2018-08-26 20:48:21 +03:00
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
|
|
|
import { Route } from 'react-router-dom';
|
2018-12-17 22:24:31 +03:00
|
|
|
import { identity } from 'ramda';
|
|
|
|
import appFactory from '../src/App';
|
2018-08-26 20:48:21 +03:00
|
|
|
|
|
|
|
describe('<App />', () => {
|
|
|
|
let wrapper;
|
2018-12-17 22:24:31 +03:00
|
|
|
const MainHeader = () => '';
|
2018-08-26 20:48:21 +03:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2018-12-17 22:24:31 +03:00
|
|
|
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);
|
|
|
|
const expectedRoutesCount = 3;
|
2018-08-26 21:17:40 +03:00
|
|
|
const second = 2;
|
2018-08-26 20:48:21 +03:00
|
|
|
|
|
|
|
expect(routes).toHaveLength(expectedRoutesCount);
|
|
|
|
expect(routes.at(0).prop('path')).toEqual('/server/create');
|
|
|
|
expect(routes.at(1).prop('path')).toEqual('/');
|
2018-08-26 21:17:40 +03:00
|
|
|
expect(routes.at(second).prop('path')).toEqual('/server/:serverId');
|
2018-08-26 20:48:21 +03:00
|
|
|
});
|
|
|
|
});
|