summaryrefslogtreecommitdiff
path: root/spec/frontend/vue_shared/components/security_reports/help_icon_spec.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-12-17 11:59:07 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-12-17 11:59:07 +0000
commit8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch)
tree544930fb309b30317ae9797a9683768705d664c4 /spec/frontend/vue_shared/components/security_reports/help_icon_spec.js
parent4b1de649d0168371549608993deac953eb692019 (diff)
downloadgitlab-ce-8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca.tar.gz
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/frontend/vue_shared/components/security_reports/help_icon_spec.js')
-rw-r--r--spec/frontend/vue_shared/components/security_reports/help_icon_spec.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/spec/frontend/vue_shared/components/security_reports/help_icon_spec.js b/spec/frontend/vue_shared/components/security_reports/help_icon_spec.js
new file mode 100644
index 00000000000..60203493cbd
--- /dev/null
+++ b/spec/frontend/vue_shared/components/security_reports/help_icon_spec.js
@@ -0,0 +1,68 @@
+import { GlLink, GlPopover } from '@gitlab/ui';
+import { shallowMount } from '@vue/test-utils';
+import HelpIcon from '~/vue_shared/security_reports/components/help_icon.vue';
+
+const helpPath = '/docs';
+const discoverProjectSecurityPath = '/discoverProjectSecurityPath';
+
+describe('HelpIcon component', () => {
+ let wrapper;
+
+ const createWrapper = props => {
+ wrapper = shallowMount(HelpIcon, {
+ propsData: {
+ helpPath,
+ ...props,
+ },
+ });
+ };
+
+ const findLink = () => wrapper.find(GlLink);
+ const findPopover = () => wrapper.find(GlPopover);
+ const findPopoverTarget = () => wrapper.find({ ref: 'discoverProjectSecurity' });
+
+ afterEach(() => {
+ wrapper.destroy();
+ wrapper = null;
+ });
+
+ describe('given a help path only', () => {
+ beforeEach(() => {
+ createWrapper();
+ });
+
+ it('does not render a popover', () => {
+ expect(findPopover().exists()).toBe(false);
+ });
+
+ it('renders a help link', () => {
+ expect(findLink().attributes()).toMatchObject({
+ href: helpPath,
+ target: '_blank',
+ });
+ });
+ });
+
+ describe('given a help path and discover project security path', () => {
+ beforeEach(() => {
+ createWrapper({ discoverProjectSecurityPath });
+ });
+
+ it('renders a popover', () => {
+ const popover = findPopover();
+ expect(popover.props('target')()).toBe(findPopoverTarget().element);
+ expect(popover.attributes()).toMatchObject({
+ title: HelpIcon.i18n.upgradeToManageVulnerabilities,
+ triggers: 'click blur',
+ });
+ expect(popover.text()).toContain(HelpIcon.i18n.upgradeToInteract);
+ });
+
+ it('renders a link to the discover path', () => {
+ expect(findLink().attributes()).toMatchObject({
+ href: discoverProjectSecurityPath,
+ target: '_blank',
+ });
+ });
+ });
+});