shlink-web-client/shlink-web-component/test/short-urls/CreateShortUrl.test.tsx

30 lines
1.2 KiB
TypeScript
Raw Normal View History

import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { CreateShortUrl as createShortUrlsCreator } from '../../src/short-urls/CreateShortUrl';
import type { ShortUrlCreation } from '../../src/short-urls/reducers/shortUrlCreation';
2018-11-01 15:15:09 +03:00
describe('<CreateShortUrl />', () => {
const ShortUrlForm = () => <span>ShortUrlForm</span>;
const CreateShortUrlResult = () => <span>CreateShortUrlResult</span>;
const shortUrlCreation = { validateUrls: true };
const shortUrlCreationResult = fromPartial<ShortUrlCreation>({});
2023-05-27 12:57:26 +03:00
const createShortUrl = vi.fn(async () => Promise.resolve());
const CreateShortUrl = createShortUrlsCreator(ShortUrlForm, CreateShortUrlResult);
const setUp = () => render(
<CreateShortUrl
shortUrlCreation={shortUrlCreationResult}
createShortUrl={createShortUrl}
selectedServer={null}
resetCreateShortUrl={() => {}}
settings={fromPartial({ shortUrlCreation })}
/>,
);
2018-11-01 15:15:09 +03:00
it('renders computed initial state', () => {
setUp();
expect(screen.getByText('ShortUrlForm')).toBeInTheDocument();
expect(screen.getByText('CreateShortUrlResult')).toBeInTheDocument();
2018-11-01 15:15:09 +03:00
});
});