2016-09-16 21:19:37 +00:00
|
|
|
import React from 'react';
|
|
|
|
import expect from 'expect';
|
|
|
|
import { mount } from 'enzyme';
|
2016-10-19 20:22:18 +00:00
|
|
|
|
2016-09-16 21:19:37 +00:00
|
|
|
import ConnectedPage, { ResetPasswordPage } from './ResetPasswordPage';
|
|
|
|
import testHelpers from '../../test/helpers';
|
|
|
|
|
|
|
|
describe('ResetPasswordPage - component', () => {
|
|
|
|
it('renders a ResetPasswordForm', () => {
|
|
|
|
const page = mount(<ResetPasswordPage token="ABC123" />);
|
|
|
|
|
|
|
|
expect(page.find('ResetPasswordForm').length).toEqual(1);
|
|
|
|
});
|
|
|
|
|
2016-10-03 17:54:22 +00:00
|
|
|
it('Redirects to the login page when there is no token or user', () => {
|
2016-09-19 15:35:38 +00:00
|
|
|
const { connectedComponent, reduxMockStore } = testHelpers;
|
2016-09-16 21:19:37 +00:00
|
|
|
const redirectToLoginAction = {
|
|
|
|
type: '@@router/CALL_HISTORY_METHOD',
|
|
|
|
payload: {
|
|
|
|
method: 'push',
|
|
|
|
args: ['/login'],
|
|
|
|
},
|
|
|
|
};
|
2016-09-19 15:35:38 +00:00
|
|
|
const store = {
|
2016-10-03 17:54:22 +00:00
|
|
|
auth: {},
|
2016-09-19 15:35:38 +00:00
|
|
|
components: {
|
|
|
|
ResetPasswordPage: {
|
|
|
|
loading: false,
|
|
|
|
error: null,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const mockStore = reduxMockStore(store);
|
2016-09-16 21:19:37 +00:00
|
|
|
|
|
|
|
mount(connectedComponent(ConnectedPage, { mockStore }));
|
|
|
|
|
|
|
|
const dispatchedActions = mockStore.getActions();
|
|
|
|
|
|
|
|
expect(dispatchedActions).toInclude(redirectToLoginAction);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|