mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 01:20:24 +03:00
Fixed tests
This commit is contained in:
parent
dbee62ac8c
commit
c181831a37
4 changed files with 9 additions and 17 deletions
|
@ -1,6 +1,5 @@
|
|||
import { shallow } from 'enzyme';
|
||||
import React from 'react';
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import asideMenuCreator from '../../src/common/AsideMenu';
|
||||
|
||||
describe('<AsideMenu />', () => {
|
||||
|
@ -15,7 +14,7 @@ describe('<AsideMenu />', () => {
|
|||
afterEach(() => wrapped.unmount());
|
||||
|
||||
it('contains links to different sections', () => {
|
||||
const links = wrapped.find(NavLink);
|
||||
const links = wrapped.find('[to]');
|
||||
|
||||
expect(links).toHaveLength(3);
|
||||
links.forEach((link) => expect(link.prop('to')).toContain('abc123'));
|
||||
|
|
|
@ -21,16 +21,8 @@ describe('<DeleteServerButton />', () => {
|
|||
it('displays modal when button is clicked', () => {
|
||||
const btn = wrapper.find('.button');
|
||||
|
||||
expect(wrapper.state('isModalOpen')).toEqual(false);
|
||||
expect(wrapper.find(DeleteServerModal).prop('isOpen')).toEqual(false);
|
||||
btn.simulate('click');
|
||||
expect(wrapper.state('isModalOpen')).toEqual(true);
|
||||
});
|
||||
|
||||
it('changes modal open state when toggled', () => {
|
||||
const modal = wrapper.find(DeleteServerModal);
|
||||
|
||||
expect(wrapper.state('isModalOpen')).toEqual(false);
|
||||
modal.prop('toggle')();
|
||||
expect(wrapper.state('isModalOpen')).toEqual(true);
|
||||
expect(wrapper.find(DeleteServerModal).prop('isOpen')).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -38,7 +38,7 @@ describe('<DeleteServerModal />', () => {
|
|||
const modalBody = wrapper.find(ModalBody);
|
||||
|
||||
expect(modalBody.find('p').first().text()).toEqual(
|
||||
`Are you sure you want to delete server ${serverName}?`
|
||||
`Are you sure you want to remove ${serverName}?`
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -44,13 +44,14 @@ describe('selectedServerReducer', () => {
|
|||
afterEach(jest.clearAllMocks);
|
||||
|
||||
it.each([
|
||||
[ version, version ],
|
||||
[ 'latest', MAX_FALLBACK_VERSION ],
|
||||
[ '%invalid_semver%', MIN_FALLBACK_VERSION ],
|
||||
])('dispatches proper actions', async (serverVersion, expectedVersion) => {
|
||||
[ version, version, `v${version}` ],
|
||||
[ 'latest', MAX_FALLBACK_VERSION, 'latest' ],
|
||||
[ '%invalid_semver%', MIN_FALLBACK_VERSION, '%invalid_semver%' ],
|
||||
])('dispatches proper actions', async (serverVersion, expectedVersion, expectedPrintableVersion) => {
|
||||
const expectedSelectedServer = {
|
||||
...selectedServer,
|
||||
version: expectedVersion,
|
||||
printableVersion: expectedPrintableVersion,
|
||||
};
|
||||
|
||||
apiClientMock.health.mockResolvedValue({ version: serverVersion });
|
||||
|
|
Loading…
Reference in a new issue