diff options
Diffstat (limited to 'spec/frontend/blob/pipeline_tour_success_modal_spec.js')
-rw-r--r-- | spec/frontend/blob/pipeline_tour_success_modal_spec.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/frontend/blob/pipeline_tour_success_modal_spec.js b/spec/frontend/blob/pipeline_tour_success_modal_spec.js new file mode 100644 index 00000000000..613a7ce8303 --- /dev/null +++ b/spec/frontend/blob/pipeline_tour_success_modal_spec.js @@ -0,0 +1,51 @@ +import pipelineTourSuccess from '~/blob/pipeline_tour_success_modal.vue'; +import { shallowMount } from '@vue/test-utils'; +import Cookies from 'js-cookie'; +import { GlSprintf, GlModal } from '@gitlab/ui'; +import { mockTracking, unmockTracking } from 'helpers/tracking_helper'; +import modalProps from './pipeline_tour_success_mock_data'; + +describe('PipelineTourSuccessModal', () => { + let wrapper; + let cookieSpy; + let trackingSpy; + + beforeEach(() => { + document.body.dataset.page = 'projects:blob:show'; + + trackingSpy = mockTracking('_category_', undefined, jest.spyOn); + wrapper = shallowMount(pipelineTourSuccess, { + propsData: modalProps, + }); + + cookieSpy = jest.spyOn(Cookies, 'remove'); + }); + + afterEach(() => { + wrapper.destroy(); + unmockTracking(); + }); + + it('has expected structure', () => { + const modal = wrapper.find(GlModal); + const sprintf = modal.find(GlSprintf); + + expect(modal.attributes('title')).toContain("That's it, well done!"); + expect(sprintf.exists()).toBe(true); + }); + + it('calls to remove cookie', () => { + wrapper.vm.disableModalFromRenderingAgain(); + + expect(cookieSpy).toHaveBeenCalledWith(modalProps.commitCookie); + }); + + describe('tracking', () => { + it('send event for basic view of popover', () => { + expect(trackingSpy).toHaveBeenCalledWith(undefined, undefined, { + label: 'congratulate_first_pipeline', + property: modalProps.humanAccess, + }); + }); + }); +}); |