test(Toast): should allow to toggle lockClick class

This commit is contained in:
chenjiahan 2020-11-12 11:35:26 +08:00
parent 3cedb085da
commit 0017c352b0
2 changed files with 23 additions and 16 deletions

View File

@ -2,7 +2,6 @@ import Vue from 'vue';
import Toast from '..';
import ToastVue from '../Toast';
import { later } from '../../../test';
import { lockClick } from '../lock-click';
test('create a forbidClick toast', async () => {
const toast = Toast({
@ -188,18 +187,3 @@ test('register component', () => {
Vue.use(Toast);
expect(Vue.component(ToastVue.name)).toBeTruthy();
});
test('lockClick function', () => {
const CLASSNAME = 'van-toast--unclickable';
expect(document.body.classList.contains(CLASSNAME)).toBeFalsy();
lockClick(true);
expect(document.body.classList.contains(CLASSNAME)).toBeTruthy();
lockClick(true);
lockClick(false);
expect(document.body.classList.contains(CLASSNAME)).toBeTruthy();
lockClick(false);
expect(document.body.classList.contains(CLASSNAME)).toBeFalsy();
});

View File

@ -0,0 +1,23 @@
import { lockClick } from '../lock-click';
test('should allow to toggle lockClick class', () => {
const CLASSNAME = 'van-toast--unclickable';
expect(document.body.classList.contains(CLASSNAME)).toBeFalsy();
lockClick(true);
expect(document.body.classList.contains(CLASSNAME)).toBeTruthy();
lockClick(true);
lockClick(false);
expect(document.body.classList.contains(CLASSNAME)).toBeTruthy();
lockClick(false);
lockClick(false);
expect(document.body.classList.contains(CLASSNAME)).toBeFalsy();
lockClick(true);
expect(document.body.classList.contains(CLASSNAME)).toBeTruthy();
lockClick(false);
expect(document.body.classList.contains(CLASSNAME)).toBeFalsy();
});