Fixed tests

This commit is contained in:
Alejandro Celaya 2020-03-05 11:58:35 +01:00
parent dbee62ac8c
commit c181831a37
4 changed files with 9 additions and 17 deletions

View file

@ -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'));

View file

@ -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);
});
});

View file

@ -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}?`
);
});

View file

@ -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 });