Tab: add test cases

This commit is contained in:
陈嘉涵 2017-09-27 11:05:33 +08:00
parent 37a5c55ddb
commit aaaf569759
2 changed files with 22 additions and 1 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<van-tabs :active="active" :duration="duration" @click="handleTabClick" @disabled="handleTabDisabledClick"> <van-tabs :active="active" :duration="duration" @click="handleTabClick" @disabled="handleTabDisabledClick">
<van-tab title="选项一">内容一</van-tab> <van-tab :title="firstTabTitle" :disabled="firstTabDisabled">内容一</van-tab>
<van-tab title="选项二">内容二</van-tab> <van-tab title="选项二">内容二</van-tab>
<van-tab title="选项三" disabled>内容三</van-tab> <van-tab title="选项三" disabled>内容三</van-tab>
<van-tab title="选项四">内容四</van-tab> <van-tab title="选项四">内容四</van-tab>
@ -17,6 +17,16 @@ export default {
'van-tabs': Tabs 'van-tabs': Tabs
}, },
props: {
firstTabTitle: {
type: String,
default: '选项一'
},
firstTabDisabled: {
type: Boolean
}
},
data() { data() {
return { return {
active: 0, active: 0,

View File

@ -146,4 +146,15 @@ describe('Tabs', () => {
done(); done();
}, 1200); }, 1200);
}); });
it('watch tab props changes', (done) => {
wrapper = mount(TabsTestComponent);
wrapper.vm.firstTabTitle = '测试标题';
wrapper.vm.firstTabDisabled = true;
wrapper.vm.$nextTick(() => {
expect(wrapper.find('.van-tab')[0].text().replace(/\n|\s/g, '')).to.equal('测试标题');
done();
});
});
}); });