Add `back` button to resend_verification.tsx`.
parent
a841dc659c
commit
304eae4900
|
@ -19,11 +19,12 @@ describe("resend_verification.tsx - failure case", () => {
|
|||
const props = {
|
||||
ok: jest.fn(),
|
||||
no: jest.fn(),
|
||||
onGoBack: jest.fn(),
|
||||
email: "foo@bar.com"
|
||||
};
|
||||
const el = mount(<ResendVerification {...props} />);
|
||||
expect.assertions(3);
|
||||
el.find("button").first().simulate("click");
|
||||
el.find("button").last().simulate("click");
|
||||
const { calls } = props.no.mock;
|
||||
setImmediate(() => {
|
||||
expect(props.ok.mock.calls.length).toEqual(0);
|
||||
|
|
|
@ -14,19 +14,31 @@ import { API } from "../../api/index";
|
|||
|
||||
describe("resend_verification.tsx - base case", () => {
|
||||
API.setBaseUrl("http://localhost:3000");
|
||||
let props = () => ({
|
||||
ok: jest.fn(),
|
||||
no: jest.fn(),
|
||||
onGoBack: jest.fn(),
|
||||
email: "foo@bar.com"
|
||||
});
|
||||
|
||||
it("fires the `onGoBack()` callback", () => {
|
||||
const p = props();
|
||||
const el = mount(<ResendVerification {...p } />);
|
||||
el.find("button").first().simulate("click");
|
||||
const { calls } = p.onGoBack.mock;
|
||||
expect(p.no.mock.calls.length).toEqual(0);
|
||||
expect(p.ok.mock.calls.length).toEqual(0);
|
||||
expect(calls.length).toEqual(1);
|
||||
});
|
||||
|
||||
it("fires the `ok()` callback", (done) => {
|
||||
const props = {
|
||||
ok: jest.fn(),
|
||||
no: jest.fn(),
|
||||
email: "foo@bar.com"
|
||||
};
|
||||
const el = mount(<ResendVerification {...props} />);
|
||||
const p = props();
|
||||
const el = mount(<ResendVerification {...p } />);
|
||||
expect.assertions(3);
|
||||
el.find("button").first().simulate("click");
|
||||
const { calls } = props.ok.mock;
|
||||
el.find("button").last().simulate("click");
|
||||
const { calls } = p.ok.mock;
|
||||
setImmediate(() => {
|
||||
expect(props.no.mock.calls.length).toEqual(0);
|
||||
expect(p.no.mock.calls.length).toEqual(0);
|
||||
expect(calls.length).toEqual(1);
|
||||
expect(get(calls[0][0], "data", "NOT FOUND")).toEqual("whatever");
|
||||
done();
|
||||
|
|
|
@ -116,7 +116,6 @@ export class FrontPage extends React.Component<{}, Partial<FrontPageState>> {
|
|||
|
||||
toggleForgotPassword = () => this.setState({ activePanel: "forgotPassword" });
|
||||
|
||||
|
||||
submitForgotPassword = (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
const { email } = this.state;
|
||||
|
@ -199,6 +198,7 @@ export class FrontPage extends React.Component<{}, Partial<FrontPageState>> {
|
|||
resendVerificationPanel = () => {
|
||||
const goBack = () => this.setState({ activePanel: "login" });
|
||||
return <ResendVerification
|
||||
onGoBack={() => this.setState({ activePanel: "login" })}
|
||||
ok={(resp) => {
|
||||
success(t("Verification email resent. Please check your email!"));
|
||||
goBack();
|
||||
|
|
|
@ -11,6 +11,7 @@ interface Props {
|
|||
ok(resp: AxiosResponse): void;
|
||||
/** Callback when resend fails */
|
||||
no(error: UnsafeError): void;
|
||||
onGoBack(): void;
|
||||
}
|
||||
|
||||
interface State {
|
||||
|
@ -30,7 +31,13 @@ export class ResendVerification extends React.Component<Props, State> {
|
|||
render() {
|
||||
return <Col xs={12} sm={5}>
|
||||
<Widget>
|
||||
<WidgetHeader title={t("Account Not Verified")} />
|
||||
<WidgetHeader title={t("Account Not Verified")}>
|
||||
<button onClick={this.props.onGoBack}
|
||||
type="button"
|
||||
className="fb-button gray pull-right front-page-button">
|
||||
{t("back")}
|
||||
</button>
|
||||
</WidgetHeader>
|
||||
<WidgetBody>
|
||||
<form>
|
||||
<Row>
|
||||
|
|
Loading…
Reference in New Issue