diff options
Diffstat (limited to 'spec/frontend/vue_mr_widget/components/states/mr_widget_missing_branch_spec.js')
-rw-r--r-- | spec/frontend/vue_mr_widget/components/states/mr_widget_missing_branch_spec.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/frontend/vue_mr_widget/components/states/mr_widget_missing_branch_spec.js b/spec/frontend/vue_mr_widget/components/states/mr_widget_missing_branch_spec.js new file mode 100644 index 00000000000..3f03ebdb047 --- /dev/null +++ b/spec/frontend/vue_mr_widget/components/states/mr_widget_missing_branch_spec.js @@ -0,0 +1,40 @@ +import Vue from 'vue'; +import mountComponent from 'helpers/vue_mount_component_helper'; +import missingBranchComponent from '~/vue_merge_request_widget/components/states/mr_widget_missing_branch.vue'; + +describe('MRWidgetMissingBranch', () => { + let vm; + + beforeEach(() => { + const Component = Vue.extend(missingBranchComponent); + vm = mountComponent(Component, { mr: { sourceBranchRemoved: true } }); + }); + + afterEach(() => { + vm.$destroy(); + }); + + describe('computed', () => { + describe('missingBranchName', () => { + it('should return proper branch name', () => { + expect(vm.missingBranchName).toEqual('source'); + + vm.mr.sourceBranchRemoved = false; + + expect(vm.missingBranchName).toEqual('target'); + }); + }); + }); + + describe('template', () => { + it('should have correct elements', () => { + const el = vm.$el; + const content = el.textContent.replace(/\n(\s)+/g, ' ').trim(); + + expect(el.classList.contains('mr-widget-body')).toBeTruthy(); + expect(el.querySelector('button').getAttribute('disabled')).toBeTruthy(); + expect(content.replace(/\s\s+/g, ' ')).toContain('source branch does not exist.'); + expect(content).toContain('Please restore it or use a different source branch'); + }); + }); +}); |