Tooltip: Improve hover test (#581)

This commit is contained in:
cinwell.li 2016-10-22 00:08:42 +08:00 committed by FuryBean
parent ac207dc971
commit 718356a67e

View File

@ -10,29 +10,21 @@ describe('Tooltip', () => {
expect(vm.$el.querySelector('.el-tooltip__popper')).to.have.property('textContent', '提示文字'); expect(vm.$el.querySelector('.el-tooltip__popper')).to.have.property('textContent', '提示文字');
}); });
it('hover', done => { describe('hover', () => {
const vm = createVue(` const vm = createVue(`
<el-tooltip ref="tooltip" content="提示文字"> <el-tooltip ref="tooltip" content="提示文字">
<button>click</button> <button>click</button>
</el-tooltip> </el-tooltip>
`, true); `);
const tooltip = vm.$refs.tooltip; const tooltip = vm.$refs.tooltip;
// trigger mouseenter
tooltip.handleShowPopper(); tooltip.handleShowPopper();
it('popperElm is exist', () => expect(tooltip.popperElm).to.exist);
expect(tooltip.popperElm).to.not.exist; it('showPopper is true', () => expect(tooltip.showPopper).to.true);
setTimeout(_ => { it('close popper', () => {
expect(tooltip).to.have.deep.property('popperElm.style.display').not.equal('none');
// trigger mouseleave
tooltip.handleClosePopper(); tooltip.handleClosePopper();
expect(tooltip.showPopper).to.false;
setTimeout(_ => { });
expect(tooltip).to.have.deep.property('popperElm.style.display', 'none');
done();
}, 500);
}, 150);
}); });
it('light mode', () => { it('light mode', () => {