diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2019-03-23 16:54:51 +0300 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2019-03-23 19:53:42 +0300 |
commit | 6d330015dfdb1979a0773c87c53b84cc86b28a6d (patch) | |
tree | ec4ace59e610198d0b44523752d546ee38c9b744 /spec/frontend/helpers | |
parent | 09d25b04c34398f9f825b3cc95265af3097fa035 (diff) |
Copy vue_mount_component_helper.js to Jest
Diffstat (limited to 'spec/frontend/helpers')
-rw-r--r-- | spec/frontend/helpers/vue_mount_component_helper.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/frontend/helpers/vue_mount_component_helper.js b/spec/frontend/helpers/vue_mount_component_helper.js new file mode 100644 index 00000000000..6848c95d95d --- /dev/null +++ b/spec/frontend/helpers/vue_mount_component_helper.js @@ -0,0 +1,38 @@ +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 mountComponentWithStore = (Component, { el, props, store }) => + new Component({ + store, + propsData: props || {}, + }).$mount(el); + +export const mountComponentWithSlots = (Component, { props, slots }) => { + const component = new Component({ + propsData: props || {}, + }); + + component.$slots = slots; + + return component.$mount(); +}; + +/** + * Mount a component with the given render method. + * + * This helps with inserting slots that need to be compiled. + */ +export const mountComponentWithRender = (render, el = null) => + mountComponent(Vue.extend({ render }), {}, el); + +export default mountComponent; |