mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[improvement] NavBar: add test cases
This commit is contained in:
parent
84e71d59fa
commit
166afd1b04
@ -1,67 +1,57 @@
|
|||||||
import Vue from 'vue';
|
|
||||||
import Card from '..';
|
import Card from '..';
|
||||||
import { mount } from '../../../test/utils';
|
import { mount } from '../../../test/utils';
|
||||||
|
|
||||||
Vue.use(Card);
|
test('render price & num slot', () => {
|
||||||
|
const wrapper = mount(Card, {
|
||||||
test('render origin-price slot', () => {
|
scopedSlots: {
|
||||||
const wrapper = mount({
|
num: () => 'Custom Num',
|
||||||
template: `
|
price: () => 'Custom Price'
|
||||||
<van-card>
|
}
|
||||||
<template v-slot:origin-price>Custom Origin Price</template>
|
|
||||||
</van-card>
|
|
||||||
`
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('render price & num slot', () => {
|
test('render origin-price slot', () => {
|
||||||
const wrapper = mount({
|
const wrapper = mount(Card, {
|
||||||
template: `
|
scopedSlots: {
|
||||||
<van-card>
|
'origin-price': () => 'Custom Origin Price'
|
||||||
<template v-slot:num>Custom Num</template>
|
}
|
||||||
<template v-slot:price>Custom Price</template>
|
|
||||||
</van-card>
|
|
||||||
`
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('render bottom slot', () => {
|
test('render bottom slot', () => {
|
||||||
const wrapper = mount({
|
const wrapper = mount(Card, {
|
||||||
template: `
|
propsData: {
|
||||||
<van-card :price="100">
|
price: 100
|
||||||
<template v-slot:bottom>Custom Bottom</template>
|
},
|
||||||
</van-card>
|
scopedSlots: {
|
||||||
`
|
bottom: () => 'Custom Bottom'
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('render thumb & tag slot', () => {
|
test('render thumb & tag slot', () => {
|
||||||
const wrapper = mount({
|
const wrapper = mount(Card, {
|
||||||
template: `
|
scopedSlots: {
|
||||||
<van-card>
|
tag: () => 'Custom Tag',
|
||||||
<template v-slot:thumb>Custom Thumb</template>
|
thumb: () => 'Custom Thumb'
|
||||||
<template v-slot:tag>Custom Tag</template>
|
}
|
||||||
</van-card>
|
|
||||||
`
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('render title & desc slot', () => {
|
test('render title & desc slot', () => {
|
||||||
const wrapper = mount({
|
const wrapper = mount(Card, {
|
||||||
template: `
|
scopedSlots: {
|
||||||
<van-card>
|
title: () => 'Custom Title',
|
||||||
<template v-slot:title>Custom Title</template>
|
desc: () => 'Custom desc'
|
||||||
<template v-slot:desc>Custom desc</template>
|
}
|
||||||
</van-card>
|
|
||||||
`
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
17
packages/nav-bar/test/__snapshots__/index.spec.js.snap
Normal file
17
packages/nav-bar/test/__snapshots__/index.spec.js.snap
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`render left & right slot 1`] = `
|
||||||
|
<div class="van-nav-bar van-hairline--bottom" style="z-index: 1;">
|
||||||
|
<div class="van-nav-bar__left">Custom Left</div>
|
||||||
|
<div class="van-nav-bar__title van-ellipsis"></div>
|
||||||
|
<div class="van-nav-bar__right">Custom Right</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`render title slot 1`] = `
|
||||||
|
<div class="van-nav-bar van-hairline--bottom" style="z-index: 1;">
|
||||||
|
<div class="van-nav-bar__left"></div>
|
||||||
|
<div class="van-nav-bar__title van-ellipsis">Custom Title</div>
|
||||||
|
<div class="van-nav-bar__right"></div>
|
||||||
|
</div>
|
||||||
|
`;
|
23
packages/nav-bar/test/index.spec.js
Normal file
23
packages/nav-bar/test/index.spec.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import NavBar from '..';
|
||||||
|
import { mount } from '../../../test/utils';
|
||||||
|
|
||||||
|
test('render left & right slot', () => {
|
||||||
|
const wrapper = mount(NavBar, {
|
||||||
|
scopedSlots: {
|
||||||
|
left: () => 'Custom Left',
|
||||||
|
right: () => 'Custom Right'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('render title slot', () => {
|
||||||
|
const wrapper = mount(NavBar, {
|
||||||
|
scopedSlots: {
|
||||||
|
title: () => 'Custom Title'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user