diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-09 18:07:59 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-09 18:07:59 +0000 |
commit | 7ebcead8cfd2edb810dd0cbda816b6cfbd170fe3 (patch) | |
tree | 11880c4059c89149cf997e9b958fb6d32c7dbdad /spec/frontend/blob | |
parent | f1a40d0db939dfe8ff95d385e652ff72566be765 (diff) | |
download | gitlab-ce-7ebcead8cfd2edb810dd0cbda816b6cfbd170fe3.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/blob')
-rw-r--r-- | spec/frontend/blob/suggest_gitlab_ci_yml/components/popover_spec.js | 34 |
1 files changed, 28 insertions, 6 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 index 0170ef927cf..2c7891e4b1a 100644 --- a/spec/frontend/blob/suggest_gitlab_ci_yml/components/popover_spec.js +++ b/spec/frontend/blob/suggest_gitlab_ci_yml/components/popover_spec.js @@ -1,18 +1,25 @@ import { shallowMount } from '@vue/test-utils'; import Popover from '~/blob/suggest_gitlab_ci_yml/components/popover.vue'; import Cookies from 'js-cookie'; +import * as utils from '~/lib/utils/common_utils'; -const popoverTarget = 'gitlab-ci-yml-selector'; +jest.mock('~/lib/utils/common_utils', () => ({ + ...jest.requireActual('~/lib/utils/common_utils'), + scrollToElement: jest.fn(), +})); + +const target = 'gitlab-ci-yml-selector'; const dismissKey = 'suggest_gitlab_ci_yml_99'; +const defaultTrackLabel = 'suggest_gitlab_ci_yml'; describe('Suggest gitlab-ci.yml Popover', () => { let wrapper; - function createWrapper() { + function createWrapper(trackLabel) { wrapper = shallowMount(Popover, { propsData: { - target: popoverTarget, - cssClass: 'js-class', + target, + trackLabel, dismissKey, }, }); @@ -25,7 +32,7 @@ describe('Suggest gitlab-ci.yml Popover', () => { describe('when no dismiss cookie is set', () => { beforeEach(() => { - createWrapper(); + createWrapper(defaultTrackLabel); }); it('sets popoverDismissed to false', () => { @@ -36,11 +43,26 @@ describe('Suggest gitlab-ci.yml Popover', () => { describe('when the dismiss cookie is set', () => { beforeEach(() => { Cookies.set(dismissKey, true); - createWrapper(); + createWrapper(defaultTrackLabel); }); it('sets popoverDismissed to true', () => { expect(wrapper.vm.popoverDismissed).toEqual(true); }); + + beforeEach(() => { + Cookies.remove(dismissKey); + }); + }); + + describe('when the popover is mounted with the trackLabel of the Confirm button popover at the bottom of the page', () => { + it('calls scrollToElement so that the Confirm button and popover will be in sight', () => { + const scrollToElementSpy = jest.spyOn(utils, 'scrollToElement'); + const commitTrackLabel = 'suggest_commit_first_project_gitlab_ci_yml'; + + createWrapper(commitTrackLabel); + + expect(scrollToElementSpy).toHaveBeenCalled(); + }); }); }); |