/ spec / pages / Swap.spec.tsx
Swap.spec.tsx
 1  import React from 'react';
 2  import { RouteComponentProps } from 'react-router';
 3  import Enzyme from 'enzyme';
 4  import Adapter from 'enzyme-adapter-react-16';
 5  import { createMockStore } from 'redux-test-utils';
 6  
 7  import { configReducer } from 'features/config/reducer';
 8  import { INITIAL_STATE as swap } from 'features/swap/reducer';
 9  import Swap from 'containers/Tabs/Swap';
10  import shallowWithStore from '../utils/shallowWithStore';
11  import { createMockRouteComponentProps } from '../utils/mockRouteComponentProps';
12  
13  Enzyme.configure({ adapter: new Adapter() });
14  
15  const routeProps: RouteComponentProps<any> = createMockRouteComponentProps({
16    match: { path: '/swap', url: '/swap', isExact: true, params: {} },
17    location: { pathname: '/swap', search: '', hash: '', key: 'e08jz7' },
18    history: {
19      length: 2,
20      action: 'PUSH',
21      location: { pathname: '/swap', search: '', hash: '', key: 'e08jz7', state: {} }
22    }
23  });
24  
25  it('render snapshot', () => {
26    const store = createMockStore({ swap, config: configReducer(undefined as any, {} as any) });
27    const component = shallowWithStore(<Swap {...routeProps} />, store);
28  
29    expect(component).toMatchSnapshot();
30  });