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
510906e5
Commit
510906e5
authored
Oct 23, 2019
by
Ben Wheeler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed stray onCaptchaError from bind list
parent
f713298d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
67 deletions
+52
-67
src/components/join-flow/email-step.jsx
src/components/join-flow/email-step.jsx
+1
-2
test/unit/components/email-step.test.jsx
test/unit/components/email-step.test.jsx
+51
-65
No files found.
src/components/join-flow/email-step.jsx
View file @
510906e5
...
...
@@ -25,8 +25,7 @@ class EmailStep extends React.Component {
'
validateForm
'
,
'
setCaptchaRef
'
,
'
captchaSolved
'
,
'
onCaptchaLoad
'
,
'
onCaptchaError
'
'
onCaptchaLoad
'
]);
this
.
state
=
{
captchaIsLoading
:
true
...
...
test/unit/components/email-step.test.jsx
View file @
510906e5
...
...
@@ -26,23 +26,23 @@ describe('EmailStep test', () => {
});
test
(
'
send correct props to formik
'
,
()
=>
{
const
w
rapper
=
shallowWithIntl
(<
EmailStep
/>);
const
formikWrapper
=
w
rapper
.
dive
();
expect
(
formik
Wrapper
.
props
().
initialValues
.
subscribe
).
toBe
(
false
);
expect
(
formik
Wrapper
.
props
().
initialValues
.
email
).
toBe
(
''
);
expect
(
formik
Wrapper
.
props
().
validateOnBlur
).
toBe
(
false
);
expect
(
formik
Wrapper
.
props
().
validateOnChange
).
toBe
(
false
);
expect
(
formikWrapper
.
props
().
validate
).
toBe
(
formik
Wrapper
.
instance
().
validateForm
);
expect
(
formikWrapper
.
props
().
onSubmit
).
toBe
(
formik
Wrapper
.
instance
().
handleValidSubmit
);
const
intlW
rapper
=
shallowWithIntl
(<
EmailStep
/>);
const
emailStepWrapper
=
intlW
rapper
.
dive
();
expect
(
emailStep
Wrapper
.
props
().
initialValues
.
subscribe
).
toBe
(
false
);
expect
(
emailStep
Wrapper
.
props
().
initialValues
.
email
).
toBe
(
''
);
expect
(
emailStep
Wrapper
.
props
().
validateOnBlur
).
toBe
(
false
);
expect
(
emailStep
Wrapper
.
props
().
validateOnChange
).
toBe
(
false
);
expect
(
emailStepWrapper
.
props
().
validate
).
toBe
(
emailStep
Wrapper
.
instance
().
validateForm
);
expect
(
emailStepWrapper
.
props
().
onSubmit
).
toBe
(
emailStep
Wrapper
.
instance
().
handleValidSubmit
);
});
test
(
'
props sent to JoinFlowStep
'
,
()
=>
{
const
w
rapper
=
shallowWithIntl
(<
EmailStep
/>);
const
intlW
rapper
=
shallowWithIntl
(<
EmailStep
/>);
// Dive to get past the intl wrapper
const
formikWrapper
=
w
rapper
.
dive
();
const
emailStepWrapper
=
intlW
rapper
.
dive
();
// Dive to get past the anonymous component.
const
joinFlowWrapper
=
formik
Wrapper
.
dive
().
find
(
JoinFlowStep
);
const
joinFlowWrapper
=
emailStep
Wrapper
.
dive
().
find
(
JoinFlowStep
);
expect
(
joinFlowWrapper
).
toHaveLength
(
1
);
expect
(
joinFlowWrapper
.
props
().
footerContent
.
props
.
id
).
toBe
(
'
registration.acceptTermsOfUse
'
);
expect
(
joinFlowWrapper
.
props
().
headerImgSrc
).
toBe
(
'
/images/join-flow/email-header.png
'
);
...
...
@@ -54,11 +54,11 @@ describe('EmailStep test', () => {
});
test
(
'
props sent to FormikInput for email
'
,
()
=>
{
const
w
rapper
=
shallowWithIntl
(<
EmailStep
/>);
const
intlW
rapper
=
shallowWithIntl
(<
EmailStep
/>);
// Dive to get past the intl wrapper
const
formikWrapper
=
w
rapper
.
dive
();
const
emailStepWrapper
=
intlW
rapper
.
dive
();
// Dive to get past the anonymous component.
const
joinFlowWrapper
=
formik
Wrapper
.
dive
().
find
(
JoinFlowStep
);
const
joinFlowWrapper
=
emailStep
Wrapper
.
dive
().
find
(
JoinFlowStep
);
expect
(
joinFlowWrapper
).
toHaveLength
(
1
);
const
emailInputWrapper
=
joinFlowWrapper
.
find
(
FormikInput
).
first
();
expect
(
emailInputWrapper
.
props
().
id
).
toEqual
(
'
email
'
);
...
...
@@ -66,16 +66,16 @@ describe('EmailStep test', () => {
expect
(
emailInputWrapper
.
props
().
name
).
toEqual
(
'
email
'
);
expect
(
emailInputWrapper
.
props
().
placeholder
).
toEqual
(
'
general.emailAddress
'
);
expect
(
emailInputWrapper
.
props
().
validationClassName
).
toEqual
(
'
validation-full-width-input
'
);
expect
(
emailInputWrapper
.
props
().
onSetRef
).
toEqual
(
formik
Wrapper
.
instance
().
handleSetEmailRef
);
expect
(
emailInputWrapper
.
props
().
validate
).
toEqual
(
formik
Wrapper
.
instance
().
validateEmail
);
expect
(
emailInputWrapper
.
props
().
onSetRef
).
toEqual
(
emailStep
Wrapper
.
instance
().
handleSetEmailRef
);
expect
(
emailInputWrapper
.
props
().
validate
).
toEqual
(
emailStep
Wrapper
.
instance
().
validateEmail
);
});
test
(
'
props sent to FormikCheckbox for subscribe
'
,
()
=>
{
const
w
rapper
=
shallowWithIntl
(<
EmailStep
/>);
const
intlW
rapper
=
shallowWithIntl
(<
EmailStep
/>);
// Dive to get past the intl wrapper
const
formikWrapper
=
w
rapper
.
dive
();
const
emailStepWrapper
=
intlW
rapper
.
dive
();
// Dive to get past the anonymous component.
const
joinFlowWrapper
=
formik
Wrapper
.
dive
().
find
(
JoinFlowStep
);
const
joinFlowWrapper
=
emailStep
Wrapper
.
dive
().
find
(
JoinFlowStep
);
expect
(
joinFlowWrapper
).
toHaveLength
(
1
);
const
checkboxWrapper
=
joinFlowWrapper
.
find
(
FormikCheckbox
).
first
();
expect
(
checkboxWrapper
).
toHaveLength
(
1
);
...
...
@@ -93,12 +93,12 @@ describe('EmailStep test', () => {
render
:
jest
.
fn
()
};
const
formData
=
{
item1
:
'
thing
'
,
item2
:
'
otherthing
'
};
const
w
rapper
=
shallowWithIntl
(
const
intlW
rapper
=
shallowWithIntl
(
<
EmailStep
/>);
const
formikWrapper
=
w
rapper
.
dive
();
formik
Wrapper
.
instance
().
onCaptchaLoad
();
// to setup catpcha state
formik
Wrapper
.
instance
().
handleValidSubmit
(
formData
,
formikBag
);
const
emailStepWrapper
=
intlW
rapper
.
dive
();
emailStep
Wrapper
.
instance
().
onCaptchaLoad
();
// to setup catpcha state
emailStep
Wrapper
.
instance
().
handleValidSubmit
(
formData
,
formikBag
);
expect
(
formikBag
.
setSubmitting
).
toHaveBeenCalledWith
(
false
);
expect
(
global
.
grecaptcha
.
execute
).
toHaveBeenCalled
();
...
...
@@ -116,18 +116,18 @@ describe('EmailStep test', () => {
render
:
jest
.
fn
()
};
const
formData
=
{
item1
:
'
thing
'
,
item2
:
'
otherthing
'
};
const
w
rapper
=
shallowWithIntl
(
const
intlW
rapper
=
shallowWithIntl
(
<
EmailStep
{
...
props
}
/>);
const
formikWrapper
=
w
rapper
.
dive
();
const
emailStepWrapper
=
intlW
rapper
.
dive
();
// Call these to setup captcha.
formik
Wrapper
.
instance
().
onCaptchaLoad
();
// to setup catpcha state
formik
Wrapper
.
instance
().
handleValidSubmit
(
formData
,
formikBag
);
emailStep
Wrapper
.
instance
().
onCaptchaLoad
();
// to setup catpcha state
emailStep
Wrapper
.
instance
().
handleValidSubmit
(
formData
,
formikBag
);
const
captchaToken
=
'
abcd
'
;
formik
Wrapper
.
instance
().
captchaSolved
(
captchaToken
);
emailStep
Wrapper
.
instance
().
captchaSolved
(
captchaToken
);
// Make sure captchaSolved calls onNextStep with formData that has
// a captcha token and left everything else in the object in place.
expect
(
props
.
onNextStep
).
toHaveBeenCalledWith
(
...
...
@@ -139,65 +139,51 @@ describe('EmailStep test', () => {
expect
(
formikBag
.
setSubmitting
).
toHaveBeenCalledWith
(
true
);
});
test
(
'
onCaptchaError calls error function with correct message
'
,
()
=>
{
const
props
=
{
onRegistrationError
:
jest
.
fn
()
};
const
wrapper
=
shallowWithIntl
(
<
EmailStep
{
...
props
}
/>);
const
formikWrapper
=
wrapper
.
dive
();
formikWrapper
.
instance
().
onCaptchaError
();
expect
(
props
.
onRegistrationError
).
toHaveBeenCalledWith
(
'
registration.troubleReload
'
);
});
test
(
'
Captcha load error calls error function
'
,
()
=>
{
const
props
=
{
on
Registration
Error
:
jest
.
fn
()
on
Captcha
Error
:
jest
.
fn
()
};
// Set this to null to force an error.
global
.
grecaptcha
=
null
;
const
w
rapper
=
shallowWithIntl
(
const
intlW
rapper
=
shallowWithIntl
(
<
EmailStep
{
...
props
}
/>);
/>
);
const
formikWrapper
=
w
rapper
.
dive
();
formik
Wrapper
.
instance
().
onCaptchaLoad
();
expect
(
props
.
on
RegistrationError
).
toHaveBeenCalledWith
(
'
registration.troubleReload
'
);
const
emailStepWrapper
=
intlW
rapper
.
dive
();
emailStep
Wrapper
.
instance
().
onCaptchaLoad
();
expect
(
props
.
on
CaptchaError
).
toHaveBeenCalled
(
);
});
test
(
'
validateEmail test email empty
'
,
()
=>
{
const
w
rapper
=
shallowWithIntl
(
const
intlW
rapper
=
shallowWithIntl
(
<
EmailStep
/>);
const
formikWrapper
=
w
rapper
.
dive
();
const
val
=
formik
Wrapper
.
instance
().
validateEmail
(
''
);
const
emailStepWrapper
=
intlW
rapper
.
dive
();
const
val
=
emailStep
Wrapper
.
instance
().
validateEmail
(
''
);
expect
(
val
).
toBe
(
'
general.required
'
);
});
test
(
'
validateEmail test email null
'
,
()
=>
{
const
w
rapper
=
shallowWithIntl
(
const
intlW
rapper
=
shallowWithIntl
(
<
EmailStep
/>);
const
formikWrapper
=
w
rapper
.
dive
();
const
val
=
formik
Wrapper
.
instance
().
validateEmail
(
null
);
const
emailStepWrapper
=
intlW
rapper
.
dive
();
const
val
=
emailStep
Wrapper
.
instance
().
validateEmail
(
null
);
expect
(
val
).
toBe
(
'
general.required
'
);
});
test
(
'
validateEmail test email undefined
'
,
()
=>
{
const
w
rapper
=
shallowWithIntl
(
const
intlW
rapper
=
shallowWithIntl
(
<
EmailStep
/>);
const
formikWrapper
=
w
rapper
.
dive
();
const
val
=
formik
Wrapper
.
instance
().
validateEmail
();
const
emailStepWrapper
=
intlW
rapper
.
dive
();
const
val
=
emailStep
Wrapper
.
instance
().
validateEmail
();
expect
(
val
).
toBe
(
'
general.required
'
);
});
test
(
'
validateEmailRemotelyWithCache calls validate.validateEmailRemotely
'
,
done
=>
{
const
w
rapper
=
shallowWithIntl
(
const
intlW
rapper
=
shallowWithIntl
(
<
EmailStep
/>);
const
instance
=
w
rapper
.
dive
().
instance
();
const
instance
=
intlW
rapper
.
dive
().
instance
();
instance
.
validateEmailRemotelyWithCache
(
'
some-email@some-domain.com
'
)
.
then
(
response
=>
{
...
...
@@ -209,10 +195,10 @@ describe('EmailStep test', () => {
});
test
(
'
validateEmailRemotelyWithCache, called twice with different data, makes two remote requests
'
,
done
=>
{
const
w
rapper
=
shallowWithIntl
(
const
intlW
rapper
=
shallowWithIntl
(
<
EmailStep
/>
);
const
instance
=
w
rapper
.
dive
().
instance
();
const
instance
=
intlW
rapper
.
dive
().
instance
();
instance
.
validateEmailRemotelyWithCache
(
'
some-email@some-domain.com
'
)
.
then
(
response
=>
{
...
...
@@ -233,10 +219,10 @@ describe('EmailStep test', () => {
});
test
(
'
validateEmailRemotelyWithCache, called twice with same data, only makes one remote request
'
,
done
=>
{
const
w
rapper
=
shallowWithIntl
(
const
intlW
rapper
=
shallowWithIntl
(
<
EmailStep
/>
);
const
instance
=
w
rapper
.
dive
().
instance
();
const
instance
=
intlW
rapper
.
dive
().
instance
();
instance
.
validateEmailRemotelyWithCache
(
'
some-email@some-domain.com
'
)
.
then
(
response
=>
{
...
...
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