|
@@ -1,7 +1,7 @@
|
|
import React from 'react';
|
|
import React from 'react';
|
|
import { mount, shallow } from 'enzyme';
|
|
import { mount, shallow } from 'enzyme';
|
|
import { Provider } from 'react-redux';
|
|
import { Provider } from 'react-redux';
|
|
-import { StaticRouter } from 'react-router';
|
|
|
|
|
|
+import { StaticRouter } from 'react-router-dom';
|
|
import configureStore from 'redux/store/configureStore';
|
|
import configureStore from 'redux/store/configureStore';
|
|
import App, { AppProps } from '../App';
|
|
import App, { AppProps } from '../App';
|
|
|
|
|
|
@@ -18,12 +18,7 @@ describe('App', () => {
|
|
/>
|
|
/>
|
|
);
|
|
);
|
|
|
|
|
|
- it('matches snapshot with initial props', () => {
|
|
|
|
- const wrapper = shallow(setupComponent());
|
|
|
|
- expect(wrapper).toMatchSnapshot();
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- it('correctly mounts App component', () => {
|
|
|
|
|
|
+ it('handles fetchClustersList', () => {
|
|
const wrapper = mount(
|
|
const wrapper = mount(
|
|
<Provider store={store}>
|
|
<Provider store={store}>
|
|
<StaticRouter>{setupComponent()}</StaticRouter>
|
|
<StaticRouter>{setupComponent()}</StaticRouter>
|
|
@@ -33,12 +28,13 @@ describe('App', () => {
|
|
expect(fetchClustersList).toHaveBeenCalledTimes(1);
|
|
expect(fetchClustersList).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|
|
|
|
|
|
- it('correctly renders PageLoader', () => {
|
|
|
|
- const wrapper = shallow(setupComponent({ isClusterListFetched: false }));
|
|
|
|
- expect(wrapper.exists('PageLoader')).toBeTruthy();
|
|
|
|
-
|
|
|
|
- wrapper.setProps({ isClusterListFetched: true });
|
|
|
|
- expect(wrapper.exists('PageLoader')).toBeFalsy();
|
|
|
|
|
|
+ it('shows PageLoader until cluster list is fetched', () => {
|
|
|
|
+ const component = shallow(setupComponent({ isClusterListFetched: false }));
|
|
|
|
+ expect(component.exists('.Layout__container PageLoader')).toBeTruthy();
|
|
|
|
+ expect(component.exists('.Layout__container Switch')).toBeFalsy();
|
|
|
|
+ component.setProps({ isClusterListFetched: true });
|
|
|
|
+ expect(component.exists('.Layout__container PageLoader')).toBeFalsy();
|
|
|
|
+ expect(component.exists('.Layout__container Switch')).toBeTruthy();
|
|
});
|
|
});
|
|
|
|
|
|
it('correctly renders alerts', () => {
|
|
it('correctly renders alerts', () => {
|
|
@@ -57,4 +53,9 @@ describe('App', () => {
|
|
expect(wrapper.exists('Alert')).toBeTruthy();
|
|
expect(wrapper.exists('Alert')).toBeTruthy();
|
|
expect(wrapper.find('Alert').length).toEqual(1);
|
|
expect(wrapper.find('Alert').length).toEqual(1);
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ it('matches snapshot', () => {
|
|
|
|
+ const component = shallow(setupComponent());
|
|
|
|
+ expect(component).toMatchSnapshot();
|
|
|
|
+ });
|
|
});
|
|
});
|