shlink-web-client/test/common/AsideMenu.test.js

28 lines
787 B
JavaScript
Raw Normal View History

import { shallow } from 'enzyme';
import React from 'react';
import { NavLink } from 'react-router-dom';
2018-12-18 00:32:51 +03:00
import asideMenuCreator from '../../src/common/AsideMenu';
2018-08-12 09:49:08 +03:00
describe('<AsideMenu />', () => {
let wrapped;
2018-12-18 00:32:51 +03:00
const DeleteServerButton = () => '';
2018-08-12 09:49:08 +03:00
beforeEach(() => {
2018-12-18 00:32:51 +03:00
const AsideMenu = asideMenuCreator(DeleteServerButton);
2018-08-12 09:49:08 +03:00
wrapped = shallow(<AsideMenu selectedServer={{ id: 'abc123' }} />);
});
afterEach(() => wrapped.unmount());
2018-08-12 09:49:08 +03:00
it('contains links to different sections', () => {
const links = wrapped.find(NavLink);
2018-08-12 09:49:08 +03:00
2019-04-19 13:54:56 +03:00
expect(links).toHaveLength(3);
links.forEach((link) => expect(link.prop('to')).toContain('abc123'));
2018-08-12 09:49:08 +03:00
});
it('contains a button to delete server', () => {
2018-12-18 00:32:51 +03:00
expect(wrapped.find(DeleteServerButton)).toHaveLength(1);
2018-08-12 09:49:08 +03:00
});
});