feat(ImagePreview): enable swipe lazy-render (#5879)

This commit is contained in:
chenjiahan
2020-03-22 15:53:15 +08:00
parent 365f2b16f7
commit 7ac85868dc
4 changed files with 16 additions and 97 deletions
+6 -18
View File
@@ -177,7 +177,8 @@ test('onScale option', async done => {
},
});
const image = instance.$el.getElementsByTagName('img')[0];
await later();
const image = instance.$el.querySelector('img');
triggerZoom(image, 300, 300);
Element.prototype.getBoundingClientRect = getBoundingClientRect;
});
@@ -195,10 +196,12 @@ test('zoom', async () => {
propsData: { images, value: true },
});
const image = wrapper.find('img');
await later();
const image = wrapper.find('.van-image');
triggerZoom(image, 300, 300);
triggerDrag(image, 300, 300);
expect(wrapper).toMatchSnapshot();
expect(image).toMatchSnapshot();
Element.prototype.getBoundingClientRect = getBoundingClientRect;
});
@@ -257,18 +260,3 @@ test('closeOnPopstate', () => {
trigger(window, 'popstate');
expect(wrapper.emitted('input')[1]).toBeFalsy();
});
test('lazy-load prop', () => {
const wrapper = mount(ImagePreviewVue, {
propsData: {
images,
lazyLoad: true,
},
});
wrapper.setProps({
value: true,
});
expect(wrapper).toMatchSnapshot();
});