import configureStore from 'redux-mock-store'; import AccountSettingsPage from './settings.page'; import React from 'react'; import ReactTestRenderer from 'react-test-renderer'; import { MemoryRouter } from 'react-router-dom'; import { Provider } from 'react-redux'; import Enzyme, { mount } from 'enzyme/build/index'; import Adapter from 'enzyme-adapter-react-16/build/index'; import { AUTH } from 'app/common/store/auth/auth.constants'; jest.mock('app/common/store', () => ({ history: { push: () => {} }, })); describe('Account page tests', () => { Enzyme.configure({ adapter: new Adapter() }); const countryCode = 'dk'; const initialState = { user: { current: { name: 'Test name', }, data:{ country: countryCode, countryCode: countryCode, }, role: AUTH.ROLE.USER, permissions: [ 'userPassword.change', ], }, }; const mockStore = configureStore(); let store; beforeEach(() => { store = mockStore(initialState); store.dispatch = jest.fn(); }); it('renders page correctly', () => { const tree = ReactTestRenderer .create( ) .toJSON(); expect(tree).toMatchSnapshot(); }); it('dispatch sendChangePwdEmail action when reset password clicked', () => { const wrapper = mount( ); wrapper.find('.js-change-password-hit-area').simulate('click'); expect(store.dispatch).toHaveBeenCalledWith({ type: AUTH.AUTH_SEND_CHANGE_PWD_EMAIL }); }); });