2022-06-08 18:28:16 +02:00
|
|
|
import { render, screen } from '@testing-library/react';
|
2023-04-13 21:48:29 +02:00
|
|
|
import { fromPartial } from '@total-typescript/shoehorn';
|
2023-08-02 09:01:44 +02:00
|
|
|
import { CreateShortUrl as createShortUrlsCreator } from '../../src/short-urls/CreateShortUrl';
|
|
|
|
import type { ShortUrlCreation } from '../../src/short-urls/reducers/shortUrlCreation';
|
2023-08-04 11:16:01 +02:00
|
|
|
import { SettingsProvider } from '../../src/utils/settings';
|
2018-11-01 13:15:09 +01:00
|
|
|
|
|
|
|
describe('<CreateShortUrl />', () => {
|
2022-06-08 18:28:16 +02:00
|
|
|
const ShortUrlForm = () => <span>ShortUrlForm</span>;
|
|
|
|
const CreateShortUrlResult = () => <span>CreateShortUrlResult</span>;
|
2021-02-14 13:23:42 +01:00
|
|
|
const shortUrlCreation = { validateUrls: true };
|
2023-04-13 21:48:29 +02:00
|
|
|
const shortUrlCreationResult = fromPartial<ShortUrlCreation>({});
|
2023-05-27 11:57:26 +02:00
|
|
|
const createShortUrl = vi.fn(async () => Promise.resolve());
|
2022-06-08 18:28:16 +02:00
|
|
|
const CreateShortUrl = createShortUrlsCreator(ShortUrlForm, CreateShortUrlResult);
|
|
|
|
const setUp = () => render(
|
2023-08-04 11:16:01 +02:00
|
|
|
<SettingsProvider value={fromPartial({ shortUrlCreation })}>
|
|
|
|
<CreateShortUrl
|
|
|
|
shortUrlCreation={shortUrlCreationResult}
|
|
|
|
createShortUrl={createShortUrl}
|
|
|
|
resetCreateShortUrl={() => {}}
|
|
|
|
/>
|
|
|
|
</SettingsProvider>,
|
2022-06-08 18:28:16 +02:00
|
|
|
);
|
2018-11-01 13:15:09 +01:00
|
|
|
|
2022-06-08 18:28:16 +02:00
|
|
|
it('renders computed initial state', () => {
|
|
|
|
setUp();
|
2018-12-17 23:11:55 +01:00
|
|
|
|
2022-06-08 18:28:16 +02:00
|
|
|
expect(screen.getByText('ShortUrlForm')).toBeInTheDocument();
|
|
|
|
expect(screen.getByText('CreateShortUrlResult')).toBeInTheDocument();
|
2018-11-01 13:15:09 +01:00
|
|
|
});
|
|
|
|
});
|