diff options
author | Kushal Pandya <kushal@gitlab.com> | 2018-05-11 15:12:05 +0530 |
---|---|---|
committer | Kushal Pandya <kushal@gitlab.com> | 2018-05-14 13:58:38 +0530 |
commit | 7877edeca98687133255bc9fca45930c49618b22 (patch) | |
tree | 4f70106704e88f6157b78b008e9e84f46822f937 /spec | |
parent | 03401338983115cb5fd2395165eac4c5a64a42e3 (diff) | |
download | gitlab-ce-7877edeca98687133255bc9fca45930c49618b22.tar.gz |
Add `createComponentWithMixin` to create anonymous components with mixin
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; |