mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
30 lines
616 B
TypeScript
30 lines
616 B
TypeScript
import { nextTick } from 'vue'
|
|
import { flushPromises, mount } from '@vue/test-utils'
|
|
import AsyncWrapper from '../components/AsyncWrapper.vue'
|
|
|
|
test('async component with suspense', async () => {
|
|
expect(AsyncWrapper).toBeTruthy()
|
|
|
|
let resolve: Function
|
|
|
|
const promise = new Promise(_resolve => resolve = _resolve)
|
|
const wrapper = mount(AsyncWrapper, {
|
|
props: {
|
|
promise,
|
|
},
|
|
})
|
|
|
|
await nextTick()
|
|
|
|
expect(wrapper.text()).toContain('fallback')
|
|
|
|
resolve()
|
|
|
|
await flushPromises()
|
|
await nextTick()
|
|
await nextTick()
|
|
|
|
const text = wrapper.text()
|
|
expect(text).toContain('resolved')
|
|
})
|