mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +03:00
Fixed ShlinkApiClient test
This commit is contained in:
parent
f7ba974d97
commit
790c69ba80
1 changed files with 9 additions and 2 deletions
|
@ -4,6 +4,7 @@ import { OptionalString } from '../../../src/utils/utils';
|
||||||
import { ShlinkDomain, ShlinkVisits, ShlinkVisitsOverview } from '../../../src/api/types';
|
import { ShlinkDomain, ShlinkVisits, ShlinkVisitsOverview } from '../../../src/api/types';
|
||||||
import { ShortUrl, ShortUrlsOrder } from '../../../src/short-urls/data';
|
import { ShortUrl, ShortUrlsOrder } from '../../../src/short-urls/data';
|
||||||
import { JsonFetch } from '../../../src/utils/types';
|
import { JsonFetch } from '../../../src/utils/types';
|
||||||
|
import { ErrorTypeV2, ErrorTypeV3 } from '../../../src/api/types/errors';
|
||||||
|
|
||||||
describe('ShlinkApiClient', () => {
|
describe('ShlinkApiClient', () => {
|
||||||
const buildFetch = (data: any) => jest.fn().mockResolvedValue(data);
|
const buildFetch = (data: any) => jest.fn().mockResolvedValue(data);
|
||||||
|
@ -318,8 +319,14 @@ describe('ShlinkApiClient', () => {
|
||||||
expect(result).toEqual(resp);
|
expect(result).toEqual(resp);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('retries request if API version is not supported', async () => {
|
it.each([
|
||||||
const fetch = buildRejectedFetch({ type: 'NOT_FOUND', status: 404 }).mockImplementation(buildFetch({}));
|
['NOT_FOUND'],
|
||||||
|
[ErrorTypeV2.NOT_FOUND],
|
||||||
|
[ErrorTypeV3.NOT_FOUND],
|
||||||
|
])('retries request if API version is not supported', async (type) => {
|
||||||
|
const fetch = buildRejectedFetch({ type, detail: 'detail', title: 'title', status: 404 }).mockImplementation(
|
||||||
|
buildFetch({}),
|
||||||
|
);
|
||||||
const { editDomainRedirects } = buildApiClient(fetch);
|
const { editDomainRedirects } = buildApiClient(fetch);
|
||||||
|
|
||||||
await editDomainRedirects({ domain: 'foo' });
|
await editDomainRedirects({ domain: 'foo' });
|
||||||
|
|
Loading…
Reference in a new issue