Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pro-blocks
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
pro-blocks
Commits
eece603c
Commit
eece603c
authored
Oct 18, 2018
by
Ioannis Cherouvim
Committed by
陈帅
Oct 18, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tested fixedZero and isUrl (#2600)
parent
93d77ec6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
src/utils/utils.test.js
src/utils/utils.test.js
+64
-0
No files found.
src/utils/utils.test.js
0 → 100644
View file @
eece603c
import
{
fixedZero
,
isUrl
}
from
'
./utils
'
;
describe
(
'
fixedZero tests
'
,
()
=>
{
it
(
'
should not pad large numbers
'
,
()
=>
{
expect
(
fixedZero
(
10
)).
toEqual
(
10
);
expect
(
fixedZero
(
11
)).
toEqual
(
11
);
expect
(
fixedZero
(
15
)).
toEqual
(
15
);
expect
(
fixedZero
(
20
)).
toEqual
(
20
);
expect
(
fixedZero
(
100
)).
toEqual
(
100
);
expect
(
fixedZero
(
1000
)).
toEqual
(
1000
);
});
it
(
'
should pad single digit numbers and return them as string
'
,
()
=>
{
expect
(
fixedZero
(
0
)).
toEqual
(
'
00
'
);
expect
(
fixedZero
(
1
)).
toEqual
(
'
01
'
);
expect
(
fixedZero
(
2
)).
toEqual
(
'
02
'
);
expect
(
fixedZero
(
3
)).
toEqual
(
'
03
'
);
expect
(
fixedZero
(
4
)).
toEqual
(
'
04
'
);
expect
(
fixedZero
(
5
)).
toEqual
(
'
05
'
);
expect
(
fixedZero
(
6
)).
toEqual
(
'
06
'
);
expect
(
fixedZero
(
7
)).
toEqual
(
'
07
'
);
expect
(
fixedZero
(
8
)).
toEqual
(
'
08
'
);
expect
(
fixedZero
(
9
)).
toEqual
(
'
09
'
);
});
});
describe
(
'
isUrl tests
'
,
()
=>
{
it
(
'
should return false for invalid and corner case inputs
'
,
()
=>
{
expect
(
isUrl
([])).
toBeFalsy
();
expect
(
isUrl
({})).
toBeFalsy
();
expect
(
isUrl
(
false
)).
toBeFalsy
();
expect
(
isUrl
(
true
)).
toBeFalsy
();
expect
(
isUrl
(
NaN
)).
toBeFalsy
();
expect
(
isUrl
(
null
)).
toBeFalsy
();
expect
(
isUrl
(
undefined
)).
toBeFalsy
();
expect
(
isUrl
()).
toBeFalsy
();
expect
(
isUrl
(
''
)).
toBeFalsy
();
});
it
(
'
should return false for invalid URLs
'
,
()
=>
{
expect
(
isUrl
(
'
foo
'
)).
toBeFalsy
();
expect
(
isUrl
(
'
bar
'
)).
toBeFalsy
();
expect
(
isUrl
(
'
bar/test
'
)).
toBeFalsy
();
expect
(
isUrl
(
'
http:/example.com/
'
)).
toBeFalsy
();
expect
(
isUrl
(
'
ttp://example.com/
'
)).
toBeFalsy
();
});
it
(
'
should return true for valid URLs
'
,
()
=>
{
expect
(
isUrl
(
'
http://example.com/
'
)).
toBeTruthy
();
expect
(
isUrl
(
'
https://example.com/
'
)).
toBeTruthy
();
expect
(
isUrl
(
'
http://example.com/test/123
'
)).
toBeTruthy
();
expect
(
isUrl
(
'
https://example.com/test/123
'
)).
toBeTruthy
();
expect
(
isUrl
(
'
http://example.com/test/123?foo=bar
'
)).
toBeTruthy
();
expect
(
isUrl
(
'
https://example.com/test/123?foo=bar
'
)).
toBeTruthy
();
expect
(
isUrl
(
'
http://www.example.com/
'
)).
toBeTruthy
();
expect
(
isUrl
(
'
https://www.example.com/
'
)).
toBeTruthy
();
expect
(
isUrl
(
'
http://www.example.com/test/123
'
)).
toBeTruthy
();
expect
(
isUrl
(
'
https://www.example.com/test/123
'
)).
toBeTruthy
();
expect
(
isUrl
(
'
http://www.example.com/test/123?foo=bar
'
)).
toBeTruthy
();
expect
(
isUrl
(
'
https://www.example.com/test/123?foo=bar
'
)).
toBeTruthy
();
});
});
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