test: fix async component test
This commit is contained in:
parent
4fa0f2fad4
commit
fc0b7fa038
|
|
@ -1,17 +1,19 @@
|
|||
import { flushPromises, mount } from '@vue/test-utils'
|
||||
import { GlobalMountOptions } from '@vue/test-utils/dist/types'
|
||||
import ArticlesList from 'src/components/ArticlesList.vue'
|
||||
import registerGlobalComponents from 'src/plugins/global-components'
|
||||
import { router } from 'src/router'
|
||||
import { getArticles } from 'src/services/article/getArticles'
|
||||
import asyncComponentWrapper from 'src/utils/test/async-component-wrapper'
|
||||
import fixtures from 'src/utils/test/fixtures'
|
||||
|
||||
jest.mock('src/services/article/getArticles')
|
||||
|
||||
const globalMountOptions: GlobalMountOptions = {
|
||||
plugins: [router],
|
||||
}
|
||||
|
||||
describe('# ArticlesList', () => {
|
||||
const globalMountOptions: GlobalMountOptions = {
|
||||
plugins: [registerGlobalComponents, router],
|
||||
}
|
||||
|
||||
const mockFetchArticles = getArticles as jest.MockedFunction<typeof getArticles>
|
||||
|
||||
beforeEach(async () => {
|
||||
|
|
@ -20,7 +22,7 @@ describe('# ArticlesList', () => {
|
|||
})
|
||||
|
||||
it('should render correctly', async () => {
|
||||
const wrapper = mount(ArticlesList, {
|
||||
const wrapper = mount(asyncComponentWrapper(ArticlesList), {
|
||||
global: globalMountOptions,
|
||||
})
|
||||
await flushPromises()
|
||||
|
|
|
|||
Loading…
Reference in New Issue