mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-10-21 05:04:08 +00:00
Replace direct rendering with react testing library by vitest-browser-react
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { MemoryRouter } from 'react-router';
|
||||
import { NotFound } from '../../src/common/NotFound';
|
||||
import { checkAccessibility } from '../__helpers__/accessibility';
|
||||
import { render } from '../__helpers__/setUpTest';
|
||||
|
||||
describe('<NotFound />', () => {
|
||||
const setUp = (props = {}) =>
|
||||
@@ -14,15 +14,15 @@ describe('<NotFound />', () => {
|
||||
it('passes a11y checks', () => checkAccessibility(setUp()));
|
||||
|
||||
it('shows expected error title', async () => {
|
||||
setUp();
|
||||
await expect.element(screen.getByText('Oops! We could not find requested route.')).toBeInTheDocument();
|
||||
const page = await setUp();
|
||||
await expect.element(page.getByText('Oops! We could not find requested route.')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows expected error message', async () => {
|
||||
setUp();
|
||||
const page = await setUp();
|
||||
await expect
|
||||
.element(
|
||||
screen.getByText(
|
||||
page.getByText(
|
||||
"Use your browser's back button to navigate to the page you have previously come from, or just press this button.",
|
||||
),
|
||||
)
|
||||
@@ -34,8 +34,8 @@ describe('<NotFound />', () => {
|
||||
[{ to: '/foo/bar', children: 'Hello' }, '/foo/bar', 'Hello'],
|
||||
[{ to: '/baz-bar', children: <>Foo</> }, '/baz-bar', 'Foo'],
|
||||
])('shows expected link and text', async (props, expectedLink, expectedText) => {
|
||||
setUp(props);
|
||||
const link = screen.getByRole('link');
|
||||
const page = await setUp(props);
|
||||
const link = page.getByRole('link');
|
||||
|
||||
await expect.element(link).toHaveAttribute('href', expectedLink);
|
||||
await expect.element(link).toHaveTextContent(expectedText);
|
||||
|
||||
Reference in New Issue
Block a user