feat(ImagePreview): add swipeTo method (#6596)

This commit is contained in:
来铧敏
2020-06-22 20:47:04 +08:00
committed by GitHub
parent 60fb4cc7bc
commit bd1279bc7d
6 changed files with 76 additions and 0 deletions
+21
View File
@@ -309,3 +309,24 @@ test('get container with component call', () => {
wrapper.vm.getContainer = null;
expect(wrapper.element).toEqual(wrapper.element);
});
test('swipeTo method', async () => {
const wrapper = mount({
template: `
<div>
<van-image-preview ref="imagePreview" :value="true" :images="images">
</van-image-preview>
</div>
`,
data() {
return {
images,
};
},
});
const { imagePreview } = wrapper.vm.$refs;
imagePreview.swipeTo(2);
await later(100);
expect(imagePreview.active).toEqual(2);
});