2
0
mirror of https://github.com/tenrok/vue-select.git synced 2026-05-17 02:29:37 +03:00
Files
Jeff Sagal 98c278b2bb build(vite): replace webpack with Vite, add Typescript (#1594)
BREAKING: mixins are no longer exported from the index (and will likely be converted to hooks)
2022-07-18 09:33:46 -07:00

71 lines
1.5 KiB
JavaScript
Executable File

import { shallowMount } from '@vue/test-utils'
import VueSelect from '@/components/Select.vue'
/**
* Trigger a submit event on the search
* input with a provided search text.
*
* @param Wrapper {Wrapper<Vue>}
* @param searchText
*/
export const searchSubmit = async (Wrapper, searchText = undefined) => {
await Wrapper.get('input').trigger('focus')
if (searchText) {
Wrapper.vm.search = searchText
await Wrapper.vm.$nextTick()
}
await Wrapper.get('input').trigger('keydown.enter')
}
/**
* Focus the search input
*/
export const searchFocus = async (Wrapper) => {
await Wrapper.get('input').trigger('focus')
await Wrapper.vm.$nextTick()
}
/**
* Focus the input, enter some search text, hit return.
* @param Wrapper {Wrapper<Vue>}
* @param searchText
* @return {Promise<void>}
*/
export const selectTag = async (Wrapper, searchText) => {
Wrapper.vm.$refs.search.focus()
await Wrapper.vm.$nextTick()
Wrapper.vm.search = searchText
await Wrapper.vm.$nextTick()
await Wrapper.get('input').trigger('keydown.enter')
}
/**
* Create a new VueSelect instance with
* a provided set of props.
* @param props
* @returns {Wrapper<Vue>}
*/
export const selectWithProps = (props = {}) => {
return shallowMount(VueSelect, { props })
}
/**
* Returns a Wrapper with a v-select component.
* @param props
* @param options
* @return {Wrapper<Vue>}
*/
export const mountDefault = (props = {}, options = {}) => {
return shallowMount(VueSelect, {
props: {
options: ['one', 'two', 'three'],
...props,
},
...options,
})
}