tag test improve (#552)

This commit is contained in:
baiyaaaaa 2016-10-20 20:56:07 +08:00 committed by FuryBean
parent febe6e8ffa
commit 831f72bbeb

View File

@ -34,25 +34,41 @@ describe('Tag', () => {
it('hit', () => { it('hit', () => {
const vm = createVue({ const vm = createVue({
template: ` template: `
<el-tag hit="true"></el-tag> <el-tag hit></el-tag>
` `
}, true); }, true);
expect(vm.$el.classList.contains('is-hit')).to.be.true; expect(vm.$el.classList.contains('is-hit')).to.be.true;
}); });
it('closable', () => { it('closable', done => {
const vm = createVue({ const vm = createVue({
template: ` template: `
<el-tag closable="true"></el-tag> <el-tag closable @close="handleClose">关闭标签</el-tag>
` `,
data() {
return {
isClose: false
};
},
methods: {
handleClose() {
this.isClose = true;
}
}
}, true); }, true);
expect(vm.$el.querySelector('.el-tag .el-tag__close')).to.exist; var closeBtn = vm.$el.querySelector('.el-tag .el-tag__close');
expect(closeBtn).to.exist;
closeBtn.click();
vm.$nextTick(_ => {
expect(vm.isClose).to.true;
done();
});
}); });
it('closeTransition', () => { it('closeTransition', () => {
const vm = createVue({ const vm = createVue({
template: ` template: `
<el-tag closable="true" closeTransition="true"></el-tag> <el-tag closable closeTransition></el-tag>
` `
}, true); }, true);
expect(vm.$el.classList.contains('md-fade-center')).to.be.false; expect(vm.$el.classList.contains('md-fade-center')).to.be.false;