diff --git a/client/components/organization-wrapper/organization-wrapper.js b/client/components/organization-wrapper/organization-wrapper.js
index c8aa31b1..dba16282 100644
--- a/client/components/organization-wrapper/organization-wrapper.js
+++ b/client/components/organization-wrapper/organization-wrapper.js
@@ -96,6 +96,7 @@ OrganizationWrapper.propTypes = {
params: PropTypes.shape({
organization: PropTypes.string.isRequired,
}),
+ path: PropTypes.string,
}).isRequired,
setOrganization: PropTypes.func.isRequired,
organization: PropTypes.shape({
diff --git a/client/components/password-confirm/__snapshots__/password-confirm.test.js.snap b/client/components/password-confirm/__snapshots__/password-confirm.test.js.snap
new file mode 100644
index 00000000..02bfa401
--- /dev/null
+++ b/client/components/password-confirm/__snapshots__/password-confirm.test.js.snap
@@ -0,0 +1,80 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[` rendering should render correctly 1`] = `
+
{success}
{getText(loginPageLink.text, language)}
diff --git a/client/components/password-reset/password-reset.test.js b/client/components/password-reset/password-reset.test.js
new file mode 100644
index 00000000..5f576f5e
--- /dev/null
+++ b/client/components/password-reset/password-reset.test.js
@@ -0,0 +1,156 @@
+/* eslint-disable prefer-promise-reject-errors */
+import axios from "axios";
+import {shallow} from "enzyme";
+import React from "react";
+import {BrowserRouter as Router} from "react-router-dom";
+import renderer from "react-test-renderer";
+
+import PasswordReset from "./password-reset";
+
+jest.mock("axios");
+
+const createTestProps = props => {
+ return {
+ language: "en",
+ orgSlug: "default",
+ passwordReset: {
+ heading: {
+ en: "reset your password",
+ },
+ additional_text: {
+ en:
+ "enter your email and we'll send you the instructions to reset your password",
+ },
+ input_fields: {
+ email: {
+ type: "email",
+ pattern: null,
+ pattern_description: {
+ en: null,
+ },
+ placeholder: {
+ en: "email address",
+ },
+ label: {
+ en: "email",
+ },
+ },
+ },
+ buttons: {
+ send: {
+ en: "send",
+ },
+ },
+ login_page_link: {
+ text: {
+ en: "Take me Back to Sign In",
+ },
+ },
+ },
+ ...props,
+ };
+};
+
+describe("
rendering", () => {
+ let props;
+ let wrapper;
+ beforeEach(() => {
+ props = createTestProps();
+ wrapper = shallow(
);
+ });
+ it("should render correctly", () => {
+ props = createTestProps();
+ const component = renderer
+ .create(
+
+
+ ,
+ )
+ .toJSON();
+ expect(component).toMatchSnapshot();
+ });
+ it("should render 1 input field", () => {
+ expect(wrapper.find(".owisp-password-reset-input")).toHaveLength(1);
+ });
+
+ it("should render email field correctly", () => {
+ const {email} = props.passwordReset.input_fields;
+ expect(wrapper.find(".owisp-password-reset-label-email").text()).toBe(
+ email.label.en,
+ );
+ expect(
+ wrapper.find(".owisp-password-reset-input-email").prop("placeholder"),
+ ).toBe(email.placeholder.en);
+ expect(
+ wrapper.find(".owisp-password-reset-input-email").prop("title"),
+ ).toBe(email.pattern_description.en);
+ expect(wrapper.find(".owisp-password-reset-input-email").prop("type")).toBe(
+ email.type,
+ );
+ });
+});
+
+describe("
interactions", () => {
+ let props;
+ let wrapper;
+ beforeEach(() => {
+ props = createTestProps();
+ wrapper = shallow(
);
+ });
+ it("should change state values when handleChange function is invoked", () => {
+ wrapper
+ .find("#owisp-password-reset-email")
+ .simulate("change", {target: {value: "test@test.com", name: "email"}});
+ expect(wrapper.state("email")).toEqual("test@test.com");
+ });
+
+ it("should execute handleSubmit correctly when form is submitted", () => {
+ axios
+ .mockImplementationOnce(() => {
+ return Promise.reject({response: {data: {detail: "errors"}}});
+ })
+ .mockImplementationOnce(() => {
+ return Promise.reject({
+ response: {data: {non_field_errors: ["non field errors"]}},
+ });
+ })
+ .mockImplementationOnce(() => {
+ return Promise.resolve({data: {detail: true}});
+ });
+ return wrapper
+ .instance()
+ .handleSubmit({preventDefault: () => {}})
+ .then(() => {
+ expect(wrapper.instance().state.errors.email).toEqual("errors");
+ expect(wrapper.find(".owisp-password-reset-input.error")).toHaveLength(
+ 1,
+ );
+ expect(wrapper.find(".owisp-password-reset-error")).toHaveLength(1);
+ })
+ .then(() => {
+ return wrapper
+ .instance()
+ .handleSubmit({preventDefault: () => {}})
+ .then(() => {
+ expect(wrapper.instance().state.errors.email).toEqual(
+ "non field errors",
+ );
+ });
+ })
+ .then(() => {
+ return wrapper
+ .instance()
+ .handleSubmit({preventDefault: () => {}})
+ .then(() => {
+ expect(wrapper.instance().state.errors).toEqual({});
+ expect(wrapper.instance().state.success).toBe(true);
+ expect(
+ wrapper.find(".owisp-password-reset-input.error"),
+ ).toHaveLength(0);
+ expect(wrapper.find(".owisp-password-reset-success")).toHaveLength(
+ 1,
+ );
+ });
+ });
+ });
+});