mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-05-30 00:56:17 +00:00
Moved common test set-up code to helper function
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { screen } from '@testing-library/react';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { CreateShortUrlResult as createResult } from '../../../src/short-urls/helpers/CreateShortUrlResult';
|
||||
import { ShortUrl } from '../../../src/short-urls/data';
|
||||
import { TimeoutToggle } from '../../../src/utils/helpers/hooks';
|
||||
import { renderWithEvents } from '../../__mocks__/setUpTest';
|
||||
|
||||
describe('<CreateShortUrlResult />', () => {
|
||||
const copyToClipboard = jest.fn();
|
||||
const useTimeoutToggle = jest.fn(() => [false, copyToClipboard]) as TimeoutToggle;
|
||||
const CreateShortUrlResult = createResult(useTimeoutToggle);
|
||||
const setUp = (result: ShortUrl | null = null, error = false) => ({
|
||||
user: userEvent.setup(),
|
||||
...render(<CreateShortUrlResult resetCreateShortUrl={() => {}} result={result} error={error} saving={false} />),
|
||||
});
|
||||
const setUp = (result: ShortUrl | null = null, error = false) => renderWithEvents(
|
||||
<CreateShortUrlResult resetCreateShortUrl={() => {}} result={result} error={error} saving={false} />,
|
||||
);
|
||||
|
||||
afterEach(jest.clearAllMocks);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user