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
e85d245c
Commit
e85d245c
authored
Jan 28, 2021
by
Dave Pisek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change all specs to move away from mount-helper
* No more mount helper
parent
7567cda6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
50 deletions
+20
-50
ee/spec/frontend/security_dashboard/components/vulnerability_action_buttons_spec.js
...dashboard/components/vulnerability_action_buttons_spec.js
+20
-50
No files found.
ee/spec/frontend/security_dashboard/components/vulnerability_action_buttons_spec.js
View file @
e85d245c
import
Vue
from
'
vue
'
;
import
{
createWrapper
,
mount
}
from
'
@vue/test-utils
'
;
import
VulnerabilityActionButtons
from
'
ee/security_dashboard/components/vulnerability_action_buttons.vue
'
;
import
createStore
from
'
ee/security_dashboard/store
'
;
import
{
mountComponentWithStore
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
VULNERABILITY_MODAL_ID
}
from
'
ee/vue_shared/security_reports/components/constants
'
;
import
{
BV_SHOW_MODAL
}
from
'
~/lib/utils/constants
'
;
import
{
resetStore
}
from
'
../helpers
'
;
import
mockDataVulnerabilities
from
'
../store/modules/vulnerabilities/data/mock_data_vulnerabilities
'
;
describe
(
'
Security Dashboard Action Buttons
'
,
()
=>
{
const
Component
=
Vue
.
extend
(
VulnerabilityActionButtons
);
let
vm
;
let
store
;
let
props
;
let
wrapper
;
const
defaultProps
=
{
vulnerability
:
mockDataVulnerabilities
[
0
],
canCreateIssue
:
true
,
canDismissVulnerability
:
true
,
};
const
createComponent
=
({
propsData
,
...
options
})
=>
{
const
createComponent
=
({
...
options
})
=>
{
return
mount
(
VulnerabilityActionButtons
,
{
store
:
createStore
(),
propsData
:
{
...
defaultProps
,
...
propsData
,
},
...
options
,
store
,
});
};
...
...
@@ -38,8 +22,8 @@ describe('Security Dashboard Action Buttons', () => {
});
afterEach
(()
=>
{
// vm.$destroy();
resetStore
(
store
);
wrapper
.
destroy
();
});
describe
(
'
with a fresh vulnerability
'
,
()
=>
{
...
...
@@ -55,10 +39,6 @@ describe('Security Dashboard Action Buttons', () => {
jest
.
spyOn
(
wrapper
.
vm
.
$store
,
'
dispatch
'
).
mockReturnValue
(
Promise
.
resolve
());
});
afterEach
(()
=>
{
wrapper
.
destroy
();
});
it
(
'
should render three buttons in a button group
'
,
()
=>
{
expect
(
wrapper
.
findAll
(
'
.btn-group .btn
'
)).
toHaveLength
(
3
);
});
...
...
@@ -108,10 +88,6 @@ describe('Security Dashboard Action Buttons', () => {
describe
(
'
with Jira issues for vulnerabilities enabled
'
,
()
=>
{
beforeEach
(()
=>
{
props
=
{
vulnerability
:
mockDataVulnerabilities
[
8
],
canCreateIssue
:
true
,
};
wrapper
=
createComponent
({
propsData
:
{
vulnerability
:
mockDataVulnerabilities
[
8
],
...
...
@@ -156,49 +132,43 @@ describe('Security Dashboard Action Buttons', () => {
describe
(
'
with a vulnerbility that has an issue
'
,
()
=>
{
beforeEach
(()
=>
{
props
=
{
vulnerability
:
mockDataVulnerabilities
[
3
],
};
vm
=
mountComponentWithStore
(
Component
,
{
store
,
props
});
});
afterEach
(()
=>
{
vm
.
$destroy
();
wrapper
=
createComponent
({
propsData
:
{
vulnerability
:
mockDataVulnerabilities
[
3
],
},
});
});
it
(
'
should only render one button
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
All
(
'
.btn
'
)).
toHaveLength
(
1
);
expect
(
wrapper
.
find
All
(
'
.btn
'
)).
toHaveLength
(
1
);
});
it
(
'
should not render the create issue button
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-create-issue
'
)).
toBeNull
(
);
expect
(
wrapper
.
find
(
'
.js-create-issue
'
).
exists
()).
toBe
(
false
);
});
});
describe
(
'
with a vulnerability that has been dismissed
'
,
()
=>
{
beforeEach
(()
=>
{
props
=
{
vulnerability
:
mockDataVulnerabilities
[
2
],
canDismissVulnerability
:
true
,
isDismissed
:
true
,
};
vm
=
mountComponentWithStore
(
Component
,
{
store
,
props
});
});
afterEach
(()
=>
{
vm
.
$destroy
();
wrapper
=
createComponent
({
propsData
:
{
vulnerability
:
mockDataVulnerabilities
[
2
],
canDismissVulnerability
:
true
,
isDismissed
:
true
,
},
});
});
it
(
'
should render two buttons in a button group
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
All
(
'
.btn-group .btn
'
)).
toHaveLength
(
2
);
expect
(
wrapper
.
find
All
(
'
.btn-group .btn
'
)).
toHaveLength
(
2
);
});
it
(
'
should not render the dismiss vulnerability button
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-dismiss-vulnerability
'
)).
toBeNull
(
);
expect
(
wrapper
.
find
(
'
.js-dismiss-vulnerability
'
).
exists
()).
toBe
(
false
);
});
it
(
'
should render the undo dismiss button
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-undo-dismiss
'
)).
not
.
toBeNull
(
);
expect
(
wrapper
.
find
(
'
.js-undo-dismiss
'
).
exists
()).
toBe
(
true
);
});
});
});
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