shlink-web-client/test/App.test.js

36 lines
940 B
JavaScript
Raw Normal View History

2018-08-26 20:48:21 +03:00
import React from 'react';
import { shallow } from 'enzyme';
import { Route } from 'react-router-dom';
import { identity } from 'ramda';
import appFactory from '../src/App';
2018-08-26 20:48:21 +03:00
describe('<App />', () => {
let wrapper;
const MainHeader = () => '';
2018-08-26 20:48:21 +03:00
beforeEach(() => {
const App = appFactory(MainHeader, identity, identity, identity);
2018-08-26 20:48:21 +03:00
wrapper = shallow(<App />);
});
afterEach(() => wrapper.unmount());
it('renders a header', () => expect(wrapper.find(MainHeader)).toHaveLength(1));
it('renders app main routes', () => {
const routes = wrapper.find(Route);
2019-03-03 13:02:29 +03:00
const expectedRoutesCount = 4;
const expectedPaths = [
'/server/create',
'/',
'/server/:serverId',
];
2018-08-26 20:48:21 +03:00
2019-03-03 13:02:29 +03:00
expect.assertions(expectedPaths.length + 1);
2018-08-26 20:48:21 +03:00
expect(routes).toHaveLength(expectedRoutesCount);
2019-03-03 13:02:29 +03:00
expectedPaths.forEach((path, index) => {
expect(routes.at(index).prop('path')).toEqual(path);
});
2018-08-26 20:48:21 +03:00
});
});