|
@@ -1,10 +1,8 @@
|
|
import React from 'react';
|
|
import React from 'react';
|
|
import { Provider } from 'react-redux';
|
|
import { Provider } from 'react-redux';
|
|
-import { shallow } from 'enzyme';
|
|
|
|
|
|
+import { mount } from 'enzyme';
|
|
import configureStore from 'redux/store/configureStore';
|
|
import configureStore from 'redux/store/configureStore';
|
|
import { StaticRouter } from 'react-router-dom';
|
|
import { StaticRouter } from 'react-router-dom';
|
|
-import { match } from 'react-router';
|
|
|
|
-import { ClusterName } from 'redux/interfaces';
|
|
|
|
import Schemas, { SchemasProps } from '../Schemas';
|
|
import Schemas, { SchemasProps } from '../Schemas';
|
|
import SchemasContainer from '../SchemasContainer';
|
|
import SchemasContainer from '../SchemasContainer';
|
|
|
|
|
|
@@ -15,7 +13,7 @@ describe('Schemas', () => {
|
|
const store = configureStore();
|
|
const store = configureStore();
|
|
|
|
|
|
it('renders view', () => {
|
|
it('renders view', () => {
|
|
- const component = shallow(
|
|
|
|
|
|
+ const component = mount(
|
|
<Provider store={store}>
|
|
<Provider store={store}>
|
|
<StaticRouter location={{ pathname }} context={{}}>
|
|
<StaticRouter location={{ pathname }} context={{}}>
|
|
<SchemasContainer />
|
|
<SchemasContainer />
|
|
@@ -28,12 +26,13 @@ describe('Schemas', () => {
|
|
|
|
|
|
describe('View', () => {
|
|
describe('View', () => {
|
|
const setupWrapper = (props: Partial<SchemasProps> = {}) => (
|
|
const setupWrapper = (props: Partial<SchemasProps> = {}) => (
|
|
- <Schemas
|
|
|
|
- isFetched
|
|
|
|
- clusterName="Test"
|
|
|
|
- fetchSchemasByClusterName={jest.fn()}
|
|
|
|
- {...props}
|
|
|
|
- />
|
|
|
|
|
|
+ <StaticRouter location={{ pathname }} context={{}}>
|
|
|
|
+ <Schemas
|
|
|
|
+ isFetching
|
|
|
|
+ fetchSchemasByClusterName={jest.fn()}
|
|
|
|
+ {...props}
|
|
|
|
+ />
|
|
|
|
+ </StaticRouter>
|
|
);
|
|
);
|
|
describe('Initial state', () => {
|
|
describe('Initial state', () => {
|
|
let useEffect: jest.SpyInstance<
|
|
let useEffect: jest.SpyInstance<
|
|
@@ -43,7 +42,6 @@ describe('Schemas', () => {
|
|
deps?: React.DependencyList | undefined
|
|
deps?: React.DependencyList | undefined
|
|
]
|
|
]
|
|
>;
|
|
>;
|
|
- let wrapper;
|
|
|
|
const mockedFn = jest.fn();
|
|
const mockedFn = jest.fn();
|
|
|
|
|
|
const mockedUseEffect = () => {
|
|
const mockedUseEffect = () => {
|
|
@@ -53,33 +51,20 @@ describe('Schemas', () => {
|
|
beforeEach(() => {
|
|
beforeEach(() => {
|
|
useEffect = jest.spyOn(React, 'useEffect');
|
|
useEffect = jest.spyOn(React, 'useEffect');
|
|
mockedUseEffect();
|
|
mockedUseEffect();
|
|
-
|
|
|
|
- wrapper = shallow(
|
|
|
|
- setupWrapper({ fetchSchemasByClusterName: mockedFn })
|
|
|
|
- );
|
|
|
|
});
|
|
});
|
|
|
|
|
|
it('should call fetchSchemasByClusterName every render', () => {
|
|
it('should call fetchSchemasByClusterName every render', () => {
|
|
|
|
+ mount(setupWrapper({ fetchSchemasByClusterName: mockedFn }));
|
|
expect(mockedFn).toHaveBeenCalled();
|
|
expect(mockedFn).toHaveBeenCalled();
|
|
});
|
|
});
|
|
-
|
|
|
|
- it('matches snapshot', () => {
|
|
|
|
- expect(
|
|
|
|
- shallow(setupWrapper({ fetchSchemasByClusterName: mockedFn }))
|
|
|
|
- ).toMatchSnapshot();
|
|
|
|
- });
|
|
|
|
});
|
|
});
|
|
|
|
|
|
describe('when page is loading', () => {
|
|
describe('when page is loading', () => {
|
|
- const wrapper = shallow(setupWrapper({ isFetched: false }));
|
|
|
|
|
|
+ const wrapper = mount(setupWrapper({ isFetching: true }));
|
|
|
|
|
|
it('renders PageLoader', () => {
|
|
it('renders PageLoader', () => {
|
|
expect(wrapper.exists('PageLoader')).toBeTruthy();
|
|
expect(wrapper.exists('PageLoader')).toBeTruthy();
|
|
});
|
|
});
|
|
-
|
|
|
|
- it('matches snapshot', () => {
|
|
|
|
- expect(shallow(setupWrapper({ isFetched: false }))).toMatchSnapshot();
|
|
|
|
- });
|
|
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|