mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +03:00
Used TestModalWrapper in DeleteShortUrlModal test
This commit is contained in:
parent
f0a6420ba9
commit
32f29a84f7
1 changed files with 15 additions and 10 deletions
|
@ -5,6 +5,7 @@ import { ShortUrl } from '../../../src/short-urls/data';
|
||||||
import { ShortUrlDeletion } from '../../../src/short-urls/reducers/shortUrlDeletion';
|
import { ShortUrlDeletion } from '../../../src/short-urls/reducers/shortUrlDeletion';
|
||||||
import { renderWithEvents } from '../../__helpers__/setUpTest';
|
import { renderWithEvents } from '../../__helpers__/setUpTest';
|
||||||
import { ErrorTypeV2, ErrorTypeV3, InvalidShortUrlDeletion, ProblemDetailsError } from '../../../src/api/types/errors';
|
import { ErrorTypeV2, ErrorTypeV3, InvalidShortUrlDeletion, ProblemDetailsError } from '../../../src/api/types/errors';
|
||||||
|
import { TestModalWrapper } from '../../__helpers__/TestModalWrapper';
|
||||||
|
|
||||||
describe('<DeleteShortUrlModal />', () => {
|
describe('<DeleteShortUrlModal />', () => {
|
||||||
const shortUrl = Mock.of<ShortUrl>({
|
const shortUrl = Mock.of<ShortUrl>({
|
||||||
|
@ -13,16 +14,19 @@ describe('<DeleteShortUrlModal />', () => {
|
||||||
longUrl: 'https://long-domain.com/foo/bar',
|
longUrl: 'https://long-domain.com/foo/bar',
|
||||||
});
|
});
|
||||||
const deleteShortUrl = jest.fn().mockResolvedValue(undefined);
|
const deleteShortUrl = jest.fn().mockResolvedValue(undefined);
|
||||||
const toggle = jest.fn();
|
const shortUrlDeleted = jest.fn();
|
||||||
const setUp = (shortUrlDeletion: Partial<ShortUrlDeletion>) => renderWithEvents(
|
const setUp = (shortUrlDeletion: Partial<ShortUrlDeletion>) => renderWithEvents(
|
||||||
<DeleteShortUrlModal
|
<TestModalWrapper
|
||||||
isOpen
|
renderModal={(args) => (
|
||||||
shortUrl={shortUrl}
|
<DeleteShortUrlModal
|
||||||
shortUrlDeletion={Mock.of<ShortUrlDeletion>(shortUrlDeletion)}
|
{...args}
|
||||||
deleteShortUrl={deleteShortUrl}
|
shortUrl={shortUrl}
|
||||||
shortUrlDeleted={jest.fn()}
|
shortUrlDeletion={Mock.of<ShortUrlDeletion>(shortUrlDeletion)}
|
||||||
toggle={toggle}
|
deleteShortUrl={deleteShortUrl}
|
||||||
resetDeleteShortUrl={jest.fn()}
|
shortUrlDeleted={shortUrlDeleted}
|
||||||
|
resetDeleteShortUrl={jest.fn()}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -76,6 +80,7 @@ describe('<DeleteShortUrlModal />', () => {
|
||||||
const { user } = setUp({
|
const { user } = setUp({
|
||||||
loading: false,
|
loading: false,
|
||||||
error: false,
|
error: false,
|
||||||
|
deleted: true,
|
||||||
shortCode,
|
shortCode,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -83,6 +88,6 @@ describe('<DeleteShortUrlModal />', () => {
|
||||||
await user.type(screen.getByPlaceholderText(/^Insert the short code/), shortCode);
|
await user.type(screen.getByPlaceholderText(/^Insert the short code/), shortCode);
|
||||||
await user.click(screen.getByRole('button', { name: 'Delete' }));
|
await user.click(screen.getByRole('button', { name: 'Delete' }));
|
||||||
expect(deleteShortUrl).toHaveBeenCalledTimes(1);
|
expect(deleteShortUrl).toHaveBeenCalledTimes(1);
|
||||||
await waitFor(() => expect(toggle).toHaveBeenCalledTimes(1));
|
await waitFor(() => expect(shortUrlDeleted).toHaveBeenCalledTimes(1));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue