mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-11-30 19:27:44 +08:00
Merge pull request #489 from QingWei-Li/test/util/popper
VuePopper: add test
This commit is contained in:
commit
7175ad272d
@ -21,7 +21,7 @@
|
||||
"clean": "rimraf lib && rimraf packages/*/lib",
|
||||
"lint": "eslint src/**/* test/**/* packages/**/*.{js,vue} build/**/* --quiet",
|
||||
"test:watch": "karma start test/unit/karma.conf.js",
|
||||
"test": "karma start test/unit/karma.conf.js --single-run"
|
||||
"test": "npm run lint && karma start test/unit/karma.conf.js --single-run"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
57
test/unit/specs/util.vue-popper.spec.js
Normal file
57
test/unit/specs/util.vue-popper.spec.js
Normal file
@ -0,0 +1,57 @@
|
||||
import VuePopper from 'element-ui/src/utils/vue-popper';
|
||||
import { createTest } from '../util';
|
||||
|
||||
const Popper = Object.assign({}, VuePopper, {
|
||||
render(h) {
|
||||
return h('div');
|
||||
},
|
||||
|
||||
created() {
|
||||
this.popperElm = document.createElement('div');
|
||||
this.referenceElm = document.createElement('div');
|
||||
}
|
||||
});
|
||||
|
||||
describe('Utils:VuePopper', () => {
|
||||
it('createPopper', () => {
|
||||
const vm = createTest(Popper, { placement: 'top' });
|
||||
vm.createPopper();
|
||||
expect(vm.popperJS._popper.getAttribute('x-placement')).to.equal('top');
|
||||
});
|
||||
|
||||
it('doDestroy', () => {
|
||||
const vm = createTest(Popper, { placement: 'top' });
|
||||
vm.createPopper();
|
||||
expect(vm.popperJS._popper.getAttribute('x-placement')).to.equal('top');
|
||||
vm.doDestroy();
|
||||
expect(vm.popperJS).to.not.exist;
|
||||
});
|
||||
|
||||
it('placement', () => {
|
||||
const vm = createTest(Popper, { placement: 'bottom-start' });
|
||||
const vm2 = createTest(Popper, { placement: 'bottom-abc' });
|
||||
|
||||
vm.createPopper();
|
||||
vm2.createPopper();
|
||||
expect(vm.popperJS._popper.getAttribute('x-placement')).to.equal('bottom-start');
|
||||
expect(vm2.popperJS).to.not.exist;
|
||||
});
|
||||
|
||||
it('display arrow', () => {
|
||||
const vm = createTest(Popper, {
|
||||
visibleArrow: true
|
||||
});
|
||||
|
||||
vm.createPopper();
|
||||
expect(vm.popperJS._popper.querySelector('div[x-arrow]')).to.exist;
|
||||
});
|
||||
|
||||
it('destroy', () => {
|
||||
const vm = createTest(Popper, true);
|
||||
|
||||
vm.createPopper();
|
||||
expect(document.body.contains(vm.popperElm)).to.true;
|
||||
vm.$destroy();
|
||||
expect(document.body.contains(vm.popperElm)).to.false;
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user