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
6d3a379d
Commit
6d3a379d
authored
Oct 18, 2019
by
Ben Wheeler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revise registration error tests
parent
0dfd1cf9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
13 deletions
+29
-13
test/unit/components/registration-error-step.test.jsx
test/unit/components/registration-error-step.test.jsx
+29
-13
No files found.
test/unit/components/registration-error-step.test.jsx
View file @
6d3a379d
...
...
@@ -4,30 +4,46 @@ import JoinFlowStep from '../../../src/components/join-flow/join-flow-step';
import
RegistrationErrorStep
from
'
../../../src/components/join-flow/registration-error-step
'
;
describe
(
'
RegistrationErrorStep
'
,
()
=>
{
const
onTryAgain
=
jest
.
fn
();
let
wrapper
;
const
onSubmit
=
jest
.
fn
();
beforeEach
(()
=>
{
wrapper
=
shallowWithIntl
(
const
getRegistrationErrorStepWrapper
=
props
=>
{
const
wrapper
=
shallowWithIntl
(
<
RegistrationErrorStep
errorMsg=
{
'
error message
'
}
onTryAgain=
{
onTryAgain
}
onSubmit=
{
onSubmit
}
{
...
props
}
/>
);
});
return
wrapper
.
dive
();
// unwrap injectIntl()
};
test
(
'
shows JoinFlowStep with props
'
,
()
=>
{
// Dive to get past the anonymous component.
const
joinFlowStepWrapper
=
wrapper
.
dive
(
).
find
(
JoinFlowStep
);
test
(
'
when canTryAgain is true, show tryAgain message
'
,
()
=>
{
const
props
=
{
canTryAgain
:
true
};
const
joinFlowStepWrapper
=
getRegistrationErrorStepWrapper
(
props
).
find
(
JoinFlowStep
);
expect
(
joinFlowStepWrapper
).
toHaveLength
(
1
);
expect
(
joinFlowStepWrapper
.
props
().
description
).
toBe
(
'
error message
'
);
expect
(
joinFlowStepWrapper
.
props
().
nextButton
).
toBe
(
'
general.tryAgain
'
);
});
test
(
'
when submitted, onTryAgain is called
'
,
()
=>
{
// Dive to get past the anonymous component.
const
joinFlowStepWrapper
=
wrapper
.
dive
().
find
(
JoinFlowStep
);
test
(
'
when canTryAgain is false, show startOver message
'
,
()
=>
{
const
props
=
{
canTryAgain
:
false
};
const
joinFlowStepWrapper
=
getRegistrationErrorStepWrapper
(
props
).
find
(
JoinFlowStep
);
expect
(
joinFlowStepWrapper
).
toHaveLength
(
1
);
expect
(
joinFlowStepWrapper
.
props
().
description
).
toBe
(
'
error message
'
);
expect
(
joinFlowStepWrapper
.
props
().
nextButton
).
toBe
(
'
general.startOver
'
);
});
test
(
'
when canTryAgain is missing, show startOver message
'
,
()
=>
{
const
joinFlowStepWrapper
=
getRegistrationErrorStepWrapper
().
find
(
JoinFlowStep
);
expect
(
joinFlowStepWrapper
).
toHaveLength
(
1
);
expect
(
joinFlowStepWrapper
.
props
().
description
).
toBe
(
'
error message
'
);
expect
(
joinFlowStepWrapper
.
props
().
nextButton
).
toBe
(
'
general.startOver
'
);
});
test
(
'
when submitted, onSubmit is called
'
,
()
=>
{
const
joinFlowStepWrapper
=
getRegistrationErrorStepWrapper
().
find
(
JoinFlowStep
);
joinFlowStepWrapper
.
props
().
onSubmit
(
new
Event
(
'
event
'
));
// eslint-disable-line no-undef
expect
(
on
TryAgain
).
toHaveBeenCalled
();
expect
(
on
Submit
).
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