diff options
Diffstat (limited to 'spec/javascripts/issuable_spec.js')
-rw-r--r-- | spec/javascripts/issuable_spec.js | 102 |
1 files changed, 33 insertions, 69 deletions
diff --git a/spec/javascripts/issuable_spec.js b/spec/javascripts/issuable_spec.js index 45f55395d3a..ceee08d47c5 100644 --- a/spec/javascripts/issuable_spec.js +++ b/spec/javascripts/issuable_spec.js @@ -1,80 +1,44 @@ -/* global IssuableIndex */ - -import '~/lib/utils/url_utility'; -import '~/issuable_index'; - -(() => { - const BASE_URL = '/user/project/issues?scope=all&state=closed'; - const DEFAULT_PARAMS = '&utf8=%E2%9C%93'; - - function updateForm(formValues, form) { - $.each(formValues, (id, value) => { - $(`#${id}`, form).val(value); - }); - } - - function resetForm(form) { - $('input[name!="utf8"]', form).each((index, input) => { - input.setAttribute('value', ''); +import IssuableIndex from '~/issuable_index'; + +describe('Issuable', () => { + let Issuable; + describe('initBulkUpdate', () => { + it('should not set bulkUpdateSidebar', () => { + Issuable = new IssuableIndex('issue_'); + expect(Issuable.bulkUpdateSidebar).not.toBeDefined(); }); - } - describe('Issuable', () => { - preloadFixtures('static/issuable_filter.html.raw'); + it('should set bulkUpdateSidebar', () => { + const element = document.createElement('div'); + element.classList.add('issues-bulk-update'); + document.body.appendChild(element); - beforeEach(() => { - loadFixtures('static/issuable_filter.html.raw'); - IssuableIndex.init(); - }); - - it('should be defined', () => { - expect(window.IssuableIndex).toBeDefined(); + Issuable = new IssuableIndex('issue_'); + expect(Issuable.bulkUpdateSidebar).toBeDefined(); }); + }); - describe('filtering', () => { - let $filtersForm; - - beforeEach(() => { - $filtersForm = $('.js-filter-form'); - loadFixtures('static/issuable_filter.html.raw'); - resetForm($filtersForm); - }); - - it('should contain only the default parameters', () => { - spyOn(gl.utils, 'visitUrl'); - - IssuableIndex.filterResults($filtersForm); - - expect(gl.utils.visitUrl).toHaveBeenCalledWith(BASE_URL + DEFAULT_PARAMS); - }); - - it('should filter for the phrase "broken"', () => { - spyOn(gl.utils, 'visitUrl'); - - updateForm({ search: 'broken' }, $filtersForm); - IssuableIndex.filterResults($filtersForm); - const params = `${DEFAULT_PARAMS}&search=broken`; - - expect(gl.utils.visitUrl).toHaveBeenCalledWith(BASE_URL + params); - }); - - it('should keep query parameters after modifying filter', () => { - spyOn(gl.utils, 'visitUrl'); + describe('resetIncomingEmailToken', () => { + beforeEach(() => { + const element = document.createElement('a'); + element.classList.add('incoming-email-token-reset'); + element.setAttribute('href', 'foo'); + document.body.appendChild(element); - // initial filter - updateForm({ milestone_title: 'v1.0' }, $filtersForm); + const input = document.createElement('input'); + input.setAttribute('id', 'issue_email'); + document.body.appendChild(input); - IssuableIndex.filterResults($filtersForm); - let params = `${DEFAULT_PARAMS}&milestone_title=v1.0`; - expect(gl.utils.visitUrl).toHaveBeenCalledWith(BASE_URL + params); + Issuable = new IssuableIndex('issue_'); + }); - // update filter - updateForm({ label_name: 'Frontend' }, $filtersForm); + it('should send request to reset email token', () => { + spyOn(jQuery, 'ajax').and.callThrough(); + document.querySelector('.incoming-email-token-reset').click(); - IssuableIndex.filterResults($filtersForm); - params = `${DEFAULT_PARAMS}&milestone_title=v1.0&label_name=Frontend`; - expect(gl.utils.visitUrl).toHaveBeenCalledWith(BASE_URL + params); - }); + expect(jQuery.ajax).toHaveBeenCalled(); + expect(jQuery.ajax.calls.argsFor(0)[0].url).toEqual('foo'); }); }); -})(); +}); + |