Skip to content

Commit facec89

Browse files
author
fengweiyao
committed
chore(slide): add vertical unit test case
1 parent b45c51c commit facec89

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/unit/specs/slide.spec.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,37 @@ describe('Slide.vue', () => {
285285
}, 20)
286286
})
287287
})
288+
289+
it('should change vertical pageIndex when direction is vertical', function (done) {
290+
this.timeout(10000)
291+
vm = createVue({
292+
template: `
293+
<cube-slide :threshold="threshold" direction="vertical" style="width:300px;height:100px;">
294+
<cube-slide-item v-for="(item,index) in items" :key="index" :item="item"></cube-slide-item>
295+
</cube-slide>
296+
`,
297+
data: {
298+
items,
299+
threshold: 0.1
300+
}
301+
})
302+
303+
vm.$nextTick(() => {
304+
expect(vm.currentPageIndex).to.equal(0)
305+
dispatchSwipe(vm.$el, [
306+
{
307+
pageX: 180,
308+
pageY: 100
309+
},
310+
{
311+
pageX: 180,
312+
pageY: 20
313+
}
314+
], 100)
315+
setTimeout(() => {
316+
expect(vm.currentPageIndex).to.equal(1)
317+
done()
318+
}, 2000)
319+
})
320+
})
288321
})

0 commit comments

Comments
 (0)