[improvement] Card: add test cases

This commit is contained in:
陈嘉涵 2019-05-31 09:53:17 +08:00
parent e8daae912a
commit 3a55346c4e
4 changed files with 80 additions and 16 deletions

View File

@ -23,3 +23,32 @@ exports[`render origin-price slot 1`] = `
</div>
</div>
`;
exports[`render price & num slot 1`] = `
<div class="van-card">
<div class="van-card__header">
<div class="van-card__content">
<div class="van-card__bottom">
<div class="van-card__price">Custom Price</div>
<div class="van-card__num">Custom Num</div>
</div>
</div>
</div>
</div>
`;
exports[`render thumb & tag slot 1`] = `
<div class="van-card">
<div class="van-card__header"><a class="van-card__thumb">Custom Thumb<div class="van-card__tag">Custom Tag</div></a>
<div class="van-card__content"></div>
</div>
</div>
`;
exports[`render title & desc slot 1`] = `
<div class="van-card">
<div class="van-card__header">
<div class="van-card__content">Custom TitleCustom desc</div>
</div>
</div>
`;

View File

@ -1,16 +1,29 @@
import Vue from 'vue';
import Card from '..';
import { mount } from '../../../test/utils';
Vue.use(Card);
test('render origin-price slot', () => {
const wrapper = mount({
template: `
<card>
<van-card>
<template v-slot:origin-price>Custom Origin Price</template>
</card>
`,
components: {
Card
}
</van-card>
`
});
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>
`
});
expect(wrapper).toMatchSnapshot();
@ -19,13 +32,36 @@ test('render origin-price slot', () => {
test('render bottom slot', () => {
const wrapper = mount({
template: `
<card :price="100">
<van-card :price="100">
<template v-slot:bottom>Custom Bottom</template>
</card>
`,
components: {
Card
}
</van-card>
`
});
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>
`
});
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>
`
});
expect(wrapper).toMatchSnapshot();

View File

@ -6,10 +6,8 @@ exports[`arrow direction 1`] = `
`;
exports[`render slot 1`] = `
<div class="van-cell">
<div class="van-cell__title">Custom Title<div class="van-cell__label">Custom Label</div>
</div>Custom Extra
</div>
<div class="van-cell">Custom Icon<div class="van-cell__title">Custom Title<div class="van-cell__label">Custom Label</div>
</div>Custom Extra</div>
`;
exports[`title-style prop 1`] = `

View File

@ -30,6 +30,7 @@ test('render slot', () => {
const wrapper = mount({
template: `
<cell>
<template v-slot:icon>Custom Icon</template>
<template v-slot:title>Custom Title</template>
<template v-slot:label>Custom Label</template>
<template v-slot:extra>Custom Extra</template>