2020-09-27 12:10:36 +08:00
|
|
|
import { mount } from '@vue/test-utils'
|
|
|
|
import { merge } from 'lodash'
|
|
|
|
|
|
|
|
const makeMount = <C,O, E>(element: C, defaultOptions: O) => {
|
2021-08-27 17:46:06 +08:00
|
|
|
return (props: (E | O) | (E & O) = {} as E) => mount(element, merge({}, defaultOptions, props))
|
2020-09-27 12:10:36 +08:00
|
|
|
}
|
|
|
|
|
2021-07-23 17:06:01 +08:00
|
|
|
interface Options {
|
|
|
|
data?: () => {
|
|
|
|
[key: string]: any
|
|
|
|
}
|
|
|
|
methods?: {
|
|
|
|
[key: string]: (...args) => any
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const makeMountFunc = defaultOptions => {
|
|
|
|
return (template: string, options: Options) => {
|
|
|
|
return mount({
|
|
|
|
...merge({}, defaultOptions, options),
|
|
|
|
template,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-27 12:10:36 +08:00
|
|
|
export default makeMount
|