mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-07-25 13:11:52 +00:00
Introduce shoehorn as a possible replacement for ts-mockery
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import { EventSourcePolyfill } from 'event-source-polyfill';
|
||||
import { identity } from 'ramda';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { bindToMercureTopic } from '../../../src/mercure/helpers';
|
||||
import type { MercureInfo } from '../../../src/mercure/reducers/mercureInfo';
|
||||
|
||||
@@ -14,11 +14,11 @@ describe('helpers', () => {
|
||||
const onTokenExpired = jest.fn();
|
||||
|
||||
it.each([
|
||||
[Mock.of<MercureInfo>({ loading: true, error: false, mercureHubUrl: 'foo' })],
|
||||
[Mock.of<MercureInfo>({ loading: false, error: true, mercureHubUrl: 'foo' })],
|
||||
[Mock.of<MercureInfo>({ loading: true, error: true, mercureHubUrl: 'foo' })],
|
||||
[Mock.of<MercureInfo>({ loading: false, error: false, mercureHubUrl: undefined })],
|
||||
[Mock.of<MercureInfo>({ loading: true, error: true, mercureHubUrl: undefined })],
|
||||
[fromPartial<MercureInfo>({ loading: true, error: false, mercureHubUrl: 'foo' })],
|
||||
[fromPartial<MercureInfo>({ loading: false, error: true, mercureHubUrl: 'foo' })],
|
||||
[fromPartial<MercureInfo>({ loading: true, error: true, mercureHubUrl: 'foo' })],
|
||||
[fromPartial<MercureInfo>({ loading: false, error: false, mercureHubUrl: undefined })],
|
||||
[fromPartial<MercureInfo>({ loading: true, error: true, mercureHubUrl: undefined })],
|
||||
])('does not bind an EventSource when loading, error or no hub URL', (mercureInfo) => {
|
||||
bindToMercureTopic(mercureInfo, [''], identity, () => {});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
||||
import type { GetState } from '../../../src/container/types';
|
||||
import { mercureInfoReducerCreator } from '../../../src/mercure/reducers/mercureInfo';
|
||||
@@ -9,7 +9,7 @@ describe('mercureInfoReducer', () => {
|
||||
token: 'abc.123.def',
|
||||
};
|
||||
const getMercureInfo = jest.fn();
|
||||
const buildShlinkApiClient = () => Mock.of<ShlinkApiClient>({ mercureInfo: getMercureInfo });
|
||||
const buildShlinkApiClient = () => fromPartial<ShlinkApiClient>({ mercureInfo: getMercureInfo });
|
||||
const { loadMercureInfo, reducer } = mercureInfoReducerCreator(buildShlinkApiClient);
|
||||
|
||||
beforeEach(jest.resetAllMocks);
|
||||
|
||||
Reference in New Issue
Block a user