Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a65ff14a
Commit
a65ff14a
authored
Aug 17, 2020
by
peterhegman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to mocking `ipaddr.isValid`
parent
c0925e88
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
ee/spec/frontend/groups/settings/access_restriction_field/validate_ip_address_spec.js
...ings/access_restriction_field/validate_ip_address_spec.js
+12
-6
No files found.
ee/spec/frontend/groups/settings/access_restriction_field/validate_ip_address_spec.js
View file @
a65ff14a
import
*
as
validateIpAddress
from
'
ee/validators/ip_addres
s
'
;
import
ipaddr
from
'
ipaddr.j
s
'
;
import
validateRestrictedIpAddress
from
'
ee/groups/settings/access_restriction_field/validate_ip_address
'
;
describe
(
'
validateRestrictedIpAddress
'
,
()
=>
{
describe
(
'
when
`validateIpAddress` returns false
'
,
()
=>
{
describe
(
'
when
IP address is not valid
'
,
()
=>
{
it
(
'
returns an error message
'
,
()
=>
{
validateIpAddress
.
default
=
jest
.
fn
(()
=>
false
);
ipaddr
.
isValid
=
jest
.
fn
(()
=>
false
);
expect
(
validateRestrictedIpAddress
(
'
foo bar
'
)).
toBe
(
`foo bar is an invalid IP address range`
);
const
result
=
validateRestrictedIpAddress
(
'
foo bar
'
);
expect
(
ipaddr
.
isValid
).
toHaveBeenCalledWith
(
'
foo bar
'
);
expect
(
result
).
toBe
(
`foo bar is an invalid IP address range`
);
});
});
describe
(
'
when IP address is valid
'
,
()
=>
{
it
(
'
returns an empty string
'
,
()
=>
{
validateIpAddress
.
default
=
jest
.
fn
(()
=>
true
);
ipaddr
.
isValid
=
jest
.
fn
(()
=>
true
);
const
result
=
validateRestrictedIpAddress
(
'
192.168.0.0
'
);
expect
(
validateRestrictedIpAddress
(
'
192.168.0.0/24
'
)).
toBe
(
''
);
expect
(
ipaddr
.
isValid
).
toHaveBeenCalledWith
(
'
192.168.0.0
'
);
expect
(
result
).
toBe
(
''
);
});
});
});
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