mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-10 17:43:51 +00:00
Migrated ShlinkApiClient from axios to fetch
This commit is contained in:
@@ -1,16 +1,14 @@
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { buildShlinkApiClient } from '../../../src/api/services/ShlinkApiClientBuilder';
|
||||
import { ReachableServer, SelectedServer } from '../../../src/servers/data';
|
||||
import { ShlinkState } from '../../../src/container/types';
|
||||
|
||||
describe('ShlinkApiClientBuilder', () => {
|
||||
const axiosMock = Mock.all<AxiosInstance>();
|
||||
const fetch = jest.fn();
|
||||
const server = (data: Partial<ReachableServer>) => Mock.of<ReachableServer>(data);
|
||||
|
||||
const createBuilder = () => {
|
||||
const builder = buildShlinkApiClient(axiosMock);
|
||||
|
||||
const builder = buildShlinkApiClient(fetch);
|
||||
return (selectedServer: SelectedServer) => builder(() => Mock.of<ShlinkState>({ selectedServer }));
|
||||
};
|
||||
|
||||
@@ -44,7 +42,7 @@ describe('ShlinkApiClientBuilder', () => {
|
||||
it('does not fetch from state when provided param is already selected server', () => {
|
||||
const url = 'url';
|
||||
const apiKey = 'apiKey';
|
||||
const apiClient = buildShlinkApiClient(axiosMock)(server({ url, apiKey }));
|
||||
const apiClient = buildShlinkApiClient(fetch)(server({ url, apiKey }));
|
||||
|
||||
expect(apiClient['baseUrl']).toEqual(url); // eslint-disable-line @typescript-eslint/dot-notation
|
||||
expect(apiClient['apiKey']).toEqual(apiKey); // eslint-disable-line @typescript-eslint/dot-notation
|
||||
|
||||
Reference in New Issue
Block a user