mirror of
https://github.com/youzan/vant.git
synced 2025-10-19 18:14:13 +00:00
[bugfix] Popup: lock-scroll not work when open multi popup (#842)
This commit is contained in:
@@ -24,7 +24,8 @@ describe('Popup', () => {
|
||||
propsData: {
|
||||
value: false,
|
||||
zIndex: 100,
|
||||
overlay: false
|
||||
overlay: false,
|
||||
lockScroll: false
|
||||
}
|
||||
});
|
||||
|
||||
@@ -60,30 +61,6 @@ describe('Popup', () => {
|
||||
expect(wrapper.instance().currentTransition).to.equal('popup-fade');
|
||||
});
|
||||
|
||||
it('popup prevent scroll', (done) => {
|
||||
wrapper = mount(Popup, {
|
||||
propsData: {
|
||||
value: true
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.hasClass('van-popup')).to.be.true;
|
||||
|
||||
setTimeout(() => {
|
||||
expect(wrapper.element.style.display).to.equal('');
|
||||
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.element.style.display).to.equal('none');
|
||||
done();
|
||||
}, 500);
|
||||
}, 300);
|
||||
});
|
||||
|
||||
it('popup modal', (done) => {
|
||||
wrapper = mount(Popup, {
|
||||
propsData: {
|
||||
@@ -113,6 +90,30 @@ describe('Popup', () => {
|
||||
}, 300);
|
||||
});
|
||||
|
||||
it('popup prevent scroll', (done) => {
|
||||
wrapper = mount(Popup, {
|
||||
propsData: {
|
||||
value: true
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.hasClass('van-popup')).to.be.true;
|
||||
|
||||
setTimeout(() => {
|
||||
expect(wrapper.element.style.display).to.equal('');
|
||||
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.element.style.display).to.equal('none');
|
||||
done();
|
||||
}, 500);
|
||||
}, 300);
|
||||
});
|
||||
|
||||
it('treat empty string as true for boolean props', () => {
|
||||
wrapper = mount(Popup, {
|
||||
propsData: {
|
||||
@@ -127,7 +128,9 @@ describe('Popup', () => {
|
||||
|
||||
it('get container prop', done => {
|
||||
const testNode = document.createElement('div');
|
||||
const testNode2 = document.createElement('div');
|
||||
document.body.appendChild(testNode);
|
||||
document.body.appendChild(testNode2);
|
||||
|
||||
wrapper = mount(Popup, {
|
||||
propsData: {
|
||||
@@ -136,11 +139,44 @@ describe('Popup', () => {
|
||||
});
|
||||
|
||||
expect(wrapper.vm.$el.parentNode === testNode).to.be.true;
|
||||
wrapper.vm.getContainer = () => document.body;
|
||||
wrapper.vm.getContainer = () => testNode2;
|
||||
|
||||
setTimeout(() => {
|
||||
expect(wrapper.vm.$el.parentNode === document.body).to.be.true;
|
||||
expect(wrapper.vm.$el.parentNode === testNode2).to.be.true;
|
||||
wrapper.vm.getContainer = null;
|
||||
done();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
it('watch overlay change', done => {
|
||||
const testNode = document.createElement('div');
|
||||
document.body.appendChild(testNode);
|
||||
|
||||
wrapper = mount(Popup, {
|
||||
propsData: {
|
||||
overlay: false,
|
||||
getContainer: () => testNode
|
||||
}
|
||||
});
|
||||
|
||||
expect(testNode.querySelectorAll('.van-modal').length).to.equal(0);
|
||||
wrapper.vm.overlay = true;
|
||||
setTimeout(() => {
|
||||
expect(testNode.querySelectorAll('.van-modal').length).to.equal(1);
|
||||
done();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
it('popup lock scroll', done => {
|
||||
wrapper = mount(Popup, {
|
||||
propsData: {
|
||||
value: true
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
expect(document.body.classList.contains('van-overflow-hidden')).to.be.true;
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user