forked from youzan/vant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.ts
36 lines (28 loc) · 763 Bytes
/
demo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import Vue, { CreateElement } from 'vue';
import '../docs/site/mobile';
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();
}
});
}