mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-16 12:33:48 +00:00
Introduce shoehorn as a possible replacement for ts-mockery
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { screen } from '@testing-library/react';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import type { ShortUrl } from '../../../src/short-urls/data';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import { CreateShortUrlResult as createResult } from '../../../src/short-urls/helpers/CreateShortUrlResult';
|
||||
import type { ShortUrlCreation } from '../../../src/short-urls/reducers/shortUrlCreation';
|
||||
import type { TimeoutToggle } from '../../../src/utils/helpers/hooks';
|
||||
@@ -28,14 +27,14 @@ describe('<CreateShortUrlResult />', () => {
|
||||
|
||||
it('renders a result message when result is provided', () => {
|
||||
setUp(
|
||||
{ result: Mock.of<ShortUrl>({ shortUrl: 'https://s.test/abc123' }), saving: false, saved: true, error: false },
|
||||
{ result: fromPartial({ shortUrl: 'https://s.test/abc123' }), saving: false, saved: true, error: false },
|
||||
);
|
||||
expect(screen.getByText(/The short URL is/)).toHaveTextContent('Great! The short URL is https://s.test/abc123');
|
||||
});
|
||||
|
||||
it('Invokes tooltip timeout when copy to clipboard button is clicked', async () => {
|
||||
const { user } = setUp(
|
||||
{ result: Mock.of<ShortUrl>({ shortUrl: 'https://s.test/abc123' }), saving: false, saved: true, error: false },
|
||||
{ result: fromPartial({ shortUrl: 'https://s.test/abc123' }), saving: false, saved: true, error: false },
|
||||
);
|
||||
|
||||
expect(copyToClipboard).not.toHaveBeenCalled();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { screen, waitFor } from '@testing-library/react';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import type { InvalidShortUrlDeletion, ProblemDetailsError } from '../../../src/api/types/errors';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import type { InvalidShortUrlDeletion } from '../../../src/api/types/errors';
|
||||
import { ErrorTypeV2, ErrorTypeV3 } from '../../../src/api/types/errors';
|
||||
import type { ShortUrl } from '../../../src/short-urls/data';
|
||||
import { DeleteShortUrlModal } from '../../../src/short-urls/helpers/DeleteShortUrlModal';
|
||||
@@ -9,7 +9,7 @@ import { renderWithEvents } from '../../__helpers__/setUpTest';
|
||||
import { TestModalWrapper } from '../../__helpers__/TestModalWrapper';
|
||||
|
||||
describe('<DeleteShortUrlModal />', () => {
|
||||
const shortUrl = Mock.of<ShortUrl>({
|
||||
const shortUrl = fromPartial<ShortUrl>({
|
||||
tags: [],
|
||||
shortCode: 'abc123',
|
||||
longUrl: 'https://long-domain.com/foo/bar',
|
||||
@@ -22,7 +22,7 @@ describe('<DeleteShortUrlModal />', () => {
|
||||
<DeleteShortUrlModal
|
||||
{...args}
|
||||
shortUrl={shortUrl}
|
||||
shortUrlDeletion={Mock.of<ShortUrlDeletion>(shortUrlDeletion)}
|
||||
shortUrlDeletion={fromPartial(shortUrlDeletion)}
|
||||
deleteShortUrl={deleteShortUrl}
|
||||
shortUrlDeleted={shortUrlDeleted}
|
||||
resetDeleteShortUrl={jest.fn()}
|
||||
@@ -38,7 +38,7 @@ describe('<DeleteShortUrlModal />', () => {
|
||||
loading: false,
|
||||
error: true,
|
||||
shortCode: 'abc123',
|
||||
errorData: Mock.of<ProblemDetailsError>({ type: 'OTHER_ERROR' }),
|
||||
errorData: fromPartial({ type: 'OTHER_ERROR' }),
|
||||
});
|
||||
expect(screen.getByText('Something went wrong while deleting the URL :(').parentElement).not.toHaveClass(
|
||||
'bg-warning',
|
||||
@@ -46,8 +46,8 @@ describe('<DeleteShortUrlModal />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[Mock.of<InvalidShortUrlDeletion>({ type: ErrorTypeV3.INVALID_SHORT_URL_DELETION })],
|
||||
[Mock.of<InvalidShortUrlDeletion>({ type: ErrorTypeV2.INVALID_SHORT_URL_DELETION })],
|
||||
[fromPartial<InvalidShortUrlDeletion>({ type: ErrorTypeV3.INVALID_SHORT_URL_DELETION })],
|
||||
[fromPartial<InvalidShortUrlDeletion>({ type: ErrorTypeV2.INVALID_SHORT_URL_DELETION })],
|
||||
])('shows specific error when threshold error occurs', (errorData) => {
|
||||
setUp({ loading: false, error: true, shortCode: 'abc123', errorData });
|
||||
expect(screen.getByText('Something went wrong while deleting the URL :(').parentElement).toHaveClass('bg-warning');
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { screen } from '@testing-library/react';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import type { ReportExporter } from '../../../src/common/services/ReportExporter';
|
||||
import type { NotFoundServer, ReachableServer, SelectedServer } from '../../../src/servers/data';
|
||||
import type { NotFoundServer, SelectedServer } from '../../../src/servers/data';
|
||||
import { ExportShortUrlsBtn as createExportShortUrlsBtn } from '../../../src/short-urls/helpers/ExportShortUrlsBtn';
|
||||
import { renderWithEvents } from '../../__helpers__/setUpTest';
|
||||
|
||||
@@ -10,11 +10,11 @@ describe('<ExportShortUrlsBtn />', () => {
|
||||
const listShortUrls = jest.fn();
|
||||
const buildShlinkApiClient = jest.fn().mockReturnValue({ listShortUrls });
|
||||
const exportShortUrls = jest.fn();
|
||||
const reportExporter = Mock.of<ReportExporter>({ exportShortUrls });
|
||||
const reportExporter = fromPartial<ReportExporter>({ exportShortUrls });
|
||||
const ExportShortUrlsBtn = createExportShortUrlsBtn(buildShlinkApiClient, reportExporter);
|
||||
const setUp = (amount?: number, selectedServer?: SelectedServer) => renderWithEvents(
|
||||
<MemoryRouter>
|
||||
<ExportShortUrlsBtn selectedServer={selectedServer ?? Mock.all<SelectedServer>()} amount={amount} />
|
||||
<ExportShortUrlsBtn selectedServer={selectedServer ?? fromPartial({})} amount={amount} />
|
||||
</MemoryRouter>,
|
||||
);
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('<ExportShortUrlsBtn />', () => {
|
||||
|
||||
it.each([
|
||||
[null],
|
||||
[Mock.of<NotFoundServer>()],
|
||||
[fromPartial<NotFoundServer>({})],
|
||||
])('does nothing on click if selected server is not reachable', async (selectedServer) => {
|
||||
const { user } = setUp(0, selectedServer);
|
||||
|
||||
@@ -49,7 +49,7 @@ describe('<ExportShortUrlsBtn />', () => {
|
||||
[385, 20],
|
||||
])('loads proper amount of pages based on the amount of results', async (amount, expectedPageLoads) => {
|
||||
listShortUrls.mockResolvedValue({ data: [] });
|
||||
const { user } = setUp(amount, Mock.of<ReachableServer>({ id: '123' }));
|
||||
const { user } = setUp(amount, fromPartial({ id: '123' }));
|
||||
|
||||
await user.click(screen.getByRole('button'));
|
||||
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
import { fireEvent, screen } from '@testing-library/react';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import type { ImageDownloader } from '../../../src/common/services/ImageDownloader';
|
||||
import type { ReachableServer } from '../../../src/servers/data';
|
||||
import type { ShortUrl } from '../../../src/short-urls/data';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import { QrCodeModal as createQrCodeModal } from '../../../src/short-urls/helpers/QrCodeModal';
|
||||
import type { SemVer } from '../../../src/utils/helpers/version';
|
||||
import { renderWithEvents } from '../../__helpers__/setUpTest';
|
||||
|
||||
describe('<QrCodeModal />', () => {
|
||||
const saveImage = jest.fn().mockReturnValue(Promise.resolve());
|
||||
const QrCodeModal = createQrCodeModal(Mock.of<ImageDownloader>({ saveImage }));
|
||||
const QrCodeModal = createQrCodeModal(fromPartial({ saveImage }));
|
||||
const shortUrl = 'https://s.test/abc123';
|
||||
const setUp = (version: SemVer = '2.8.0') => renderWithEvents(
|
||||
<QrCodeModal
|
||||
isOpen
|
||||
shortUrl={Mock.of<ShortUrl>({ shortUrl })}
|
||||
selectedServer={Mock.of<ReachableServer>({ version })}
|
||||
shortUrl={fromPartial({ shortUrl })}
|
||||
selectedServer={fromPartial({ version })}
|
||||
toggle={() => {}}
|
||||
/>,
|
||||
);
|
||||
|
||||
@@ -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',
|
||||
],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { render, screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import type { ShlinkVisitsSummary } from '../../../src/api/types';
|
||||
import type { ShortUrl, ShortUrlMeta } from '../../../src/short-urls/data';
|
||||
import { ShortUrlStatus } from '../../../src/short-urls/helpers/ShortUrlStatus';
|
||||
@@ -13,35 +13,35 @@ describe('<ShortUrlStatus />', () => {
|
||||
|
||||
it.each([
|
||||
[
|
||||
Mock.of<ShortUrlMeta>({ validSince: '2099-01-01T10:30:15' }),
|
||||
fromPartial<ShortUrlMeta>({ validSince: '2099-01-01T10:30:15' }),
|
||||
{},
|
||||
'This short URL will start working on 2099-01-01 10:30.',
|
||||
],
|
||||
[
|
||||
Mock.of<ShortUrlMeta>({ validUntil: '2020-01-01T10:30:15' }),
|
||||
fromPartial<ShortUrlMeta>({ validUntil: '2020-01-01T10:30:15' }),
|
||||
{},
|
||||
'This short URL cannot be visited since 2020-01-01 10:30.',
|
||||
],
|
||||
[
|
||||
Mock.of<ShortUrlMeta>({ maxVisits: 10 }),
|
||||
Mock.of<ShlinkVisitsSummary>({ total: 10 }),
|
||||
fromPartial<ShortUrlMeta>({ maxVisits: 10 }),
|
||||
fromPartial<ShlinkVisitsSummary>({ total: 10 }),
|
||||
'This short URL cannot be currently visited because it has reached the maximum amount of 10 visits.',
|
||||
],
|
||||
[
|
||||
Mock.of<ShortUrlMeta>({ maxVisits: 1 }),
|
||||
Mock.of<ShlinkVisitsSummary>({ total: 1 }),
|
||||
fromPartial<ShortUrlMeta>({ maxVisits: 1 }),
|
||||
fromPartial<ShlinkVisitsSummary>({ total: 1 }),
|
||||
'This short URL cannot be currently visited because it has reached the maximum amount of 1 visit.',
|
||||
],
|
||||
[{}, {}, 'This short URL can be visited normally.'],
|
||||
[Mock.of<ShortUrlMeta>({ validUntil: '2099-01-01T10:30:15' }), {}, 'This short URL can be visited normally.'],
|
||||
[Mock.of<ShortUrlMeta>({ validSince: '2020-01-01T10:30:15' }), {}, 'This short URL can be visited normally.'],
|
||||
[fromPartial<ShortUrlMeta>({ validUntil: '2099-01-01T10:30:15' }), {}, 'This short URL can be visited normally.'],
|
||||
[fromPartial<ShortUrlMeta>({ validSince: '2020-01-01T10:30:15' }), {}, 'This short URL can be visited normally.'],
|
||||
[
|
||||
Mock.of<ShortUrlMeta>({ maxVisits: 10 }),
|
||||
Mock.of<ShlinkVisitsSummary>({ total: 1 }),
|
||||
fromPartial<ShortUrlMeta>({ maxVisits: 10 }),
|
||||
fromPartial<ShlinkVisitsSummary>({ total: 1 }),
|
||||
'This short URL can be visited normally.',
|
||||
],
|
||||
])('shows expected tooltip', async (meta, visitsSummary, expectedTooltip) => {
|
||||
const { user } = setUp(Mock.of<ShortUrl>({ meta, visitsSummary }));
|
||||
const { user } = setUp(fromPartial({ meta, visitsSummary }));
|
||||
|
||||
await user.hover(screen.getByRole('img', { hidden: true }));
|
||||
await waitFor(() => expect(screen.getByRole('tooltip')).toHaveTextContent(expectedTooltip));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { render, screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import type { ShortUrl } from '../../../src/short-urls/data';
|
||||
import { ShortUrlVisitsCount } from '../../../src/short-urls/helpers/ShortUrlVisitsCount';
|
||||
|
||||
@@ -14,7 +14,7 @@ describe('<ShortUrlVisitsCount />', () => {
|
||||
|
||||
it.each([undefined, {}])('just returns visits when no limits are provided', (meta) => {
|
||||
const visitsCount = 45;
|
||||
const { container } = setUp(visitsCount, Mock.of<ShortUrl>({ meta }));
|
||||
const { container } = setUp(visitsCount, fromPartial({ meta }));
|
||||
|
||||
expect(container.firstChild).toHaveTextContent(`${visitsCount}`);
|
||||
expect(container.querySelector('.short-urls-visits-count__max-visits-control')).not.toBeInTheDocument();
|
||||
@@ -24,7 +24,7 @@ describe('<ShortUrlVisitsCount />', () => {
|
||||
const visitsCount = 45;
|
||||
const maxVisits = 500;
|
||||
const meta = { maxVisits };
|
||||
const { container } = setUp(visitsCount, Mock.of<ShortUrl>({ meta }));
|
||||
const { container } = setUp(visitsCount, fromPartial({ meta }));
|
||||
|
||||
expect(container.firstChild).toHaveTextContent(`/ ${maxVisits}`);
|
||||
});
|
||||
@@ -44,7 +44,7 @@ describe('<ShortUrlVisitsCount />', () => {
|
||||
'This short URL will not accept visits after 2023-05-05 15:30',
|
||||
], { validSince: '2023-01-01T10:00:00', validUntil: '2023-05-05T15:30:30', maxVisits: 100 }],
|
||||
])('displays proper amount of tooltip list items', async (expectedListItems, meta) => {
|
||||
const { user } = setUp(100, Mock.of<ShortUrl>({ meta }));
|
||||
const { user } = setUp(100, fromPartial({ meta }));
|
||||
|
||||
await user.hover(screen.getByRole('img', { hidden: true }));
|
||||
await waitFor(() => expect(screen.getByRole('list')));
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { screen } from '@testing-library/react';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import { addDays, formatISO, subDays } from 'date-fns';
|
||||
import { last } from 'ramda';
|
||||
import { MemoryRouter, useLocation } from 'react-router-dom';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import type { ReachableServer } from '../../../src/servers/data';
|
||||
import type { Settings } from '../../../src/settings/reducers/settings';
|
||||
import type { ShortUrl, ShortUrlMeta } from '../../../src/short-urls/data';
|
||||
@@ -28,7 +28,7 @@ jest.mock('react-router-dom', () => ({
|
||||
describe('<ShortUrlsRow />', () => {
|
||||
const timeoutToggle = jest.fn(() => true);
|
||||
const useTimeoutToggle = jest.fn(() => [false, timeoutToggle]) as TimeoutToggle;
|
||||
const server = Mock.of<ReachableServer>({ url: 'https://s.test' });
|
||||
const server = fromPartial<ReachableServer>({ url: 'https://s.test' });
|
||||
const shortUrl: ShortUrl = {
|
||||
shortCode: 'abc123',
|
||||
shortUrl: 'https://s.test/abc123',
|
||||
@@ -60,7 +60,7 @@ describe('<ShortUrlsRow />', () => {
|
||||
selectedServer={server}
|
||||
shortUrl={{ ...shortUrl, title, tags, meta: { ...shortUrl.meta, ...meta } }}
|
||||
onTagClick={() => null}
|
||||
settings={Mock.of<Settings>(settings)}
|
||||
settings={fromPartial(settings)}
|
||||
/>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -118,13 +118,13 @@ describe('<ShortUrlsRow />', () => {
|
||||
|
||||
it.each([
|
||||
[{}, '', shortUrl.visitsSummary?.total],
|
||||
[Mock.of<Settings>({ visits: { excludeBots: false } }), '', shortUrl.visitsSummary?.total],
|
||||
[Mock.of<Settings>({ visits: { excludeBots: true } }), '', shortUrl.visitsSummary?.nonBots],
|
||||
[Mock.of<Settings>({ visits: { excludeBots: false } }), 'excludeBots=true', shortUrl.visitsSummary?.nonBots],
|
||||
[Mock.of<Settings>({ visits: { excludeBots: true } }), 'excludeBots=true', shortUrl.visitsSummary?.nonBots],
|
||||
[fromPartial<Settings>({ visits: { excludeBots: false } }), '', shortUrl.visitsSummary?.total],
|
||||
[fromPartial<Settings>({ visits: { excludeBots: true } }), '', shortUrl.visitsSummary?.nonBots],
|
||||
[fromPartial<Settings>({ visits: { excludeBots: false } }), 'excludeBots=true', shortUrl.visitsSummary?.nonBots],
|
||||
[fromPartial<Settings>({ visits: { excludeBots: true } }), 'excludeBots=true', shortUrl.visitsSummary?.nonBots],
|
||||
[{}, 'excludeBots=true', shortUrl.visitsSummary?.nonBots],
|
||||
[Mock.of<Settings>({ visits: { excludeBots: true } }), 'excludeBots=false', shortUrl.visitsSummary?.total],
|
||||
[Mock.of<Settings>({ visits: { excludeBots: false } }), 'excludeBots=false', shortUrl.visitsSummary?.total],
|
||||
[fromPartial<Settings>({ visits: { excludeBots: true } }), 'excludeBots=false', shortUrl.visitsSummary?.total],
|
||||
[fromPartial<Settings>({ visits: { excludeBots: false } }), 'excludeBots=false', shortUrl.visitsSummary?.total],
|
||||
[{}, 'excludeBots=false', shortUrl.visitsSummary?.total],
|
||||
])('renders visits count in fifth row', (settings, search, expectedAmount) => {
|
||||
setUp({ settings }, search);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { screen } from '@testing-library/react';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import type { ReachableServer } from '../../../src/servers/data';
|
||||
import type { ShortUrl } from '../../../src/short-urls/data';
|
||||
import { ShortUrlsRowMenu as createShortUrlsRowMenu } from '../../../src/short-urls/helpers/ShortUrlsRowMenu';
|
||||
@@ -8,8 +8,8 @@ import { renderWithEvents } from '../../__helpers__/setUpTest';
|
||||
|
||||
describe('<ShortUrlsRowMenu />', () => {
|
||||
const ShortUrlsRowMenu = createShortUrlsRowMenu(() => <i>DeleteShortUrlModal</i>, () => <i>QrCodeModal</i>);
|
||||
const selectedServer = Mock.of<ReachableServer>({ id: 'abc123' });
|
||||
const shortUrl = Mock.of<ShortUrl>({
|
||||
const selectedServer = fromPartial<ReachableServer>({ id: 'abc123' });
|
||||
const shortUrl = fromPartial<ShortUrl>({
|
||||
shortCode: 'abc123',
|
||||
shortUrl: 'https://s.test/abc123',
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import type { ShortUrl } from '../../../src/short-urls/data';
|
||||
import { shortUrlDataFromShortUrl, urlDecodeShortCode, urlEncodeShortCode } from '../../../src/short-urls/helpers';
|
||||
|
||||
@@ -8,7 +8,7 @@ describe('helpers', () => {
|
||||
[undefined, { validateUrls: true }, { longUrl: '', validateUrl: true }],
|
||||
[undefined, undefined, { longUrl: '', validateUrl: false }],
|
||||
[
|
||||
Mock.of<ShortUrl>({ meta: {} }),
|
||||
fromPartial<ShortUrl>({ meta: {} }),
|
||||
{ validateUrls: false },
|
||||
{
|
||||
longUrl: undefined,
|
||||
|
||||
Reference in New Issue
Block a user