mirror of
https://github.com/youzan/vant.git
synced 2025-12-13 02:00:53 +08:00
Fix: 修复toast关闭时未移除Dom节点,以及补上单元测试 (#19)
* 文档页样式和打包配置优化 * upload unit test * intanbul ignore src/index * unit test * utils dom unit test * fix: toast not remove * remove dom unit test * remove toast clear unit test * remove toast import vue
This commit is contained in:
@@ -8,32 +8,88 @@ describe('Toast', () => {
|
||||
el.parentNode.removeChild(el);
|
||||
}
|
||||
Toast.clear();
|
||||
if (el.__vue__) {
|
||||
el.__vue__.$destroy();
|
||||
}
|
||||
});
|
||||
|
||||
it('create a toast', () => {
|
||||
Toast('我是提示文案,建议不超过十五字~');
|
||||
it('create a empty toast', () => {
|
||||
const toast = Toast();
|
||||
|
||||
expect(document.querySelector('.van-toast-wrapper')).to.exist;
|
||||
});
|
||||
|
||||
it('create a toast', (done) => {
|
||||
const toast = Toast('toast');
|
||||
|
||||
expect(document.querySelector('.van-toast-wrapper')).to.exist;
|
||||
expect(toast.message).to.equal('toast');
|
||||
expect(toast.type).to.equal('text');
|
||||
setTimeout(() => {
|
||||
expect(typeof toast.timer).to.equal('number');
|
||||
done();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
it('create a loading toast', () => {
|
||||
Toast.loading();
|
||||
const toast = Toast.loading();
|
||||
|
||||
expect(document.querySelector('.van-toast-wrapper')).to.exist;
|
||||
expect(toast.type).to.equal('loading');
|
||||
});
|
||||
|
||||
it('create a options loading toast', () => {
|
||||
const toast = Toast.loading({
|
||||
message: 'toast'
|
||||
});
|
||||
|
||||
expect(document.querySelector('.van-toast-wrapper')).to.exist;
|
||||
expect(toast.message).to.equal('toast');
|
||||
expect(toast.type).to.equal('loading');
|
||||
});
|
||||
|
||||
it('create a success toast', () => {
|
||||
Toast.success('success');
|
||||
const toast = Toast.success('success');
|
||||
|
||||
expect(document.querySelector('.van-toast-wrapper')).to.exist;
|
||||
expect(toast.type).to.equal('success');
|
||||
});
|
||||
|
||||
it('create a fali toast', () => {
|
||||
Toast.fail('fail');
|
||||
it('create a options success toast', () => {
|
||||
const toast = Toast.success({
|
||||
message: 'toast'
|
||||
});
|
||||
|
||||
expect(document.querySelector('.van-toast-wrapper')).to.exist;
|
||||
expect(toast.message).to.equal('toast');
|
||||
expect(toast.type).to.equal('success');
|
||||
});
|
||||
|
||||
it('create a fail toast', () => {
|
||||
const toast = Toast.fail('fail');
|
||||
|
||||
expect(document.querySelector('.van-toast-wrapper')).to.exist;
|
||||
expect(toast.type).to.equal('fail');
|
||||
});
|
||||
|
||||
it('create a options fail toast', () => {
|
||||
const toast = Toast.fail({
|
||||
message: 'toast'
|
||||
});
|
||||
|
||||
expect(document.querySelector('.van-toast-wrapper')).to.exist;
|
||||
expect(toast.message).to.equal('toast');
|
||||
expect(toast.type).to.equal('fail');
|
||||
});
|
||||
|
||||
|
||||
it('create a forbidClick toast', (done) => {
|
||||
Toast({
|
||||
message: 'test',
|
||||
forbidClick: true
|
||||
});
|
||||
|
||||
expect(document.querySelector('.van-toast-wrapper')).to.exist;
|
||||
setTimeout(() => {
|
||||
expect(document.querySelector('.van-toast__overlay')).to.exist;
|
||||
done();
|
||||
}, 500);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user