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
0d95ad53
Unverified
Commit
0d95ad53
authored
Nov 04, 2019
by
Benjamin Wheeler
Committed by
GitHub
Nov 04, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3483 from benjiwheeler/join-flow-usernames-can-have-underscores
revise join flow username validation tests
parents
e367950a
24fd824e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
6 deletions
+34
-6
test/unit/lib/validate.test.js
test/unit/lib/validate.test.js
+34
-6
No files found.
test/unit/lib/validate.test.js
View file @
0d95ad53
const
validate
=
require
(
'
../../../src/lib/validate
'
);
describe
(
'
unit test lib/validate.js
'
,
()
=>
{
test
(
'
validate username locally
'
,
()
=>
{
test
(
'
validate username exists locally
'
,
()
=>
{
let
response
;
expect
(
typeof
validate
.
validateUsernameLocally
).
toBe
(
'
function
'
);
response
=
validate
.
validateUsernameLocally
(
'
abc
'
);
expect
(
response
).
toEqual
({
valid
:
true
});
response
=
validate
.
validateUsernameLocally
(
'
abcdefghijklmnopqrst
'
);
expect
(
response
).
toEqual
({
valid
:
true
});
response
=
validate
.
validateUsernameLocally
(
'
abc-def-ghi
'
);
expect
(
response
).
toEqual
({
valid
:
true
});
response
=
validate
.
validateUsernameLocally
(
''
);
expect
(
response
).
toEqual
({
valid
:
false
,
errMsgId
:
'
general.required
'
});
});
test
(
'
validate username length locally
'
,
()
=>
{
let
response
;
response
=
validate
.
validateUsernameLocally
(
'
abcdefghijklmnopqrst
'
);
expect
(
response
).
toEqual
({
valid
:
true
});
response
=
validate
.
validateUsernameLocally
(
'
ab
'
);
expect
(
response
).
toEqual
({
valid
:
false
,
errMsgId
:
'
registration.validationUsernameMinLength
'
});
response
=
validate
.
validateUsernameLocally
(
'
abcdefghijklmnopqrstu
'
);
expect
(
response
).
toEqual
({
valid
:
false
,
errMsgId
:
'
registration.validationUsernameMaxLength
'
});
response
=
validate
.
validateUsernameLocally
(
'
abc def
'
);
});
test
(
'
validate username hyphens allowed
'
,
()
=>
{
const
response
=
validate
.
validateUsernameLocally
(
'
-abc-def-ghi-
'
);
expect
(
response
).
toEqual
({
valid
:
true
});
});
test
(
'
validate username underscores allowed
'
,
()
=>
{
const
response
=
validate
.
validateUsernameLocally
(
'
_abc_def_ghi_
'
);
expect
(
response
).
toEqual
({
valid
:
true
});
});
test
(
'
validate username spaces not allowed
'
,
()
=>
{
const
response
=
validate
.
validateUsernameLocally
(
'
abc def
'
);
expect
(
response
).
toEqual
({
valid
:
false
,
errMsgId
:
'
registration.validationUsernameRegexp
'
});
});
test
(
'
validate username special chars not allowed
'
,
()
=>
{
let
response
;
response
=
validate
.
validateUsernameLocally
(
'
abc!def
'
);
expect
(
response
).
toEqual
({
valid
:
false
,
errMsgId
:
'
registration.validationUsernameRegexp
'
});
response
=
validate
.
validateUsernameLocally
(
'
amiascratcher?
'
);
expect
(
response
).
toEqual
({
valid
:
false
,
errMsgId
:
'
registration.validationUsernameRegexp
'
});
});
test
(
'
validate username unicode chars not allowed
'
,
()
=>
{
let
response
;
response
=
validate
.
validateUsernameLocally
(
'
abc😄def
'
);
expect
(
response
).
toEqual
({
valid
:
false
,
errMsgId
:
'
registration.validationUsernameRegexp
'
});
response
=
validate
.
validateUsernameLocally
(
'
🦆🦆🦆😺😺😺
'
);
expect
(
response
).
toEqual
({
valid
:
false
,
errMsgId
:
'
registration.validationUsernameRegexp
'
});
});
test
(
'
validate password
'
,
()
=>
{
...
...
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