Skip to content

Commit

Permalink
Recactoring tests in the <LoginComponent />
Browse files Browse the repository at this point in the history
  • Loading branch information
robisson committed Nov 10, 2018
1 parent 35a1209 commit 3235ace
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/client/components/Login/FormLogin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ describe("Login User", () => {
let expectedState = {
email: "email@example.com",
password: "mypassword",
requiredFields: false
emailFieldEmpty: false,
passwordFieldEmpty: false
};

//password field
Expand Down
46 changes: 45 additions & 1 deletion src/client/components/Login/__snapshots__/FormLogin.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,11 @@ exports[`Login User does not should call function onLogin when click button Logi
}
className="Login-text-4"
error={true}
helperText="The email field is empty"
inputRef={[Function]}
label="Type your email"
onChange={[Function]}
onKeyUp={[Function]}
required={false}
select={false}
variant="standard"
Expand All @@ -140,14 +143,22 @@ exports[`Login User does not should call function onLogin when click button Logi
}
}
className="Login-text-4"
error={true}
error={false}
helperText=""
label="Password"
onChange={[Function]}
onKeyUp={[Function]}
required={false}
select={false}
type="password"
variant="standard"
/>
<WithStyles(Typography)
align="center"
className="Login-textError-10"
gutterBottom={true}
variant="subtitle2"
/>
<div
style={
Object {
Expand Down Expand Up @@ -357,8 +368,11 @@ exports[`Login User should call function onLogin when click button Login with fi
}
className="Login-text-4"
error={false}
helperText=""
inputRef={[Function]}
label="Type your email"
onChange={[Function]}
onKeyUp={[Function]}
required={false}
select={false}
variant="standard"
Expand All @@ -375,13 +389,21 @@ exports[`Login User should call function onLogin when click button Login with fi
}
className="Login-text-4"
error={false}
helperText=""
label="Password"
onChange={[Function]}
onKeyUp={[Function]}
required={false}
select={false}
type="password"
variant="standard"
/>
<WithStyles(Typography)
align="center"
className="Login-textError-10"
gutterBottom={true}
variant="subtitle2"
/>
<div
style={
Object {
Expand Down Expand Up @@ -591,8 +613,11 @@ exports[`Login User should render 2 inputs and a Button 1`] = `
}
className="Login-text-4"
error={false}
helperText=""
inputRef={[Function]}
label="Type your email"
onChange={[Function]}
onKeyUp={[Function]}
required={false}
select={false}
variant="standard"
Expand All @@ -609,13 +634,21 @@ exports[`Login User should render 2 inputs and a Button 1`] = `
}
className="Login-text-4"
error={false}
helperText=""
label="Password"
onChange={[Function]}
onKeyUp={[Function]}
required={false}
select={false}
type="password"
variant="standard"
/>
<WithStyles(Typography)
align="center"
className="Login-textError-10"
gutterBottom={true}
variant="subtitle2"
/>
<div
style={
Object {
Expand Down Expand Up @@ -825,8 +858,11 @@ exports[`Login User should render 2 inputs and a Button 2`] = `
}
className="Login-text-4"
error={false}
helperText=""
inputRef={[Function]}
label="Type your email"
onChange={[Function]}
onKeyUp={[Function]}
required={false}
select={false}
variant="standard"
Expand All @@ -843,13 +879,21 @@ exports[`Login User should render 2 inputs and a Button 2`] = `
}
className="Login-text-4"
error={false}
helperText=""
label="Password"
onChange={[Function]}
onKeyUp={[Function]}
required={false}
select={false}
type="password"
variant="standard"
/>
<WithStyles(Typography)
align="center"
className="Login-textError-10"
gutterBottom={true}
variant="subtitle2"
/>
<div
style={
Object {
Expand Down
4 changes: 3 additions & 1 deletion src/client/components/Login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ class Login extends React.Component<Props, State> {
}

componentDidMount() {
this._inputEmail.focus();
if (this._inputEmail !== undefined) {
this._inputEmail.focus();
}
}

_onLogin() {
Expand Down

0 comments on commit 3235ace

Please sign in to comment.