mirror of
https://github.com/tenrok/vue-select.git
synced 2026-05-26 04:34:04 +03:00
63 lines
1.5 KiB
JavaScript
Executable File
63 lines
1.5 KiB
JavaScript
Executable File
import { mount, shallowMount } from '@vue/test-utils';
|
|
import VueSelect from '../src/components/Select.vue';
|
|
import Vue from 'vue';
|
|
|
|
/**
|
|
* Trigger a submit event on the search
|
|
* input with a provided search text.
|
|
*
|
|
* @param Wrapper {Wrapper<Vue>}
|
|
* @param searchText
|
|
*/
|
|
export const searchSubmit = (Wrapper, searchText = false) => {
|
|
if (searchText) {
|
|
Wrapper.vm.search = searchText;
|
|
}
|
|
Wrapper.find({ref: 'search'}).trigger('keydown.enter');
|
|
};
|
|
|
|
/**
|
|
* Create a new VueSelect instance with
|
|
* a provided set of props.
|
|
* @param propsData
|
|
* @returns {Wrapper<Vue>}
|
|
*/
|
|
export const selectWithProps = (propsData = {}) =>
|
|
shallowMount(VueSelect, {propsData});
|
|
|
|
export const mountWithProps = (propsData = {}) =>
|
|
mount(VueSelect, {propsData});
|
|
|
|
/**
|
|
* Returns a Wrapper with a v-select component.
|
|
* @param props
|
|
* @param options
|
|
* @return {Wrapper<Vue>}
|
|
*/
|
|
export const mountDefault = (props = {}, options = {}) => {
|
|
return shallowMount(VueSelect, {
|
|
propsData: {
|
|
options: ['one', 'two', 'three'],
|
|
...props,
|
|
},
|
|
...options,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Returns a v-select component directly.
|
|
* @param props
|
|
* @param options
|
|
* @return {Vue | Element | Vue[] | Element[]}
|
|
*/
|
|
export const mountWithoutTestUtils = (props = {}, options = {}) => {
|
|
return new Vue({
|
|
render: createEl => createEl('vue-select', {
|
|
ref: 'select',
|
|
props: {options: ['one', 'two', 'three'], ...props},
|
|
...options,
|
|
}),
|
|
components: {VueSelect},
|
|
}).$mount().$refs.select;
|
|
};
|