2021-04-12 13:32:25 +00:00
|
|
|
import React from "react";
|
|
|
|
import { mount } from "enzyme";
|
2016-10-19 20:22:18 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
import ConnectedPage, { ResetPasswordPage } from "./ResetPasswordPage";
|
|
|
|
import testHelpers from "../../test/helpers";
|
2016-09-16 21:19:37 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
describe("ResetPasswordPage - component", () => {
|
|
|
|
it("renders a ResetPasswordForm", () => {
|
2016-09-16 21:19:37 +00:00
|
|
|
const page = mount(<ResetPasswordPage token="ABC123" />);
|
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
expect(page.find("ResetPasswordForm").length).toEqual(1);
|
2016-09-16 21:19:37 +00:00
|
|
|
});
|
|
|
|
|
2021-04-12 13:32:25 +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 = {
|
2021-04-12 13:32:25 +00:00
|
|
|
type: "@@router/CALL_HISTORY_METHOD",
|
2016-09-16 21:19:37 +00:00
|
|
|
payload: {
|
2021-04-12 13:32:25 +00:00
|
|
|
method: "push",
|
|
|
|
args: ["/login"],
|
2016-09-16 21:19:37 +00:00
|
|
|
},
|
|
|
|
};
|
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();
|
|
|
|
|
2020-12-01 18:15:12 +00:00
|
|
|
expect(dispatchedActions).toContainEqual(redirectToLoginAction);
|
2016-09-16 21:19:37 +00:00
|
|
|
});
|
|
|
|
});
|