mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-09 09:47:28 +03:00
Migrated ShlinkVersionsContainer test to react testing library
This commit is contained in:
parent
4ea826ed2c
commit
00f154ef4e
1 changed files with 6 additions and 13 deletions
|
@ -1,26 +1,19 @@
|
||||||
import { shallow, ShallowWrapper } from 'enzyme';
|
import { render } from '@testing-library/react';
|
||||||
import { Mock } from 'ts-mockery';
|
import { Mock } from 'ts-mockery';
|
||||||
import ShlinkVersionsContainer from '../../src/common/ShlinkVersionsContainer';
|
import ShlinkVersionsContainer from '../../src/common/ShlinkVersionsContainer';
|
||||||
import { SelectedServer } from '../../src/servers/data';
|
import { SelectedServer } from '../../src/servers/data';
|
||||||
import { Sidebar } from '../../src/common/reducers/sidebar';
|
import { Sidebar } from '../../src/common/reducers/sidebar';
|
||||||
|
|
||||||
describe('<ShlinkVersionsContainer />', () => {
|
describe('<ShlinkVersionsContainer />', () => {
|
||||||
let wrapper: ShallowWrapper;
|
const setUp = (sidebar: Sidebar) => render(
|
||||||
|
<ShlinkVersionsContainer selectedServer={Mock.all<SelectedServer>()} sidebar={sidebar} />,
|
||||||
const createWrapper = (sidebar: Sidebar) => {
|
);
|
||||||
wrapper = shallow(<ShlinkVersionsContainer selectedServer={Mock.all<SelectedServer>()} sidebar={sidebar} />);
|
|
||||||
|
|
||||||
return wrapper;
|
|
||||||
};
|
|
||||||
|
|
||||||
afterEach(() => wrapper?.unmount());
|
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[{ sidebarPresent: false }, 'text-center'],
|
[{ sidebarPresent: false }, 'text-center'],
|
||||||
[{ sidebarPresent: true }, 'text-center shlink-versions-container--with-sidebar'],
|
[{ sidebarPresent: true }, 'text-center shlink-versions-container--with-sidebar'],
|
||||||
])('renders proper col classes based on sidebar status', (sidebar, expectedClasses) => {
|
])('renders proper col classes based on sidebar status', (sidebar, expectedClasses) => {
|
||||||
const wrapper = createWrapper(sidebar);
|
const { container } = setUp(sidebar);
|
||||||
|
expect(container.firstChild).toHaveAttribute('class', `${expectedClasses}`);
|
||||||
expect(wrapper.find('div').prop('className')).toEqual(`${expectedClasses}`);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue