mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-23 18:00:27 +08:00
test(PullRefresh): add test cases
This commit is contained in:
parent
e00058b681
commit
f3857053d6
@ -192,3 +192,5 @@ export default createComponent({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//
|
||||||
|
@ -79,3 +79,21 @@ exports[`not in page top 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`render success text 1`] = `
|
||||||
|
<div class="van-pull-refresh">
|
||||||
|
<div class="van-pull-refresh__track" style="transition-duration: 300ms; transform: translate3d(0,50px, 0);">
|
||||||
|
<div class="van-pull-refresh__head">
|
||||||
|
<div class="van-pull-refresh__text">success</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`render success text 2`] = `
|
||||||
|
<div class="van-pull-refresh">
|
||||||
|
<div class="van-pull-refresh__track" style="transition-duration: 300ms;">
|
||||||
|
<div class="van-pull-refresh__head"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
@ -5,13 +5,14 @@ test('change head content when pulling down', async () => {
|
|||||||
const wrapper = mount(PullRefresh, {
|
const wrapper = mount(PullRefresh, {
|
||||||
propsData: {
|
propsData: {
|
||||||
value: false
|
value: false
|
||||||
|
},
|
||||||
|
listeners: {
|
||||||
|
input(value) {
|
||||||
|
wrapper.setProps({ value });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
wrapper.vm.$on('input', value => {
|
|
||||||
wrapper.vm.value = value;
|
|
||||||
});
|
|
||||||
|
|
||||||
const track = wrapper.find('.van-pull-refresh__track');
|
const track = wrapper.find('.van-pull-refresh__track');
|
||||||
|
|
||||||
// pulling
|
// pulling
|
||||||
@ -65,6 +66,7 @@ test('custom content by slots', async () => {
|
|||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
|
||||||
// loosing
|
// loosing
|
||||||
|
trigger(track, 'touchmove', 0, 75);
|
||||||
trigger(track, 'touchmove', 0, 100);
|
trigger(track, 'touchmove', 0, 100);
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
|
||||||
@ -102,3 +104,35 @@ test('not in page top', () => {
|
|||||||
|
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('render success text', async () => {
|
||||||
|
const wrapper = mount(PullRefresh, {
|
||||||
|
propsData: {
|
||||||
|
successText: 'success',
|
||||||
|
successDuration: 0
|
||||||
|
},
|
||||||
|
listeners: {
|
||||||
|
input(value) {
|
||||||
|
wrapper.setProps({ value });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const track = wrapper.find('.van-pull-refresh__track');
|
||||||
|
trigger(track, 'touchstart', 0, 0);
|
||||||
|
trigger(track, 'touchmove', 0, 100);
|
||||||
|
trigger(track, 'touchend', 0, 100);
|
||||||
|
|
||||||
|
await later();
|
||||||
|
|
||||||
|
// loading
|
||||||
|
expect(wrapper.vm.value).toBeTruthy();
|
||||||
|
wrapper.setProps({ value: false });
|
||||||
|
|
||||||
|
// success
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
|
||||||
|
// normal
|
||||||
|
await later();
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user