From 77e59c886d8c93d03cbee6c629ff6c493221fbcf Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 24 Apr 2022 18:54:44 +0200 Subject: [PATCH] Added test for ShlinkApiClient.getDomainVisits --- test/api/services/ShlinkApiClient.test.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/api/services/ShlinkApiClient.test.ts b/test/api/services/ShlinkApiClient.test.ts index 6b08a82e..88bab25f 100644 --- a/test/api/services/ShlinkApiClient.test.ts +++ b/test/api/services/ShlinkApiClient.test.ts @@ -115,6 +115,28 @@ describe('ShlinkApiClient', () => { }); }); + describe('getDomainVisits', () => { + it('properly returns domain visits', async () => { + const expectedVisits = ['foo', 'bar']; + const axiosSpy = createAxiosMock({ + data: { + visits: { + data: expectedVisits, + }, + }, + }); + const { getDomainVisits } = new ShlinkApiClient(axiosSpy, '', ''); + + const actualVisits = await getDomainVisits('foo.com', {}); + + expect({ data: expectedVisits }).toEqual(actualVisits); + expect(axiosSpy).toHaveBeenCalledWith(expect.objectContaining({ + url: '/domains/foo.com/visits', + method: 'GET', + })); + }); + }); + describe('getShortUrl', () => { it.each(shortCodesWithDomainCombinations)('properly returns short URL', async (shortCode, domain) => { const expectedShortUrl = { foo: 'bar' };