Tooltip: add test (#487)

pull/501/head
cinwell.li 2016-10-18 19:07:43 +08:00 committed by FuryBean
parent 7175ad272d
commit 815bdd47d0
3 changed files with 52 additions and 2 deletions

View File

@ -10,6 +10,7 @@ var INSTALL_COMPONENT_TEMPLATE = ' Vue.component({{name}}.name, {{name}});';
var MAIN_TEMPLATE = `{{include}}
const install = function(Vue) {
/* istanbul ignore if */
if (install.installed) return;
{{install}}
@ -24,7 +25,7 @@ const install = function(Vue) {
Vue.prototype.$message = Message;
};
// auto install
/* istanbul ignore if */
if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue);
};

View File

@ -55,6 +55,7 @@ import Steps from '../packages/steps/index.js';
import Step from '../packages/step/index.js';
const install = function(Vue) {
/* istanbul ignore next */
if (install.installed) return;
Vue.component(Pagination.name, Pagination);
@ -119,7 +120,7 @@ const install = function(Vue) {
Vue.prototype.$message = Message;
};
// auto install
/* istanbul ignore next */
if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue);
};

View File

@ -0,0 +1,48 @@
import { createVue } from '../util';
describe('Tooltip', () => {
it('create', () => {
const vm = createVue(`
<el-tooltip content="提示文字">
<button>click</button>
</el-tooltip>`);
expect(vm.$el.querySelector('.el-tooltip__popper')).to.exist;
expect(vm.$el.querySelector('.el-tooltip__popper').textContent).to.equal('提示文字');
});
it('hover', done => {
const vm = createVue(`
<el-tooltip ref="tooltip" content="提示文字">
<button>click</button>
</el-tooltip>
`, true);
const tooltip = vm.$refs.tooltip;
// trigger mouseenter
tooltip.handleShowPopper();
expect(tooltip.popperElm).to.not.exist;
setTimeout(_ => {
expect(tooltip.popperElm).to.exist;
expect(tooltip.popperElm.style.display).to.not.equal('none');
// trigger mouseleave
tooltip.handleClosePopper();
setTimeout(_ => {
expect(tooltip.popperElm.style.display).to.equal('none');
done();
}, 500);
}, 150);
});
it('light mode', () => {
const vm = createVue(`
<el-tooltip content="abc" effect="light">
<button>abc</button>
</el-tooltip>
`);
expect(vm.$el.querySelector('.is-light')).to.exist;
});
});