Simplified DeleteShortUrlModal so that it only requires writing 'delete'

This commit is contained in:
Alejandro Celaya
2022-11-25 19:08:40 +01:00
parent b79dced185
commit 0bf859d485
2 changed files with 9 additions and 9 deletions

View File

@@ -62,30 +62,28 @@ describe('<DeleteShortUrlModal />', () => {
});
it('enables submit button when proper short code is provided', async () => {
const shortCode = 'abc123';
const { user } = setUp({
loading: false,
error: false,
shortCode,
shortCode: 'abc123',
});
const getDeleteBtn = () => screen.getByRole('button', { name: 'Delete' });
expect(getDeleteBtn()).toHaveAttribute('disabled');
await user.type(screen.getByPlaceholderText(/^Insert the short code/), shortCode);
await user.type(screen.getByPlaceholderText('Insert delete'), 'delete');
expect(getDeleteBtn()).not.toHaveAttribute('disabled');
});
it('tries to delete short URL when form is submit', async () => {
const shortCode = 'abc123';
const { user } = setUp({
loading: false,
error: false,
deleted: true,
shortCode,
shortCode: 'abc123',
});
expect(deleteShortUrl).not.toHaveBeenCalled();
await user.type(screen.getByPlaceholderText(/^Insert the short code/), shortCode);
await user.type(screen.getByPlaceholderText('Insert delete'), 'delete');
await user.click(screen.getByRole('button', { name: 'Delete' }));
expect(deleteShortUrl).toHaveBeenCalledTimes(1);
await waitFor(() => expect(shortUrlDeleted).toHaveBeenCalledTimes(1));