element-plus/packages/test-utils/make-mount.ts
三咲智子 55348b30b6
style: use prettier (#3228)
* style: use prettier

* style: just prettier format, no code changes

* style: eslint fix
object-shorthand, prefer-const

* style: fix no-void

* style: no-console
2021-09-04 19:29:28 +08:00

28 lines
583 B
TypeScript

import { mount } from '@vue/test-utils'
import { merge } from 'lodash'
const makeMount = <C, O, E>(element: C, defaultOptions: O) => {
return (props: (E | O) | (E & O) = {} as E) =>
mount(element, merge({}, defaultOptions, props))
}
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,
})
}
}
export default makeMount