diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-05-14 12:30:51 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-05-14 12:30:51 +0300 |
commit | 1a103161f729e7f7351476c0f7c09d5265fdc0b9 (patch) | |
tree | 0c9d3155c1606ba12ad315f313f2e85414be470b /spec | |
parent | 7ecb4162fe44e1d25da93d770d8d070ca4a22e3b (diff) | |
parent | 7877edeca98687133255bc9fca45930c49618b22 (diff) |
Merge branch 'kp-add-vue-create-component-helper' into 'master'
Add `createComponentWithMixin` to create anonymous components with mixins
See merge request gitlab-org/gitlab-ce!18899
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/helpers/vue_mount_component_helper.js | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/spec/javascripts/helpers/vue_mount_component_helper.js b/spec/javascripts/helpers/vue_mount_component_helper.js index effacbcff4e..a34a1add4e0 100644 --- a/spec/javascripts/helpers/vue_mount_component_helper.js +++ b/spec/javascripts/helpers/vue_mount_component_helper.js @@ -1,14 +1,30 @@ +import Vue from 'vue'; + +const mountComponent = (Component, props = {}, el = null) => new Component({ + propsData: props, +}).$mount(el); + export const createComponentWithStore = (Component, store, propsData = {}) => new Component({ store, propsData, }); +export const createComponentWithMixin = (mixins = [], state = {}, props = {}, template = '<div></div>') => { + const Component = Vue.extend({ + template, + mixins, + data() { + return props; + }, + }); + + return mountComponent(Component, props); +}; + export const mountComponentWithStore = (Component, { el, props, store }) => new Component({ store, propsData: props || { }, }).$mount(el); -export default (Component, props = {}, el = null) => new Component({ - propsData: props, -}).$mount(el); +export default mountComponent; |