[improvement] NavBar: add test cases

This commit is contained in:
陈嘉涵
2019-05-31 10:03:25 +08:00
parent 84e71d59fa
commit 166afd1b04
3 changed files with 68 additions and 38 deletions
+28 -38
View File
@@ -1,67 +1,57 @@
import Vue from 'vue';
import Card from '..';
import { mount } from '../../../test/utils';
Vue.use(Card);
test('render origin-price slot', () => {
const wrapper = mount({
template: `
<van-card>
<template v-slot:origin-price>Custom Origin Price</template>
</van-card>
`
test('render price & num slot', () => {
const wrapper = mount(Card, {
scopedSlots: {
num: () => 'Custom Num',
price: () => 'Custom Price'
}
});
expect(wrapper).toMatchSnapshot();
});
test('render price & num slot', () => {
const wrapper = mount({
template: `
<van-card>
<template v-slot:num>Custom Num</template>
<template v-slot:price>Custom Price</template>
</van-card>
`
test('render origin-price slot', () => {
const wrapper = mount(Card, {
scopedSlots: {
'origin-price': () => 'Custom Origin Price'
}
});
expect(wrapper).toMatchSnapshot();
});
test('render bottom slot', () => {
const wrapper = mount({
template: `
<van-card :price="100">
<template v-slot:bottom>Custom Bottom</template>
</van-card>
`
const wrapper = mount(Card, {
propsData: {
price: 100
},
scopedSlots: {
bottom: () => 'Custom Bottom'
}
});
expect(wrapper).toMatchSnapshot();
});
test('render thumb & tag slot', () => {
const wrapper = mount({
template: `
<van-card>
<template v-slot:thumb>Custom Thumb</template>
<template v-slot:tag>Custom Tag</template>
</van-card>
`
const wrapper = mount(Card, {
scopedSlots: {
tag: () => 'Custom Tag',
thumb: () => 'Custom Thumb'
}
});
expect(wrapper).toMatchSnapshot();
});
test('render title & desc slot', () => {
const wrapper = mount({
template: `
<van-card>
<template v-slot:title>Custom Title</template>
<template v-slot:desc>Custom desc</template>
</van-card>
`
const wrapper = mount(Card, {
scopedSlots: {
title: () => 'Custom Title',
desc: () => 'Custom desc'
}
});
expect(wrapper).toMatchSnapshot();