diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-06-07 22:34:19 +0300 |
---|---|---|
committer | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-07-07 16:57:00 +0300 |
commit | 421e41c9ce3abdd843079c1eb022cad8974d36ff (patch) | |
tree | 495149c4fd99d811e31bae9e2d775954764a04fa /spec/javascripts/merge_request_spec.js | |
parent | fa82736cf4ba55c0f549f137afd2abe8383e33f8 (diff) |
Added specs
Diffstat (limited to 'spec/javascripts/merge_request_spec.js')
-rw-r--r-- | spec/javascripts/merge_request_spec.js | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/spec/javascripts/merge_request_spec.js b/spec/javascripts/merge_request_spec.js index f444bcaf847..3235df50456 100644 --- a/spec/javascripts/merge_request_spec.js +++ b/spec/javascripts/merge_request_spec.js @@ -2,10 +2,11 @@ /* global MergeRequest */ import '~/merge_request'; +import * as CloseReopenReportToggle from '~/close_reopen_report_toggle'; (function() { describe('MergeRequest', function() { - return describe('task lists', function() { + describe('task lists', function() { preloadFixtures('merge_requests/merge_request_with_task_list.html.raw'); beforeEach(function() { loadFixtures('merge_requests/merge_request_with_task_list.html.raw'); @@ -27,5 +28,42 @@ import '~/merge_request'; return $('.js-task-list-field').trigger('tasklist:changed'); }); }); + + describe('class constructor', () => { + it('calls .initCloseReopenReport', () => { + spyOn(MergeRequest, 'initCloseReopenReport'); + + new MergeRequest(); // eslint-disable-line no-new + + expect(MergeRequest.initCloseReopenReport).toHaveBeenCalled(); + }); + }); + + describe('initCloseReopenReport', () => { + it('inits a new CloseReopenReportToggle instance and calls .initDroplab', () => { + const container = jasmine.createSpyObj('container', ['querySelector']); + const closeReopenReportToggle = jasmine.createSpyObj('closeReopenReportToggle', ['initDroplab']); + const dropdownTrigger = {}; + const dropdownList = {}; + const button = {}; + + spyOn(document, 'querySelector').and.returnValue(container); + spyOn(CloseReopenReportToggle, 'default').and.returnValue(closeReopenReportToggle); + container.querySelector.and.returnValues(dropdownTrigger, dropdownList, button); + + MergeRequest.initCloseReopenReport(); + + expect(document.querySelector).toHaveBeenCalledWith('.js-issuable-close-dropdown'); + expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-toggle'); + expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-menu'); + expect(container.querySelector).toHaveBeenCalledWith('.js-issuable-close-button'); + expect(CloseReopenReportToggle.default).toHaveBeenCalledWith({ + dropdownTrigger, + dropdownList, + button, + }); + expect(closeReopenReportToggle.initDroplab).toHaveBeenCalled(); + }); + }); }); }).call(window); |