test(carousel): remove useless nextTick (#970)

* test(carousel): added autoplay and interval test

* 写法简化

* use sleep

* remove nextTick
This commit is contained in:
Yanming Deng 2021-08-31 11:36:30 +08:00 committed by GitHub
parent 61f62801c5
commit bb6839f04f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,47 @@ describe('n-carousel', () => {
it('should work with import on demand', () => {
mount(NCarousel)
})
it('should work with `autoplay` and `interval` prop', async () => {
const wrapper = mount(NCarousel, {
slots: {
default: () => {
return [...Array(3).keys()].map((i) => {
return h('div', {}, i.toString())
})
}
}
})
await wrapper.setProps({ autoplay: true, interval: 50 })
await sleep(10)
;([0, 1, 2, 3, 4] as const).forEach((i) => {
if (i === 1) {
expect(
wrapper.find(`[data-index="${i}"]`).attributes('aria-hidden')
).toBe('false')
} else {
expect(
wrapper.find(`[data-index="${i}"]`).attributes('aria-hidden')
).toBe('true')
}
})
await sleep(60)
;([0, 1, 2, 3, 4] as const).forEach((i) => {
if (i === 2) {
expect(
wrapper.find(`[data-index="${i}"]`).attributes('aria-hidden')
).toBe('false')
} else {
expect(
wrapper.find(`[data-index="${i}"]`).attributes('aria-hidden')
).toBe('true')
}
})
})
it('should work with `dotPlacement` prop', async () => {
const wrapper = mount(NCarousel)