mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 10:44:59 +00:00
31
test/unit/specs/utils.dom.spec.js
Normal file
31
test/unit/specs/utils.dom.spec.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { hasClass, addClass, removeClass } from 'src/utils/dom';
|
||||
|
||||
describe('Utils Dom', () => {
|
||||
let wrapper;
|
||||
beforeEach(() => {
|
||||
wrapper = document.createElement('div');
|
||||
wrapper.classList.add('test-class');
|
||||
document.body.appendChild(wrapper);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(wrapper);
|
||||
});
|
||||
|
||||
it('hasClass', () => {
|
||||
expect(hasClass(wrapper, 'test-class')).to.be.true;
|
||||
expect(hasClass()).to.be.false;
|
||||
});
|
||||
|
||||
it('addClass and removeClass', () => {
|
||||
expect(hasClass(wrapper, 'test-class')).to.be.true;
|
||||
|
||||
addClass(wrapper, ' other-class');
|
||||
expect(hasClass(wrapper, 'other-class')).to.be.true;
|
||||
expect(addClass()).to.equal(undefined);
|
||||
|
||||
removeClass(wrapper, ' other-class');
|
||||
expect(hasClass(wrapper, 'other-class')).to.be.false;
|
||||
expect(removeClass()).to.equal(undefined);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user