mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-03 06:47:29 +03:00
Fix remaining act-related warningsin tests
This commit is contained in:
parent
2ad0daaed5
commit
e7fab8c2d6
2 changed files with 13 additions and 16 deletions
|
@ -1,4 +1,4 @@
|
|||
import { act, render, screen, waitFor } from '@testing-library/react';
|
||||
import { act, render, screen } from '@testing-library/react';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import { AppFactory } from '../../src/app/App';
|
||||
|
@ -23,7 +23,7 @@ describe('<App />', () => {
|
|||
fetchServers={() => {}}
|
||||
servers={{}}
|
||||
settings={fromPartial({})}
|
||||
appUpdated
|
||||
appUpdated={false}
|
||||
resetAppUpdate={() => {}}
|
||||
/>
|
||||
</MemoryRouter>,
|
||||
|
@ -36,9 +36,6 @@ describe('<App />', () => {
|
|||
|
||||
expect(screen.getByText('MainHeader')).toBeInTheDocument();
|
||||
expect(screen.getByText('ShlinkVersions')).toBeInTheDocument();
|
||||
|
||||
await waitFor(() => screen.getByRole('alert'));
|
||||
expect(screen.getByText('This app has just been updated!')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it.each([
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { screen } from '@testing-library/react';
|
||||
import { act, screen } from '@testing-library/react';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import type { ServerData } from '../../../src/servers/data';
|
||||
import { DuplicatedServersModal } from '../../../src/servers/helpers/DuplicatedServersModal';
|
||||
|
@ -8,9 +8,9 @@ import { renderWithEvents } from '../../__helpers__/setUpTest';
|
|||
describe('<DuplicatedServersModal />', () => {
|
||||
const onDiscard = vi.fn();
|
||||
const onSave = vi.fn();
|
||||
const setUp = (duplicatedServers: ServerData[] = []) => renderWithEvents(
|
||||
const setUp = (duplicatedServers: ServerData[] = []) => act(() => renderWithEvents(
|
||||
<DuplicatedServersModal isOpen duplicatedServers={duplicatedServers} onDiscard={onDiscard} onSave={onSave} />,
|
||||
);
|
||||
));
|
||||
const mockServer = (data: Partial<ServerData> = {}) => fromPartial<ServerData>(data);
|
||||
|
||||
it('passes a11y checks', () => checkAccessibility(setUp()));
|
||||
|
@ -21,8 +21,8 @@ describe('<DuplicatedServersModal />', () => {
|
|||
[[mockServer(), mockServer()], 2],
|
||||
[[mockServer(), mockServer(), mockServer()], 3],
|
||||
[[mockServer(), mockServer(), mockServer(), mockServer()], 4],
|
||||
])('renders expected amount of items', (duplicatedServers, expectedItems) => {
|
||||
setUp(duplicatedServers);
|
||||
])('renders expected amount of items', async (duplicatedServers, expectedItems) => {
|
||||
await setUp(duplicatedServers);
|
||||
expect(screen.queryAllByRole('listitem')).toHaveLength(expectedItems);
|
||||
});
|
||||
|
||||
|
@ -45,8 +45,8 @@ describe('<DuplicatedServersModal />', () => {
|
|||
discardBtn: 'Ignore duplicates',
|
||||
},
|
||||
],
|
||||
])('renders expected texts based on amount of servers', (duplicatedServers, assertions) => {
|
||||
setUp(duplicatedServers);
|
||||
])('renders expected texts based on amount of servers', async (duplicatedServers, assertions) => {
|
||||
await setUp(duplicatedServers);
|
||||
|
||||
expect(screen.getByRole('heading')).toHaveTextContent(assertions.header);
|
||||
expect(screen.getByText(assertions.firstParagraph)).toBeInTheDocument();
|
||||
|
@ -61,8 +61,8 @@ describe('<DuplicatedServersModal />', () => {
|
|||
mockServer({ url: 'url_1', apiKey: 'apiKey_1' }),
|
||||
mockServer({ url: 'url_2', apiKey: 'apiKey_2' }),
|
||||
]],
|
||||
])('displays provided server data', (duplicatedServers) => {
|
||||
setUp(duplicatedServers);
|
||||
])('displays provided server data', async (duplicatedServers) => {
|
||||
await setUp(duplicatedServers);
|
||||
|
||||
if (duplicatedServers.length === 0) {
|
||||
expect(screen.queryByRole('listitem')).not.toBeInTheDocument();
|
||||
|
@ -81,7 +81,7 @@ describe('<DuplicatedServersModal />', () => {
|
|||
});
|
||||
|
||||
it('invokes onDiscard when appropriate button is clicked', async () => {
|
||||
const { user } = setUp();
|
||||
const { user } = await setUp();
|
||||
|
||||
expect(onDiscard).not.toHaveBeenCalled();
|
||||
await user.click(screen.getByRole('button', { name: 'Discard' }));
|
||||
|
@ -89,7 +89,7 @@ describe('<DuplicatedServersModal />', () => {
|
|||
});
|
||||
|
||||
it('invokes onSave when appropriate button is clicked', async () => {
|
||||
const { user } = setUp();
|
||||
const { user } = await setUp();
|
||||
|
||||
expect(onSave).not.toHaveBeenCalled();
|
||||
await user.click(screen.getByRole('button', { name: 'Save anyway' }));
|
||||
|
|
Loading…
Reference in a new issue