mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-23 15:09:16 +08:00
Popup: add test cases
This commit is contained in:
parent
625f6e7d8d
commit
3a642fce0c
@ -99,6 +99,7 @@ export default {
|
|||||||
* 显示popup
|
* 显示popup
|
||||||
*/
|
*/
|
||||||
open() {
|
open() {
|
||||||
|
/* istanbul ignore if */
|
||||||
if (this.$isServer) return;
|
if (this.$isServer) return;
|
||||||
if (this.opened) return;
|
if (this.opened) return;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ describe('PayOrder', () => {
|
|||||||
propsData: {
|
propsData: {
|
||||||
price: 3005,
|
price: 3005,
|
||||||
buttonText: '提交订单',
|
buttonText: '提交订单',
|
||||||
buttonType: 'normal'
|
buttonType: 'default'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import Popup from 'packages/popup';
|
import Popup from 'packages/popup';
|
||||||
import { mount } from 'avoriaz';
|
import { mount } from 'avoriaz';
|
||||||
|
import { triggerTouch } from '../utils';
|
||||||
|
|
||||||
describe('Popup', () => {
|
describe('Popup', () => {
|
||||||
let wrapper;
|
let wrapper;
|
||||||
@ -57,4 +58,60 @@ describe('Popup', () => {
|
|||||||
expect(wrapper.hasClass('van-popup')).to.be.true;
|
expect(wrapper.hasClass('van-popup')).to.be.true;
|
||||||
expect(wrapper.instance().currentTransition).to.equal('popup-fade');
|
expect(wrapper.instance().currentTransition).to.equal('popup-fade');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('popup prevent scroll', (done) => {
|
||||||
|
wrapper = mount(Popup, {
|
||||||
|
propsData: {
|
||||||
|
preventScroll: true,
|
||||||
|
value: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.hasClass('van-popup')).to.be.true;
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
expect(wrapper.data().currentValue).to.be.true;
|
||||||
|
wrapper.vm.value = false;
|
||||||
|
triggerTouch(document, 'touchstart', 0, 0);
|
||||||
|
triggerTouch(document, 'touchmove', 0, 10);
|
||||||
|
triggerTouch(document, 'touchmove', 0, 30);
|
||||||
|
triggerTouch(document, 'touchmove', 0, -30);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
expect(wrapper.data().currentValue).to.be.false;
|
||||||
|
done();
|
||||||
|
}, 300);
|
||||||
|
}, 300);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('popup modal', (done) => {
|
||||||
|
wrapper = mount(Popup, {
|
||||||
|
propsData: {
|
||||||
|
preventScroll: true,
|
||||||
|
value: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
wrapper.vm.$on('input', val => {
|
||||||
|
wrapper.vm.value = val;
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.hasClass('van-popup')).to.be.true;
|
||||||
|
|
||||||
|
const modal = document.querySelector('.van-modal');
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
triggerTouch(modal, 'touchstart', 0, 0);
|
||||||
|
triggerTouch(modal, 'touchmove', 0, 10);
|
||||||
|
triggerTouch(modal, 'touchmove', 0, 30);
|
||||||
|
triggerTouch(modal, 'touchmove', 0, -30);
|
||||||
|
expect(modal).to.exist;
|
||||||
|
|
||||||
|
modal.click();
|
||||||
|
setTimeout(() => {
|
||||||
|
expect(wrapper.data().currentValue).to.be.false;
|
||||||
|
done();
|
||||||
|
}, 300);
|
||||||
|
}, 300);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user