diff options
Diffstat (limited to 'spec/javascripts/vue_mr_widget/components/states/mr_widget_merge_when_pipeline_succeeds_spec.js')
-rw-r--r-- | spec/javascripts/vue_mr_widget/components/states/mr_widget_merge_when_pipeline_succeeds_spec.js | 56 |
1 files changed, 37 insertions, 19 deletions
diff --git a/spec/javascripts/vue_mr_widget/components/states/mr_widget_merge_when_pipeline_succeeds_spec.js b/spec/javascripts/vue_mr_widget/components/states/mr_widget_merge_when_pipeline_succeeds_spec.js index d47815a5b5a..d46ad0acc9b 100644 --- a/spec/javascripts/vue_mr_widget/components/states/mr_widget_merge_when_pipeline_succeeds_spec.js +++ b/spec/javascripts/vue_mr_widget/components/states/mr_widget_merge_when_pipeline_succeeds_spec.js @@ -42,22 +42,27 @@ describe('MRWidgetMergeWhenPipelineSucceeds', () => { it('should return false when user id is not the same with who set the MWPS', () => { vm.mr.mergeUserId = 2; + expect(vm.canRemoveSourceBranch).toBeFalsy(); vm.mr.currentUserId = 2; + expect(vm.canRemoveSourceBranch).toBeTruthy(); vm.mr.currentUserId = 3; + expect(vm.canRemoveSourceBranch).toBeFalsy(); }); it('should return false when shouldRemoveSourceBranch set to false', () => { vm.mr.shouldRemoveSourceBranch = true; + expect(vm.canRemoveSourceBranch).toBeFalsy(); }); it('should return false if user is not able to remove the source branch', () => { vm.mr.canRemoveSourceBranch = false; + expect(vm.canRemoveSourceBranch).toBeFalsy(); }); }); @@ -65,15 +70,17 @@ describe('MRWidgetMergeWhenPipelineSucceeds', () => { describe('methods', () => { describe('cancelAutomaticMerge', () => { - it('should set flag and call service then tell main component to update the widget with data', (done) => { + it('should set flag and call service then tell main component to update the widget with data', done => { const mrObj = { is_new_mr_data: true, }; - spyOn(vm.service, 'cancelAutomaticMerge').and.returnValue(new Promise((resolve) => { - resolve({ - data: mrObj, - }); - })); + spyOn(vm.service, 'cancelAutomaticMerge').and.returnValue( + new Promise(resolve => { + resolve({ + data: mrObj, + }); + }), + ); vm.cancelAutomaticMerge(); setTimeout(() => { @@ -85,12 +92,14 @@ describe('MRWidgetMergeWhenPipelineSucceeds', () => { }); describe('removeSourceBranch', () => { - it('should set flag and call service then request main component to update the widget', (done) => { - spyOn(vm.service, 'merge').and.returnValue(Promise.resolve({ - data: { - status: 'merge_when_pipeline_succeeds', - }, - })); + it('should set flag and call service then request main component to update the widget', done => { + spyOn(vm.service, 'merge').and.returnValue( + Promise.resolve({ + data: { + status: 'merge_when_pipeline_succeeds', + }, + }), + ); vm.removeSourceBranch(); setTimeout(() => { @@ -113,13 +122,19 @@ describe('MRWidgetMergeWhenPipelineSucceeds', () => { expect(vm.$el.innerText).toContain('The changes will be merged into'); expect(vm.$el.innerText).toContain(targetBranch); expect(vm.$el.innerText).toContain('The source branch will not be removed'); - expect(vm.$el.querySelector('.js-cancel-auto-merge').innerText).toContain('Cancel automatic merge'); + expect(vm.$el.querySelector('.js-cancel-auto-merge').innerText).toContain( + 'Cancel automatic merge', + ); + expect(vm.$el.querySelector('.js-cancel-auto-merge').getAttribute('disabled')).toBeFalsy(); - expect(vm.$el.querySelector('.js-remove-source-branch').innerText).toContain('Remove source branch'); + expect(vm.$el.querySelector('.js-remove-source-branch').innerText).toContain( + 'Remove source branch', + ); + expect(vm.$el.querySelector('.js-remove-source-branch').getAttribute('disabled')).toBeFalsy(); }); - it('should disable cancel auto merge button when the action is in progress', (done) => { + it('should disable cancel auto merge button when the action is in progress', done => { vm.isCancellingAutoMerge = true; Vue.nextTick(() => { @@ -128,18 +143,19 @@ describe('MRWidgetMergeWhenPipelineSucceeds', () => { }); }); - it('should show source branch will be removed text when it source branch set to remove', (done) => { + it('should show source branch will be removed text when it source branch set to remove', done => { vm.mr.shouldRemoveSourceBranch = true; Vue.nextTick(() => { const normalizedText = vm.$el.innerText.replace(/\s+/g, ' '); + expect(normalizedText).toContain('The source branch will be removed'); expect(normalizedText).not.toContain('The source branch will not be removed'); done(); }); }); - it('should not show remove source branch button when user not able to remove source branch', (done) => { + it('should not show remove source branch button when user not able to remove source branch', done => { vm.mr.currentUserId = 4; Vue.nextTick(() => { @@ -148,11 +164,13 @@ describe('MRWidgetMergeWhenPipelineSucceeds', () => { }); }); - it('should disable remove source branch button when the action is in progress', (done) => { + it('should disable remove source branch button when the action is in progress', done => { vm.isRemovingSourceBranch = true; Vue.nextTick(() => { - expect(vm.$el.querySelector('.js-remove-source-branch').getAttribute('disabled')).toBeTruthy(); + expect( + vm.$el.querySelector('.js-remove-source-branch').getAttribute('disabled'), + ).toBeTruthy(); done(); }); }); |