mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-16 02:11:48 +08:00
d45c2b95b2
* fix(test-utils): fix type error * chore: update * chore: update
30 lines
640 B
TypeScript
30 lines
640 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]: unknown
|
|
}
|
|
methods?: {
|
|
[key: string]: (...args: unknown[]) => any
|
|
}
|
|
}
|
|
|
|
export const makeMountFunc = <T extends Record<string, unknown>>(
|
|
defaultOptions: T
|
|
) => {
|
|
return (template: string, options: Options) => {
|
|
return mount({
|
|
...merge({}, defaultOptions, options),
|
|
template,
|
|
})
|
|
}
|
|
}
|
|
|
|
export default makeMount
|