[bugfix] PullRefresh head overflow (#436)

This commit is contained in:
neverland
2017-12-14 16:32:34 +08:00
committed by GitHub
parent a024399fbe
commit 03bb3cc6ef
5 changed files with 77 additions and 47 deletions
+15 -1
View File
@@ -4,6 +4,7 @@ import { mount } from 'avoriaz';
import { DOMChecker } from '../utils';
const coupon = {
id: 1,
available: 1,
discount: 0,
denominations: 150,
@@ -18,6 +19,7 @@ const coupon = {
const discountCoupon = {
...coupon,
id: 2,
discount: 88,
denominations: 0,
origin_condition: 50,
@@ -26,18 +28,21 @@ const discountCoupon = {
};
const emptyCoupon = {
id: 3,
denominations: 0,
discount: 0
};
const disabledCoupon = {
...coupon,
id: 4,
avaliable: 0,
reason: '未满足使用门槛'
};
const disabledDiscountCoupon = {
...discountCoupon,
id: 5,
avaliable: 0,
reason: '未满足使用门槛'
};
@@ -204,15 +209,19 @@ describe('CouponList', () => {
propsData: {
coupons: [coupon, {
...coupon,
id: 10,
denominations: 10
}, {
...coupon,
id: 11,
denominations: 100
}, {
...coupon,
id: 12,
denominations: 135
}, {
...coupon,
id: 13,
denominations: 0
}]
}
@@ -231,9 +240,11 @@ describe('CouponList', () => {
propsData: {
coupons: [discountCoupon, {
...discountCoupon,
id: 10,
discount: 10
}, {
...discountCoupon,
id: 11,
discount: 0
}]
}
@@ -258,7 +269,10 @@ describe('CouponList', () => {
wrapper.vm.$on('exchange', (code) => {
expect(code).to.equal(code);
wrapper.vm.coupons.push(coupon);
wrapper.vm.coupons.push({
...coupon,
id: 15
});
});
setTimeout(() => {
+28 -22
View File
@@ -25,20 +25,21 @@ describe('PullRefresh', () => {
}
});
triggerTouch(wrapper, 'touchstart', 0, 0);
triggerTouch(wrapper, 'touchmove', 0, 10);
const track = wrapper.find('.van-pull-refresh__track')[0];
triggerTouch(track, 'touchstart', 0, 0);
triggerTouch(track, 'touchmove', 0, 10);
wrapper.vm.$nextTick(() => {
expect(wrapper.find('.van-pull-refresh__text')[0].text()).to.equal('下拉即可刷新...');
triggerTouch(wrapper, 'touchmove', 0, 30);
triggerTouch(wrapper, 'touchmove', 0, 60);
triggerTouch(wrapper, 'touchmove', 0, 100);
triggerTouch(track, 'touchmove', 0, 30);
triggerTouch(track, 'touchmove', 0, 60);
triggerTouch(track, 'touchmove', 0, 100);
wrapper.vm.$nextTick(() => {
expect(wrapper.find('.van-pull-refresh__text')[0].text()).to.equal('释放即可刷新...');
triggerTouch(wrapper, 'touchend', 0, 100);
triggerTouch(track, 'touchend', 0, 100);
wrapper.vm.$nextTick(() => {
expect(wrapper.find('.van-pull-refresh__loading span')[1].text()).to.equal('加载中...');
@@ -67,17 +68,18 @@ describe('PullRefresh', () => {
}, 30);
});
triggerTouch(wrapper, 'touchstart', 0, 0);
triggerTouch(wrapper, 'touchmove', 0, 100);
triggerTouch(wrapper, 'touchend', 0, 100);
const track = wrapper.find('.van-pull-refresh__track')[0];
triggerTouch(track, 'touchstart', 0, 0);
triggerTouch(track, 'touchmove', 0, 100);
triggerTouch(track, 'touchend', 0, 100);
expect(wrapper.vm.value).to.be.true;
expect(wrapper.vm.status).to.equal('loading');
// ignore touch event when loading
triggerTouch(wrapper, 'touchstart', 0, 0);
triggerTouch(wrapper, 'touchmove', 0, 100);
triggerTouch(wrapper, 'touchend', 0, 100);
triggerTouch(track, 'touchstart', 0, 0);
triggerTouch(track, 'touchmove', 0, 100);
triggerTouch(track, 'touchend', 0, 100);
});
it('pull a short distance', () => {
@@ -87,9 +89,10 @@ describe('PullRefresh', () => {
}
});
triggerTouch(wrapper, 'touchstart', 0, 0);
triggerTouch(wrapper, 'touchmove', 0, 10);
triggerTouch(wrapper, 'touchend', 0, 10);
const track = wrapper.find('.van-pull-refresh__track')[0];
triggerTouch(track, 'touchstart', 0, 0);
triggerTouch(track, 'touchmove', 0, 10);
triggerTouch(track, 'touchend', 0, 10);
expect(wrapper.vm.value).to.be.false;
expect(wrapper.vm.status).to.equal('normal');
@@ -104,14 +107,15 @@ describe('PullRefresh', () => {
window.scrollTop = 100;
const track = wrapper.find('.van-pull-refresh__track')[0];
// ignore touch event when not at page top
triggerTouch(wrapper, 'touchstart', 0, 0);
triggerTouch(wrapper, 'touchmove', 0, 100);
triggerTouch(wrapper, 'touchend', 0, 100);
triggerTouch(track, 'touchstart', 0, 0);
triggerTouch(track, 'touchmove', 0, 100);
triggerTouch(track, 'touchend', 0, 100);
expect(wrapper.vm.ceiling).to.be.false;
window.scrollTop = 0;
triggerTouch(wrapper, 'touchmove', 0, 100);
triggerTouch(track, 'touchmove', 0, 100);
expect(wrapper.vm.ceiling).to.be.true;
});
@@ -121,9 +125,11 @@ describe('PullRefresh', () => {
value: false
}
});
triggerTouch(wrapper, 'touchstart', 0, 0);
triggerTouch(wrapper, 'touchmove', 10, 0);
triggerTouch(wrapper, 'touchend', 10, 0);
const track = wrapper.find('.van-pull-refresh__track')[0];
triggerTouch(track, 'touchstart', 0, 0);
triggerTouch(track, 'touchmove', 10, 0);
triggerTouch(track, 'touchend', 10, 0);
expect(wrapper.vm.direction).to.equal('horizontal');
});
});