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
d2a02869
Commit
d2a02869
authored
Mar 16, 2020
by
Dave Pisek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate vulnerabilities mutations specs to jest
This commit migrates the vulnerabilities mutations specs to jest.
parent
42e63196
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 deletions
+14
-13
ee/spec/frontend/security_dashboard/store/modules/vulnerabilities/mutations_spec.js
...dashboard/store/modules/vulnerabilities/mutations_spec.js
+14
-13
No files found.
ee/spec/
javascripts/security_dashboard/store
/vulnerabilities/mutations_spec.js
→
ee/spec/
frontend/security_dashboard/store/modules
/vulnerabilities/mutations_spec.js
View file @
d2a02869
...
...
@@ -3,6 +3,9 @@ import * as types from 'ee/security_dashboard/store/modules/vulnerabilities/muta
import
mutations
from
'
ee/security_dashboard/store/modules/vulnerabilities/mutations
'
;
import
{
DAYS
}
from
'
ee/security_dashboard/store/modules/vulnerabilities/constants
'
;
import
mockData
from
'
./data/mock_data_vulnerabilities
'
;
import
{
visitUrl
}
from
'
~/lib/utils/url_utility
'
;
jest
.
mock
(
'
~/lib/utils/url_utility
'
);
describe
(
'
vulnerabilities module mutations
'
,
()
=>
{
let
state
;
...
...
@@ -256,7 +259,7 @@ describe('vulnerabilities module mutations', () => {
describe
(
'
with irregular data
'
,
()
=>
{
const
vulnerability
=
mockData
[
0
];
it
(
'
should set isDismissed when the vulnerabilit
i
y is dismissed
'
,
()
=>
{
it
(
'
should set isDismissed when the vulnerability is dismissed
'
,
()
=>
{
const
payload
=
{
vulnerability
:
{
...
vulnerability
,
dismissal_feedback
:
'
I am dismissed
'
},
};
...
...
@@ -265,7 +268,7 @@ describe('vulnerabilities module mutations', () => {
expect
(
state
.
modal
.
vulnerability
.
isDismissed
).
toBe
(
true
);
});
it
(
'
should set hasIssue when the vulnerabilit
i
y has a related issue
'
,
()
=>
{
it
(
'
should set hasIssue when the vulnerability has a related issue
'
,
()
=>
{
const
payload
=
{
vulnerability
:
{
...
vulnerability
,
...
...
@@ -312,7 +315,6 @@ describe('vulnerabilities module mutations', () => {
describe
(
'
RECEIVE_CREATE_ISSUE_SUCCESS
'
,
()
=>
{
it
(
'
should fire the visitUrl function on the issue URL
'
,
()
=>
{
const
payload
=
{
issue_url
:
'
fakepath.html
'
};
const
visitUrl
=
spyOnDependency
(
mutations
,
'
visitUrl
'
);
mutations
[
types
.
RECEIVE_CREATE_ISSUE_SUCCESS
](
state
,
payload
);
expect
(
visitUrl
).
toHaveBeenCalledWith
(
payload
.
issue_url
);
...
...
@@ -350,7 +352,6 @@ describe('vulnerabilities module mutations', () => {
describe
(
'
RECEIVE_CREATE_MERGE_REQUEST_SUCCESS
'
,
()
=>
{
it
(
'
should fire the visitUrl function on the merge request URL
'
,
()
=>
{
const
payload
=
{
merge_request_path
:
'
fakepath.html
'
};
const
visitUrl
=
spyOnDependency
(
mutations
,
'
visitUrl
'
);
mutations
[
types
.
RECEIVE_CREATE_MERGE_REQUEST_SUCCESS
](
state
,
payload
);
expect
(
visitUrl
).
toHaveBeenCalledWith
(
payload
.
merge_request_path
);
...
...
@@ -454,7 +455,7 @@ describe('vulnerabilities module mutations', () => {
mutations
[
types
.
RECEIVE_DISMISS_SELECTED_VULNERABILITIES_ERROR
](
state
);
});
it
(
'
should set isDismissingVulnerabilties to false
'
,
()
=>
{
it
(
'
should set isDismissingVulnerabil
i
ties to false
'
,
()
=>
{
expect
(
state
.
isDismissingVulnerabilities
).
toBe
(
false
);
});
});
...
...
@@ -471,10 +472,10 @@ describe('vulnerabilities module mutations', () => {
});
it
(
'
should not add a duplicate id to the selected vulnerabilities
'
,
()
=>
{
expect
(
state
.
selectedVulnerabilities
).
to
HaveLength
(
1
);
expect
(
state
.
selectedVulnerabilities
).
to
StrictEqual
({
[
id
]:
true
}
);
mutations
[
types
.
SELECT_VULNERABILITY
](
state
,
id
);
expect
(
state
.
selectedVulnerabilities
).
to
HaveLength
(
1
);
expect
(
state
.
selectedVulnerabilities
).
to
StrictEqual
({
[
id
]:
true
}
);
});
});
...
...
@@ -496,7 +497,7 @@ describe('vulnerabilities module mutations', () => {
describe
(
'
SELECT_ALL_VULNERABILITIES
'
,
()
=>
{
beforeEach
(()
=>
{
state
.
vulnerabilities
=
[{
id
:
12
},
{
id
:
34
},
{
id
:
56
}];
state
.
selectedVulnerabilites
=
{};
state
.
selectedVulnerabilit
i
es
=
{};
});
it
(
'
should add all the vulnerabilities when none are selected
'
,
()
=>
{
...
...
@@ -506,7 +507,7 @@ describe('vulnerabilities module mutations', () => {
});
it
(
'
should add all the vulnerabilities when some are already selected
'
,
()
=>
{
state
.
selectedVulnerabilites
=
{
12
:
true
,
13
:
true
};
state
.
selectedVulnerabilit
i
es
=
{
12
:
true
,
13
:
true
};
mutations
[
types
.
SELECT_ALL_VULNERABILITIES
](
state
);
expect
(
Object
.
keys
(
state
.
selectedVulnerabilities
)).
toHaveLength
(
state
.
vulnerabilities
.
length
);
...
...
@@ -559,7 +560,7 @@ describe('vulnerabilities module mutations', () => {
expect
(
state
.
isDismissingVulnerability
).
toBe
(
false
);
});
it
(
'
should set isDis
s
missed on the modal vulnerability to be true
'
,
()
=>
{
it
(
'
should set isDismissed on the modal vulnerability to be true
'
,
()
=>
{
expect
(
state
.
modal
.
vulnerability
.
isDismissed
).
toBe
(
true
);
});
});
...
...
@@ -583,7 +584,7 @@ describe('vulnerabilities module mutations', () => {
mutations
[
types
.
SHOW_DISMISSAL_DELETE_BUTTONS
](
state
);
});
it
(
'
should set isShowingDeleteButtons
to
to true
'
,
()
=>
{
it
(
'
should set isShowingDeleteButtons to true
'
,
()
=>
{
expect
(
state
.
modal
.
isShowingDeleteButtons
).
toBe
(
true
);
});
});
...
...
@@ -633,7 +634,7 @@ describe('vulnerabilities module mutations', () => {
expect
(
state
.
isDismissingVulnerability
).
toBe
(
false
);
});
it
(
'
should set isDis
s
missed on the modal vulnerability to be true
'
,
()
=>
{
it
(
'
should set isDismissed on the modal vulnerability to be true
'
,
()
=>
{
expect
(
state
.
modal
.
vulnerability
.
isDismissed
).
toBe
(
true
);
});
});
...
...
@@ -685,7 +686,7 @@ describe('vulnerabilities module mutations', () => {
expect
(
state
.
isDismissingVulnerability
).
toBe
(
false
);
});
it
(
'
should set isDis
s
missed on the modal vulnerability to be false
'
,
()
=>
{
it
(
'
should set isDismissed on the modal vulnerability to be false
'
,
()
=>
{
expect
(
state
.
modal
.
vulnerability
.
isDismissed
).
toBe
(
false
);
});
});
...
...
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