test(countdown): add test (#3257)

This commit is contained in:
XieZongChen 2022-07-08 23:14:15 +08:00 committed by GitHub
parent ffe8af94fc
commit 70708a4f34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
import { mount } from '@vue/test-utils'
import { sleep } from 'seemly'
import { CountdownProps, NCountdown } from '../index'
describe('n-countdown', () => {
@ -46,4 +47,16 @@ describe('n-countdown', () => {
})
expect(wrapper.text()).not.toBe('1:1:1:1')
})
it('should work with `on-finish` prop', async () => {
const onFinish = jest.fn()
const wrapper = mount(NCountdown, {
props: {
duration: 1,
onFinish
}
})
await sleep(100)
expect(onFinish).toHaveBeenCalled()
wrapper.unmount()
})
})