mirror of
https://github.com/youzan/vant.git
synced 2025-10-17 08:37:23 +00:00
chore: adjust path of test utils (#4997)
This commit is contained in:
36
test/demo.ts
Normal file
36
test/demo.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import Vue, { CreateElement } from 'vue';
|
||||
import '../docs/site/mobile/demo-common';
|
||||
import Locale from '../src/locale';
|
||||
import { mount, later } from '.';
|
||||
|
||||
const Empty = {
|
||||
render(h: CreateElement): ReturnType<CreateElement> {
|
||||
return h('div', [(this as any).$slots.default]);
|
||||
},
|
||||
inheritAttrs: false
|
||||
};
|
||||
|
||||
Vue.component('demo-block', Empty);
|
||||
Vue.component('demo-section', Empty);
|
||||
|
||||
export function snapshotDemo(Demo: any, option: any = {}) {
|
||||
test('renders demo correctly', async () => {
|
||||
if (option.beforeTest) {
|
||||
option.beforeTest();
|
||||
}
|
||||
|
||||
if (Demo.i18n) {
|
||||
Locale.add(Demo.i18n);
|
||||
}
|
||||
|
||||
const wrapper = mount(Demo);
|
||||
|
||||
await later();
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
|
||||
if (option.afterTest) {
|
||||
option.afterTest();
|
||||
}
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user