diff options
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/helpers/vue_mount_component_helper.js | 10 | ||||
-rw-r--r-- | spec/javascripts/vue_shared/components/reports/report_section_spec.js | 25 |
2 files changed, 34 insertions, 1 deletions
diff --git a/spec/javascripts/helpers/vue_mount_component_helper.js b/spec/javascripts/helpers/vue_mount_component_helper.js index 5ba17ecf5b5..1057f0aca3e 100644 --- a/spec/javascripts/helpers/vue_mount_component_helper.js +++ b/spec/javascripts/helpers/vue_mount_component_helper.js @@ -15,4 +15,14 @@ export const mountComponentWithStore = (Component, { el, props, store }) => propsData: props || {}, }).$mount(el); +export const mountComponentWithSlots = (Component, { props, slots }) => { + const component = new Component({ + propsData: props || {}, + }); + + component.$slots = slots; + + return component.$mount(); +}; + export default mountComponent; diff --git a/spec/javascripts/vue_shared/components/reports/report_section_spec.js b/spec/javascripts/vue_shared/components/reports/report_section_spec.js index 8d5401a9d89..4e3986acb16 100644 --- a/spec/javascripts/vue_shared/components/reports/report_section_spec.js +++ b/spec/javascripts/vue_shared/components/reports/report_section_spec.js @@ -1,6 +1,6 @@ import Vue from 'vue'; import reportSection from '~/vue_shared/components/reports/report_section.vue'; -import mountComponent from 'spec/helpers/vue_mount_component_helper'; +import mountComponent, { mountComponentWithSlots } from 'spec/helpers/vue_mount_component_helper'; describe('Report section', () => { let vm; @@ -171,4 +171,27 @@ describe('Report section', () => { expect(vm.$el.textContent.trim()).toEqual('Failed to load codeclimate report'); }); }); + + describe('with action buttons passed to the slot', () => { + beforeEach(() => { + vm = mountComponentWithSlots(ReportSection, { + props: { + status: 'SUCCESS', + successText: 'success', + hasIssues: true, + }, + slots: { + actionButtons: ['Action!'], + }, + }); + }); + + it('should render the passed button', () => { + expect(vm.$el.textContent.trim()).toContain('Action!'); + }); + + it('should still render the expand/collapse button', () => { + expect(vm.$el.querySelector('.js-collapse-btn').textContent.trim()).toEqual('Expand'); + }); + }); }); |