23 lines
1.0 KiB
TypeScript
23 lines
1.0 KiB
TypeScript
|
|
import { afterEach, expect, it, vi } from 'vitest'
|
||
|
|
import { createSSRApp, defineComponent, h } from 'vue'
|
||
|
|
import { renderToString } from 'vue/server-renderer'
|
||
|
|
import { createPinia } from 'pinia'
|
||
|
|
import JobDetail from './JobDetail.vue'
|
||
|
|
import { api } from '../api'
|
||
|
|
|
||
|
|
vi.mock('./AssetPreview.vue', () => ({ default: { render: () => null } }))
|
||
|
|
|
||
|
|
afterEach(() => vi.restoreAllMocks())
|
||
|
|
|
||
|
|
it('fetches an initially selected deep-linked task without depending on recent-list cache', async () => {
|
||
|
|
const request = vi.spyOn(api, 'job').mockReturnValue(new Promise(() => {}))
|
||
|
|
const application = createSSRApp(JobDetail, { jobId: 'archived-owned-job' })
|
||
|
|
application.use(createPinia())
|
||
|
|
application.component('ElDrawer', defineComponent({ setup: (_, { slots }) => () => h('aside', slots.default?.()) }))
|
||
|
|
application.component('ElProgress', { render: () => null })
|
||
|
|
application.component('ElButton', { render: () => null })
|
||
|
|
application.directive('loading', {})
|
||
|
|
await renderToString(application)
|
||
|
|
expect(request).toHaveBeenCalledExactlyOnceWith('archived-owned-job')
|
||
|
|
})
|