2022-05-06 22:01:44 +03:00
|
|
|
import { render } from '@testing-library/react';
|
2023-04-13 22:48:29 +03:00
|
|
|
import { fromPartial } from '@total-typescript/shoehorn';
|
2022-05-28 11:47:39 +03:00
|
|
|
import { ShlinkVersionsContainer } from '../../src/common/ShlinkVersionsContainer';
|
2024-04-11 10:19:32 +03:00
|
|
|
import type { ReachableServer, SelectedServer } from '../../src/servers/data';
|
2023-09-30 11:20:28 +03:00
|
|
|
import { checkAccessibility } from '../__helpers__/accessibility';
|
2020-12-14 21:05:25 +03:00
|
|
|
|
|
|
|
describe('<ShlinkVersionsContainer />', () => {
|
2024-04-11 10:19:32 +03:00
|
|
|
const setUp = (selectedServer: SelectedServer = null) => render(
|
|
|
|
<ShlinkVersionsContainer selectedServer={selectedServer} />,
|
|
|
|
);
|
2023-08-06 19:07:03 +03:00
|
|
|
|
2024-04-11 10:19:32 +03:00
|
|
|
it.each([
|
|
|
|
[null],
|
|
|
|
[fromPartial<SelectedServer>({})],
|
|
|
|
[fromPartial<ReachableServer>({ version: '1.0.0', printableVersion: 'v1.0.0' })],
|
|
|
|
])('passes a11y checks', (selectedServer) => checkAccessibility(setUp(selectedServer)));
|
2023-09-30 11:20:28 +03:00
|
|
|
|
2021-09-20 23:00:34 +03:00
|
|
|
it.each([
|
2024-04-11 10:19:32 +03:00
|
|
|
[null, 'text-center'],
|
|
|
|
[fromPartial<SelectedServer>({}), 'text-center'],
|
|
|
|
[fromPartial<ReachableServer>({ version: '1.0.0' }), 'text-center shlink-versions-container--with-sidebar'],
|
|
|
|
])('renders proper col classes based on sidebar status', (selectedServer, expectedClasses) => {
|
|
|
|
const { container } = setUp(selectedServer);
|
2022-05-06 22:01:44 +03:00
|
|
|
expect(container.firstChild).toHaveAttribute('class', `${expectedClasses}`);
|
2020-12-14 21:05:25 +03:00
|
|
|
});
|
|
|
|
});
|