mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-22 22:46:19 +00:00
Introduce shoehorn as a possible replacement for ts-mockery
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import { buildShlinkApiClient } from '../../../src/api/services/ShlinkApiClientBuilder';
|
||||
import type { HttpClient } from '../../../src/common/services/HttpClient';
|
||||
import type { ShlinkState } from '../../../src/container/types';
|
||||
import type { ReachableServer, SelectedServer } from '../../../src/servers/data';
|
||||
|
||||
describe('ShlinkApiClientBuilder', () => {
|
||||
const server = (data: Partial<ReachableServer>) => Mock.of<ReachableServer>(data);
|
||||
const server = fromPartial<ReachableServer>;
|
||||
|
||||
const createBuilder = () => {
|
||||
const builder = buildShlinkApiClient(Mock.of<HttpClient>());
|
||||
return (selectedServer: SelectedServer) => builder(() => Mock.of<ShlinkState>({ selectedServer }));
|
||||
const builder = buildShlinkApiClient(fromPartial({}));
|
||||
return (selectedServer: SelectedServer) => builder(() => fromPartial({ selectedServer }));
|
||||
};
|
||||
|
||||
it('creates new instances when provided params are different', async () => {
|
||||
@@ -42,7 +40,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(Mock.of<HttpClient>())(server({ url, apiKey }));
|
||||
const apiClient = buildShlinkApiClient(fromPartial({}))(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