2022-06-08 19:28:16 +03:00
|
|
|
import { render, screen } from '@testing-library/react';
|
2020-08-30 20:45:17 +03:00
|
|
|
import { Mock } from 'ts-mockery';
|
2022-05-28 12:16:59 +03:00
|
|
|
import { CreateShortUrl as createShortUrlsCreator } from '../../src/short-urls/CreateShortUrl';
|
2020-08-30 20:45:17 +03:00
|
|
|
import { ShortUrlCreation } from '../../src/short-urls/reducers/shortUrlCreation';
|
2021-02-14 15:23:42 +03:00
|
|
|
import { Settings } from '../../src/settings/reducers/settings';
|
2018-11-01 15:15:09 +03:00
|
|
|
|
|
|
|
describe('<CreateShortUrl />', () => {
|
2022-06-08 19:28:16 +03:00
|
|
|
const ShortUrlForm = () => <span>ShortUrlForm</span>;
|
|
|
|
const CreateShortUrlResult = () => <span>CreateShortUrlResult</span>;
|
2021-02-14 15:23:42 +03:00
|
|
|
const shortUrlCreation = { validateUrls: true };
|
2020-08-30 20:45:17 +03:00
|
|
|
const shortUrlCreationResult = Mock.all<ShortUrlCreation>();
|
|
|
|
const createShortUrl = jest.fn(async () => Promise.resolve());
|
2022-06-08 19:28:16 +03:00
|
|
|
const CreateShortUrl = createShortUrlsCreator(ShortUrlForm, CreateShortUrlResult);
|
|
|
|
const setUp = () => render(
|
|
|
|
<CreateShortUrl
|
|
|
|
shortUrlCreationResult={shortUrlCreationResult}
|
|
|
|
createShortUrl={createShortUrl}
|
|
|
|
selectedServer={null}
|
|
|
|
resetCreateShortUrl={() => {}}
|
|
|
|
settings={Mock.of<Settings>({ shortUrlCreation })}
|
|
|
|
/>,
|
|
|
|
);
|
2018-11-01 15:15:09 +03:00
|
|
|
|
2022-06-08 19:28:16 +03:00
|
|
|
it('renders computed initial state', () => {
|
|
|
|
setUp();
|
2018-12-18 01:11:55 +03:00
|
|
|
|
2022-06-08 19:28:16 +03:00
|
|
|
expect(screen.getByText('ShortUrlForm')).toBeInTheDocument();
|
|
|
|
expect(screen.getByText('CreateShortUrlResult')).toBeInTheDocument();
|
2018-11-01 15:15:09 +03:00
|
|
|
});
|
|
|
|
});
|