[Improvement] ImagePreview: suppot onClose callback (#1589)

This commit is contained in:
neverland
2018-08-05 17:37:35 +08:00
committed by GitHub
parent 6f6bed4eb9
commit 428cb5059a
5 changed files with 74 additions and 21 deletions
+20
View File
@@ -36,6 +36,26 @@ test('function call', done => {
});
});
test('function call options', done => {
const onClose = jest.fn();
const instance = ImagePreview({
images,
startPostion: 1,
onClose
});
instance.$emit('input', true);
expect(onClose.mock.calls.length).toEqual(0);
Vue.nextTick(() => {
const wrapper = document.querySelector('.van-image-preview');
const swipe = wrapper.querySelector('.van-swipe__track');
triggerDrag(swipe, 0, 0);
expect(onClose.mock.calls.length).toEqual(1);
done();
});
});
test('register component', () => {
Vue.use(ImagePreview);
expect(Vue.component(ImagePreviewVue.name)).toBeTruthy();