[new feature] PullRefresh: add distance of slotProps (#3829)

This commit is contained in:
neverland
2019-07-11 19:24:22 +08:00
committed by GitHub
parent 0c7fc25d97
commit 907c9a3d03
5 changed files with 86 additions and 29 deletions

View File

@@ -42,6 +42,37 @@ test('change head content when pulling down', async () => {
expect(wrapper).toMatchSnapshot();
});
test('custom content by slots', async () => {
const wrapper = mount(PullRefresh, {
scopedSlots: {
pulling({ distance }) {
return `pulling ${distance}`;
},
loosing({ distance }) {
return `loosing ${distance}`;
},
loading({ distance }) {
return `loading ${distance}`;
}
}
});
const track = wrapper.find('.van-pull-refresh__track');
// pulling
trigger(track, 'touchstart', 0, 0);
trigger(track, 'touchmove', 0, 20);
expect(wrapper).toMatchSnapshot();
// loosing
trigger(track, 'touchmove', 0, 100);
expect(wrapper).toMatchSnapshot();
// loading
trigger(track, 'touchend', 0, 100);
expect(wrapper).toMatchSnapshot();
});
test('pull a short distance', () => {
const wrapper = mount(PullRefresh, {
propsData: {