element-plus/packages/test-utils/make-mount.ts
Sanxiaozhizi e9e56d5938
chore: upgrade & improve eslint rule (#3105)
* chore: remove unused ts-node

* chore: upgrade lodash

* chore: upgrade eslint

* perf: remove side effects in computed

* refactor: follow eslint rules

* chore: remove vue-template-compiler

* style: enhance eslint format rule

* style: format code
2021-08-27 17:46:06 +08:00

27 lines
576 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