mirror of
https://github.com/youzan/vant.git
synced 2025-10-16 16:04:04 +00:00
test: fix demo snapshot
This commit is contained in:
26
test/demo.ts
26
test/demo.ts
@@ -1,18 +1,15 @@
|
||||
import Vue, { CreateElement } from 'vue';
|
||||
import '../docs/site/mobile';
|
||||
import { h } from 'Vue';
|
||||
import Locale from '../src/locale';
|
||||
import { mount, later } from '.';
|
||||
import { DemoLocaleMixin } from '../docs/site/demo-locale';
|
||||
|
||||
const Empty = {
|
||||
render(h: CreateElement): ReturnType<CreateElement> {
|
||||
return h('div', [(this as any).$slots.default]);
|
||||
const EmptyComponent = {
|
||||
render() {
|
||||
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) {
|
||||
@@ -23,11 +20,20 @@ export function snapshotDemo(Demo: any, option: any = {}) {
|
||||
Locale.add(Demo.i18n);
|
||||
}
|
||||
|
||||
const wrapper = mount(Demo);
|
||||
const wrapper = mount(Demo, {
|
||||
global: {
|
||||
mixins: [DemoLocaleMixin],
|
||||
components: {
|
||||
'demo-block': EmptyComponent,
|
||||
'demo-section': EmptyComponent,
|
||||
},
|
||||
plugins: [(window as any).vant],
|
||||
},
|
||||
});
|
||||
|
||||
await later();
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
|
||||
if (option.afterTest) {
|
||||
option.afterTest();
|
||||
|
Reference in New Issue
Block a user