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