Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
6e83c496
Commit
6e83c496
authored
Oct 23, 2019
by
Ben Wheeler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revise and add registration error step tests
parent
d265ad3d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
9 deletions
+54
-9
test/unit/components/registration-error-step.test.jsx
test/unit/components/registration-error-step.test.jsx
+54
-9
No files found.
test/unit/components/registration-error-step.test.jsx
View file @
6e83c496
...
@@ -9,8 +9,6 @@ describe('RegistrationErrorStep', () => {
...
@@ -9,8 +9,6 @@ describe('RegistrationErrorStep', () => {
const
getRegistrationErrorStepWrapper
=
props
=>
{
const
getRegistrationErrorStepWrapper
=
props
=>
{
const
wrapper
=
shallowWithIntl
(
const
wrapper
=
shallowWithIntl
(
<
RegistrationErrorStep
<
RegistrationErrorStep
errorMsg=
{
'
error message
'
}
onSubmit=
{
onSubmit
}
{
...
props
}
{
...
props
}
/>
/>
);
);
...
@@ -18,31 +16,78 @@ describe('RegistrationErrorStep', () => {
...
@@ -18,31 +16,78 @@ describe('RegistrationErrorStep', () => {
.
dive
();
// unwrap injectIntl()
.
dive
();
// unwrap injectIntl()
};
};
test
(
'
registrationError has JoinFlowStep
'
,
()
=>
{
const
props
=
{
canTryAgain
:
true
,
onSubmit
:
onSubmit
};
const
joinFlowStepWrapper
=
getRegistrationErrorStepWrapper
(
props
).
find
(
JoinFlowStep
);
expect
(
joinFlowStepWrapper
).
toHaveLength
(
1
);
});
test
(
'
when errorMsg provided, registrationError shows it
'
,
()
=>
{
const
props
=
{
canTryAgain
:
true
,
errorMsg
:
'
halp there is a errors!!
'
,
onSubmit
:
onSubmit
};
const
joinFlowStepWrapper
=
getRegistrationErrorStepWrapper
(
props
).
find
(
JoinFlowStep
);
const
joinFlowStepInstance
=
joinFlowStepWrapper
.
dive
();
const
errMsgElement
=
joinFlowStepInstance
.
find
(
'
#registration-error-msg
'
);
expect
(
errMsgElement
).
toHaveLength
(
1
);
expect
(
errMsgElement
.
text
()).
toEqual
(
'
halp there is a errors!!
'
);
});
test
(
'
when no errorMsg provided, registrationError does not show it
'
,
()
=>
{
const
props
=
{
canTryAgain
:
true
,
onSubmit
:
onSubmit
};
const
joinFlowStepWrapper
=
getRegistrationErrorStepWrapper
(
props
).
find
(
JoinFlowStep
);
const
joinFlowStepInstance
=
joinFlowStepWrapper
.
dive
();
const
errMsgElement
=
joinFlowStepInstance
.
find
(
'
#registration-error-msg
'
);
expect
(
errMsgElement
).
toHaveLength
(
0
);
});
test
(
'
when canTryAgain is true, show tryAgain message
'
,
()
=>
{
test
(
'
when canTryAgain is true, show tryAgain message
'
,
()
=>
{
const
props
=
{
canTryAgain
:
true
};
const
props
=
{
canTryAgain
:
true
,
errorMsg
:
'
halp there is a errors!!
'
,
onSubmit
:
onSubmit
};
const
joinFlowStepWrapper
=
getRegistrationErrorStepWrapper
(
props
).
find
(
JoinFlowStep
);
const
joinFlowStepWrapper
=
getRegistrationErrorStepWrapper
(
props
).
find
(
JoinFlowStep
);
expect
(
joinFlowStepWrapper
).
toHaveLength
(
1
);
expect
(
joinFlowStepWrapper
).
toHaveLength
(
1
);
expect
(
joinFlowStepWrapper
.
props
().
description
).
toBe
(
'
error message
'
);
expect
(
joinFlowStepWrapper
.
props
().
nextButton
).
toBe
(
'
general.tryAgain
'
);
expect
(
joinFlowStepWrapper
.
props
().
nextButton
).
toBe
(
'
general.tryAgain
'
);
});
});
test
(
'
when canTryAgain is false, show startOver message
'
,
()
=>
{
test
(
'
when canTryAgain is false, show startOver message
'
,
()
=>
{
const
props
=
{
canTryAgain
:
false
};
const
props
=
{
canTryAgain
:
false
,
errorMsg
:
'
halp there is a errors!!
'
,
onSubmit
:
onSubmit
};
const
joinFlowStepWrapper
=
getRegistrationErrorStepWrapper
(
props
).
find
(
JoinFlowStep
);
const
joinFlowStepWrapper
=
getRegistrationErrorStepWrapper
(
props
).
find
(
JoinFlowStep
);
expect
(
joinFlowStepWrapper
).
toHaveLength
(
1
);
expect
(
joinFlowStepWrapper
).
toHaveLength
(
1
);
expect
(
joinFlowStepWrapper
.
props
().
description
).
toBe
(
'
error message
'
);
expect
(
joinFlowStepWrapper
.
props
().
nextButton
).
toBe
(
'
general.startOver
'
);
expect
(
joinFlowStepWrapper
.
props
().
nextButton
).
toBe
(
'
general.startOver
'
);
});
});
test
(
'
when canTryAgain is missing, show startOver message
'
,
()
=>
{
test
(
'
when canTryAgain is missing, show startOver message
'
,
()
=>
{
const
joinFlowStepWrapper
=
getRegistrationErrorStepWrapper
().
find
(
JoinFlowStep
);
const
props
=
{
errorMsg
:
'
halp there is a errors!!
'
,
onSubmit
:
onSubmit
};
const
joinFlowStepWrapper
=
getRegistrationErrorStepWrapper
(
props
).
find
(
JoinFlowStep
);
expect
(
joinFlowStepWrapper
).
toHaveLength
(
1
);
expect
(
joinFlowStepWrapper
).
toHaveLength
(
1
);
expect
(
joinFlowStepWrapper
.
props
().
description
).
toBe
(
'
error message
'
);
expect
(
joinFlowStepWrapper
.
props
().
nextButton
).
toBe
(
'
general.startOver
'
);
expect
(
joinFlowStepWrapper
.
props
().
nextButton
).
toBe
(
'
general.startOver
'
);
});
});
test
(
'
when submitted, onSubmit is called
'
,
()
=>
{
test
(
'
when submitted, onSubmit is called
'
,
()
=>
{
const
joinFlowStepWrapper
=
getRegistrationErrorStepWrapper
().
find
(
JoinFlowStep
);
const
props
=
{
canTryAgain
:
true
,
errorMsg
:
'
halp there is a errors!!
'
,
onSubmit
:
onSubmit
};
const
joinFlowStepWrapper
=
getRegistrationErrorStepWrapper
(
props
).
find
(
JoinFlowStep
);
joinFlowStepWrapper
.
props
().
onSubmit
(
new
Event
(
'
event
'
));
// eslint-disable-line no-undef
joinFlowStepWrapper
.
props
().
onSubmit
(
new
Event
(
'
event
'
));
// eslint-disable-line no-undef
expect
(
onSubmit
).
toHaveBeenCalled
();
expect
(
onSubmit
).
toHaveBeenCalled
();
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment