summaryrefslogtreecommitdiff
path: root/spec/frontend/admin/analytics/devops_score/components/devops_score_callout_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/admin/analytics/devops_score/components/devops_score_callout_spec.js')
-rw-r--r--spec/frontend/admin/analytics/devops_score/components/devops_score_callout_spec.js67
1 files changed, 67 insertions, 0 deletions
diff --git a/spec/frontend/admin/analytics/devops_score/components/devops_score_callout_spec.js b/spec/frontend/admin/analytics/devops_score/components/devops_score_callout_spec.js
new file mode 100644
index 00000000000..ee14e002f1b
--- /dev/null
+++ b/spec/frontend/admin/analytics/devops_score/components/devops_score_callout_spec.js
@@ -0,0 +1,67 @@
+import { GlBanner } from '@gitlab/ui';
+import { shallowMount } from '@vue/test-utils';
+import DevopsScoreCallout from '~/analytics/devops_report/components/devops_score_callout.vue';
+import { INTRO_COOKIE_KEY } from '~/analytics/devops_report/constants';
+import * as utils from '~/lib/utils/common_utils';
+import { devopsReportDocsPath, devopsScoreIntroImagePath } from '../mock_data';
+
+describe('DevopsScoreCallout', () => {
+ let wrapper;
+
+ const createComponent = () => {
+ wrapper = shallowMount(DevopsScoreCallout, {
+ provide: {
+ devopsReportDocsPath,
+ devopsScoreIntroImagePath,
+ },
+ });
+ };
+
+ const findBanner = () => wrapper.findComponent(GlBanner);
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ describe('with no cookie set', () => {
+ beforeEach(() => {
+ utils.setCookie = jest.fn();
+
+ createComponent();
+ });
+
+ it('displays the banner', () => {
+ expect(findBanner().exists()).toBe(true);
+ });
+
+ it('does not call setCookie', () => {
+ expect(utils.setCookie).not.toHaveBeenCalled();
+ });
+
+ describe('when the close button is clicked', () => {
+ beforeEach(() => {
+ findBanner().vm.$emit('close');
+ });
+
+ it('sets the dismissed cookie', () => {
+ expect(utils.setCookie).toHaveBeenCalledWith(INTRO_COOKIE_KEY, 'true');
+ });
+
+ it('hides the banner', () => {
+ expect(findBanner().exists()).toBe(false);
+ });
+ });
+ });
+
+ describe('with the dismissed cookie set', () => {
+ beforeEach(() => {
+ jest.spyOn(utils, 'getCookie').mockReturnValue('true');
+
+ createComponent();
+ });
+
+ it('hides the banner', () => {
+ expect(findBanner().exists()).toBe(false);
+ });
+ });
+});