diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-20 18:07:34 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-20 18:07:34 +0300 |
commit | 8b61452138ecc511b52cd49be4ee6b8a80390c50 (patch) | |
tree | 122b817432c2a0f0e23767bd95791a89b20540c0 /spec/javascripts/project_select_combo_button_spec.js | |
parent | f864f8a7aafa45b0e4c04e4312f89da4b1227c0f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/javascripts/project_select_combo_button_spec.js')
-rw-r--r-- | spec/javascripts/project_select_combo_button_spec.js | 124 |
1 files changed, 0 insertions, 124 deletions
diff --git a/spec/javascripts/project_select_combo_button_spec.js b/spec/javascripts/project_select_combo_button_spec.js deleted file mode 100644 index dc85292c23e..00000000000 --- a/spec/javascripts/project_select_combo_button_spec.js +++ /dev/null @@ -1,124 +0,0 @@ -import $ from 'jquery'; -import ProjectSelectComboButton from '~/project_select_combo_button'; - -const fixturePath = 'static/project_select_combo_button.html'; - -describe('Project Select Combo Button', function() { - preloadFixtures(fixturePath); - - beforeEach(function() { - this.defaults = { - label: 'Select project to create issue', - groupId: 12345, - projectMeta: { - name: 'My Cool Project', - url: 'http://mycoolproject.com', - }, - newProjectMeta: { - name: 'My Other Cool Project', - url: 'http://myothercoolproject.com', - }, - localStorageKey: 'group-12345-new-issue-recent-project', - relativePath: 'issues/new', - }; - - loadFixtures(fixturePath); - - this.newItemBtn = document.querySelector('.new-project-item-link'); - this.projectSelectInput = document.querySelector('.project-item-select'); - }); - - describe('on page load when localStorage is empty', function() { - beforeEach(function() { - this.comboButton = new ProjectSelectComboButton(this.projectSelectInput); - }); - - it('newItemBtn href is null', function() { - expect(this.newItemBtn.getAttribute('href')).toBe(''); - }); - - it('newItemBtn text is the plain default label', function() { - expect(this.newItemBtn.textContent).toBe(this.defaults.label); - }); - }); - - describe('on page load when localStorage is filled', function() { - beforeEach(function() { - window.localStorage.setItem( - this.defaults.localStorageKey, - JSON.stringify(this.defaults.projectMeta), - ); - this.comboButton = new ProjectSelectComboButton(this.projectSelectInput); - }); - - it('newItemBtn href is correctly set', function() { - expect(this.newItemBtn.getAttribute('href')).toBe(this.defaults.projectMeta.url); - }); - - it('newItemBtn text is the cached label', function() { - expect(this.newItemBtn.textContent).toBe(`New issue in ${this.defaults.projectMeta.name}`); - }); - - afterEach(function() { - window.localStorage.clear(); - }); - }); - - describe('after selecting a new project', function() { - beforeEach(function() { - this.comboButton = new ProjectSelectComboButton(this.projectSelectInput); - - // mock the effect of selecting an item from the projects dropdown (select2) - $('.project-item-select') - .val(JSON.stringify(this.defaults.newProjectMeta)) - .trigger('change'); - }); - - it('newItemBtn href is correctly set', function() { - expect(this.newItemBtn.getAttribute('href')).toBe('http://myothercoolproject.com/issues/new'); - }); - - it('newItemBtn text is the selected project label', function() { - expect(this.newItemBtn.textContent).toBe(`New issue in ${this.defaults.newProjectMeta.name}`); - }); - - afterEach(function() { - window.localStorage.clear(); - }); - }); - - describe('deriveTextVariants', function() { - beforeEach(function() { - this.mockExecutionContext = { - resourceType: '', - resourceLabel: '', - }; - - this.comboButton = new ProjectSelectComboButton(this.projectSelectInput); - - this.method = this.comboButton.deriveTextVariants.bind(this.mockExecutionContext); - }); - - it('correctly derives test variants for merge requests', function() { - this.mockExecutionContext.resourceType = 'merge_requests'; - this.mockExecutionContext.resourceLabel = 'New merge request'; - - const returnedVariants = this.method(); - - expect(returnedVariants.localStorageItemType).toBe('new-merge-request'); - expect(returnedVariants.defaultTextPrefix).toBe('New merge request'); - expect(returnedVariants.presetTextSuffix).toBe('merge request'); - }); - - it('correctly derives text variants for issues', function() { - this.mockExecutionContext.resourceType = 'issues'; - this.mockExecutionContext.resourceLabel = 'New issue'; - - const returnedVariants = this.method(); - - expect(returnedVariants.localStorageItemType).toBe('new-issue'); - expect(returnedVariants.defaultTextPrefix).toBe('New issue'); - expect(returnedVariants.presetTextSuffix).toBe('issue'); - }); - }); -}); |