test: fix demo snapshot

This commit is contained in:
chenjiahan
2020-08-22 10:59:22 +08:00
parent f0482c7eec
commit 6016a4acf1
4 changed files with 143 additions and 142 deletions

View File

@@ -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();