shlink-web-client/test/common/ShlinkVersionsContainer.test.tsx

31 lines
1.1 KiB
TypeScript
Raw Normal View History

import { render } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { createMemoryHistory } from 'history';
import { Router } from 'react-router-dom';
2022-05-28 11:47:39 +03:00
import { ShlinkVersionsContainer } from '../../src/common/ShlinkVersionsContainer';
2023-09-30 11:20:28 +03:00
import { checkAccessibility } from '../__helpers__/accessibility';
describe('<ShlinkVersionsContainer />', () => {
2023-09-30 11:20:28 +03:00
const setUp = (activeRoute: string = '') => {
const history = createMemoryHistory();
history.push(activeRoute);
return render(
<Router location={history.location} navigator={history}>
<ShlinkVersionsContainer selectedServer={fromPartial({})} />
</Router>,
);
};
2023-09-30 11:20:28 +03:00
it('passes a11y checks', () => checkAccessibility(setUp()));
it.each([
['/something', 'text-center'],
['/server/foo/edit', 'text-center'],
['/server/foo/bar', 'text-center shlink-versions-container--with-sidebar'],
])('renders proper col classes based on sidebar status', (sidebar, expectedClasses) => {
const { container } = setUp(sidebar);
expect(container.firstChild).toHaveAttribute('class', `${expectedClasses}`);
});
});