Added test for ShlinkApiClient.getDomainVisits

This commit is contained in:
Alejandro Celaya 2022-04-24 18:54:44 +02:00
parent 05254326cb
commit 77e59c886d

View file

@ -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', () => { describe('getShortUrl', () => {
it.each(shortCodesWithDomainCombinations)('properly returns short URL', async (shortCode, domain) => { it.each(shortCodesWithDomainCombinations)('properly returns short URL', async (shortCode, domain) => {
const expectedShortUrl = { foo: 'bar' }; const expectedShortUrl = { foo: 'bar' };