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