diff --git a/src/core/client/auth/components/App.spec.tsx b/src/core/client/auth/components/App.spec.tsx new file mode 100644 index 000000000..ec7dd130d --- /dev/null +++ b/src/core/client/auth/components/App.spec.tsx @@ -0,0 +1,14 @@ +import { shallow } from "enzyme"; +import React from "react"; + +import { PropTypesOf } from "talk-framework/types"; + +import App from "./App"; + +it("renders sign in", () => { + const props: PropTypesOf = { + view: "SIGN_IN", + }; + const wrapper = shallow(); + expect(wrapper).toMatchSnapshot(); +}); diff --git a/src/core/client/auth/components/App.tsx b/src/core/client/auth/components/App.tsx index f2537db83..103bf95dc 100644 --- a/src/core/client/auth/components/App.tsx +++ b/src/core/client/auth/components/App.tsx @@ -30,7 +30,7 @@ const renderView = (view: View) => { case "RESET_PASSWORD": return ; default: - return ; + throw new Error(`Unknown view ${view}`); } }; diff --git a/src/core/client/auth/components/ForgotPassword.tsx b/src/core/client/auth/components/ForgotPassword.tsx index 794acebfa..53a13b76a 100644 --- a/src/core/client/auth/components/ForgotPassword.tsx +++ b/src/core/client/auth/components/ForgotPassword.tsx @@ -33,7 +33,7 @@ export interface ForgotPasswordForm { const ForgotPassword: StatelessComponent = props => { return (
- {({ handleSubmit, submitError }) => ( + {({ handleSubmit, submitting, submitError }) => ( @@ -71,7 +71,13 @@ const ForgotPassword: StatelessComponent = props => { onChange={input.onChange} value={input.value} placeholder="Email Address" + color={ + meta.touched && (meta.error || meta.submitError) + ? "error" + : "regular" + } fullWidth + disabled={submitting} /> {meta.touched && @@ -84,7 +90,13 @@ const ForgotPassword: StatelessComponent = props => { )} - diff --git a/src/core/client/auth/components/ResetPassword.tsx b/src/core/client/auth/components/ResetPassword.tsx index dadf210db..fd75246fb 100644 --- a/src/core/client/auth/components/ResetPassword.tsx +++ b/src/core/client/auth/components/ResetPassword.tsx @@ -36,7 +36,7 @@ export interface ResetPasswordForm { const ResetPassword: StatelessComponent = props => { return ( - {({ handleSubmit, submitError }) => ( + {({ handleSubmit, submitting, submitError }) => ( @@ -77,6 +77,12 @@ const ResetPassword: StatelessComponent = props => { value={input.value} placeholder="Password" type="password" + color={ + meta.touched && (meta.error || meta.submitError) + ? "error" + : "regular" + } + disabled={submitting} fullWidth /> @@ -109,6 +115,12 @@ const ResetPassword: StatelessComponent = props => { value={input.value} placeholder="Confirm Password" type="password" + color={ + meta.touched && (meta.error || meta.submitError) + ? "error" + : "regular" + } + disabled={submitting} fullWidth /> @@ -122,7 +134,13 @@ const ResetPassword: StatelessComponent = props => { )} - diff --git a/src/core/client/auth/components/SignIn.tsx b/src/core/client/auth/components/SignIn.tsx index c1058365e..b1bbe514a 100644 --- a/src/core/client/auth/components/SignIn.tsx +++ b/src/core/client/auth/components/SignIn.tsx @@ -71,6 +71,12 @@ const SignIn: StatelessComponent = props => { onChange={input.onChange} value={input.value} placeholder="Email Address" + color={ + meta.touched && (meta.error || meta.submitError) + ? "error" + : "regular" + } + disabled={submitting} fullWidth /> @@ -100,6 +106,12 @@ const SignIn: StatelessComponent = props => { value={input.value} placeholder="Password" type="password" + color={ + meta.touched && (meta.error || meta.submitError) + ? "error" + : "regular" + } + disabled={submitting} fullWidth /> @@ -115,6 +127,7 @@ const SignIn: StatelessComponent = props => { variant="underlined" color="primary" size="small" + disabled={submitting} onClick={props.onGotoForgotPassword} > Forgot your password? @@ -130,6 +143,7 @@ const SignIn: StatelessComponent = props => { color="primary" size="large" type="submit" + disabled={submitting} fullWidth > Sign in and join the conversation @@ -143,6 +157,7 @@ const SignIn: StatelessComponent = props => { variant="underlined" size="small" color="primary" + disabled={submitting} onClick={props.onGotoSignUp} /> } diff --git a/src/core/client/auth/components/SignUp.tsx b/src/core/client/auth/components/SignUp.tsx index cd511dd42..a5ea25c62 100644 --- a/src/core/client/auth/components/SignUp.tsx +++ b/src/core/client/auth/components/SignUp.tsx @@ -41,7 +41,7 @@ export interface SignUpForm { const SignUp: StatelessComponent = props => { return ( - {({ handleSubmit, submitError }) => ( + {({ handleSubmit, submitting, submitError }) => ( @@ -73,6 +73,12 @@ const SignUp: StatelessComponent = props => { onChange={input.onChange} value={input.value} placeholder="Email Address" + color={ + meta.touched && (meta.error || meta.submitError) + ? "error" + : "regular" + } + disabled={submitting} fullWidth /> @@ -109,6 +115,12 @@ const SignUp: StatelessComponent = props => { onChange={input.onChange} value={input.value} placeholder="Username" + color={ + meta.touched && (meta.error || meta.submitError) + ? "error" + : "regular" + } + disabled={submitting} fullWidth /> @@ -145,6 +157,12 @@ const SignUp: StatelessComponent = props => { value={input.value} placeholder="Password" type="password" + color={ + meta.touched && (meta.error || meta.submitError) + ? "error" + : "regular" + } + disabled={submitting} fullWidth /> @@ -176,6 +194,12 @@ const SignUp: StatelessComponent = props => { value={input.value} placeholder="Confirm Password" type="password" + color={ + meta.touched && (meta.error || meta.submitError) + ? "error" + : "regular" + } + disabled={submitting} fullWidth /> @@ -193,8 +217,9 @@ const SignUp: StatelessComponent = props => { variant="filled" color="primary" size="large" - fullWidth type="submit" + disabled={submitting} + fullWidth > Sign up and join the conversation @@ -208,6 +233,7 @@ const SignUp: StatelessComponent = props => { size="small" color="primary" onClick={props.onGotoSignIn} + disabled={submitting} /> } > diff --git a/src/core/client/auth/components/__snapshots__/App.spec.tsx.snap b/src/core/client/auth/components/__snapshots__/App.spec.tsx.snap new file mode 100644 index 000000000..449ec1ce6 --- /dev/null +++ b/src/core/client/auth/components/__snapshots__/App.spec.tsx.snap @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders sign in 1`] = ` +
+ +
+`; diff --git a/src/core/client/stream/components/PostCommentFormFake.spec.tsx b/src/core/client/stream/components/PostCommentFormFake.spec.tsx new file mode 100644 index 000000000..0721cd6fe --- /dev/null +++ b/src/core/client/stream/components/PostCommentFormFake.spec.tsx @@ -0,0 +1,9 @@ +import { shallow } from "enzyme"; +import React from "react"; + +import PostCommentFormFake from "./PostCommentFormFake"; + +it("renders correctly", () => { + const wrapper = shallow(); + expect(wrapper).toMatchSnapshot(); +}); diff --git a/src/core/client/stream/components/PoweredBy.spec.tsx b/src/core/client/stream/components/PoweredBy.spec.tsx new file mode 100644 index 000000000..f0f754745 --- /dev/null +++ b/src/core/client/stream/components/PoweredBy.spec.tsx @@ -0,0 +1,15 @@ +import { shallow } from "enzyme"; +import { noop } from "lodash"; +import React from "react"; + +import { PropTypesOf } from "talk-framework/types"; + +import PoweredBy from "./PoweredBy"; + +it("renders correctly", () => { + const props: PropTypesOf = { + className: "custom", + }; + const wrapper = shallow(); + expect(wrapper).toMatchSnapshot(); +}); diff --git a/src/core/client/stream/components/UserBoxAuthenticated.spec.tsx b/src/core/client/stream/components/UserBoxAuthenticated.spec.tsx new file mode 100644 index 000000000..5e658f287 --- /dev/null +++ b/src/core/client/stream/components/UserBoxAuthenticated.spec.tsx @@ -0,0 +1,16 @@ +import { shallow } from "enzyme"; +import { noop } from "lodash"; +import React from "react"; + +import { PropTypesOf } from "talk-framework/types"; + +import UserBoxAuthenticated from "./UserBoxAuthenticated"; + +it("renders correctly", () => { + const props: PropTypesOf = { + onSignOut: noop, + username: "Username", + }; + const wrapper = shallow(); + expect(wrapper).toMatchSnapshot(); +}); diff --git a/src/core/client/stream/components/__snapshots__/PostCommentFormFake.spec.tsx.snap b/src/core/client/stream/components/__snapshots__/PostCommentFormFake.spec.tsx.snap new file mode 100644 index 000000000..2f29d6793 --- /dev/null +++ b/src/core/client/stream/components/__snapshots__/PostCommentFormFake.spec.tsx.snap @@ -0,0 +1,26 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders correctly 1`] = ` + +