Extracted helper fetch function and migrated remoteServers redux action from axios to fetch

This commit is contained in:
Alejandro Celaya
2022-11-14 23:25:39 +01:00
parent e5afe4f767
commit d800062159
9 changed files with 67 additions and 78 deletions

View File

@@ -6,10 +6,8 @@ import { ShortUrl, ShortUrlsOrder } from '../../../src/short-urls/data';
import { Fetch } from '../../../src/utils/types';
describe('ShlinkApiClient', () => {
const buildFetch = (data: any) => jest.fn().mockResolvedValue({ json: () => Promise.resolve(data), ok: true });
const buildRejectedFetch = (error: any) => jest.fn().mockResolvedValueOnce(
{ json: () => Promise.resolve(error), ok: false },
);
const buildFetch = (data: any) => jest.fn().mockResolvedValue(data);
const buildRejectedFetch = (error: any) => jest.fn().mockRejectedValueOnce(error);
const buildApiClient = (fetch: Fetch) => new ShlinkApiClient(fetch, '', '');
const shortCodesWithDomainCombinations: [string, OptionalString][] = [
['abc123', null],