diff options
Diffstat (limited to 'spec/frontend/blob/suggest_gitlab_ci_yml/components/popover_spec.js')
-rw-r--r-- | spec/frontend/blob/suggest_gitlab_ci_yml/components/popover_spec.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/frontend/blob/suggest_gitlab_ci_yml/components/popover_spec.js b/spec/frontend/blob/suggest_gitlab_ci_yml/components/popover_spec.js new file mode 100644 index 00000000000..0170ef927cf --- /dev/null +++ b/spec/frontend/blob/suggest_gitlab_ci_yml/components/popover_spec.js @@ -0,0 +1,46 @@ +import { shallowMount } from '@vue/test-utils'; +import Popover from '~/blob/suggest_gitlab_ci_yml/components/popover.vue'; +import Cookies from 'js-cookie'; + +const popoverTarget = 'gitlab-ci-yml-selector'; +const dismissKey = 'suggest_gitlab_ci_yml_99'; + +describe('Suggest gitlab-ci.yml Popover', () => { + let wrapper; + + function createWrapper() { + wrapper = shallowMount(Popover, { + propsData: { + target: popoverTarget, + cssClass: 'js-class', + dismissKey, + }, + }); + } + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + describe('when no dismiss cookie is set', () => { + beforeEach(() => { + createWrapper(); + }); + + it('sets popoverDismissed to false', () => { + expect(wrapper.vm.popoverDismissed).toEqual(false); + }); + }); + + describe('when the dismiss cookie is set', () => { + beforeEach(() => { + Cookies.set(dismissKey, true); + createWrapper(); + }); + + it('sets popoverDismissed to true', () => { + expect(wrapper.vm.popoverDismissed).toEqual(true); + }); + }); +}); |