mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-08-02 17:11:51 +00:00
Introduce shoehorn as a possible replacement for ts-mockery
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import type { NotFoundServer, ReachableServer } from '../../../src/servers/data';
|
||||
import type { ShortUrl } from '../../../src/short-urls/data';
|
||||
import type { LinkSuffix } from '../../../src/short-urls/helpers/ShortUrlDetailLink';
|
||||
@@ -10,11 +10,11 @@ describe('<ShortUrlDetailLink />', () => {
|
||||
it.each([
|
||||
[undefined, undefined],
|
||||
[null, null],
|
||||
[Mock.of<ReachableServer>({ id: '1' }), null],
|
||||
[Mock.of<ReachableServer>({ id: '1' }), undefined],
|
||||
[Mock.of<NotFoundServer>(), Mock.all<ShortUrl>()],
|
||||
[null, Mock.all<ShortUrl>()],
|
||||
[undefined, Mock.all<ShortUrl>()],
|
||||
[fromPartial<ReachableServer>({ id: '1' }), null],
|
||||
[fromPartial<ReachableServer>({ id: '1' }), undefined],
|
||||
[fromPartial<NotFoundServer>({}), fromPartial<ShortUrl>({})],
|
||||
[null, fromPartial<ShortUrl>({})],
|
||||
[undefined, fromPartial<ShortUrl>({})],
|
||||
])('only renders a plain span when either server or short URL are not set', (selectedServer, shortUrl) => {
|
||||
render(
|
||||
<ShortUrlDetailLink selectedServer={selectedServer} shortUrl={shortUrl} suffix="visits">
|
||||
@@ -28,26 +28,26 @@ describe('<ShortUrlDetailLink />', () => {
|
||||
|
||||
it.each([
|
||||
[
|
||||
Mock.of<ReachableServer>({ id: '1' }),
|
||||
Mock.of<ShortUrl>({ shortCode: 'abc123' }),
|
||||
fromPartial<ReachableServer>({ id: '1' }),
|
||||
fromPartial<ShortUrl>({ shortCode: 'abc123' }),
|
||||
'visits' as LinkSuffix,
|
||||
'/server/1/short-code/abc123/visits',
|
||||
],
|
||||
[
|
||||
Mock.of<ReachableServer>({ id: '3' }),
|
||||
Mock.of<ShortUrl>({ shortCode: 'def456', domain: 'example.com' }),
|
||||
fromPartial<ReachableServer>({ id: '3' }),
|
||||
fromPartial<ShortUrl>({ shortCode: 'def456', domain: 'example.com' }),
|
||||
'visits' as LinkSuffix,
|
||||
'/server/3/short-code/def456/visits?domain=example.com',
|
||||
],
|
||||
[
|
||||
Mock.of<ReachableServer>({ id: '1' }),
|
||||
Mock.of<ShortUrl>({ shortCode: 'abc123' }),
|
||||
fromPartial<ReachableServer>({ id: '1' }),
|
||||
fromPartial<ShortUrl>({ shortCode: 'abc123' }),
|
||||
'edit' as LinkSuffix,
|
||||
'/server/1/short-code/abc123/edit',
|
||||
],
|
||||
[
|
||||
Mock.of<ReachableServer>({ id: '3' }),
|
||||
Mock.of<ShortUrl>({ shortCode: 'def456', domain: 'example.com' }),
|
||||
fromPartial<ReachableServer>({ id: '3' }),
|
||||
fromPartial<ShortUrl>({ shortCode: 'def456', domain: 'example.com' }),
|
||||
'edit' as LinkSuffix,
|
||||
'/server/3/short-code/def456/edit?domain=example.com',
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user