apiAsyncComponent.spec.ts — vue Source File
Architecture documentation for apiAsyncComponent.spec.ts, a typescript file in the vue codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 3560519c_9011_d357_7c0e_4e3a07867c76["apiAsyncComponent.spec.ts"] db9e7bef_009d_3918_6e7d_543a36a38d75["vue"] 3560519c_9011_d357_7c0e_4e3a07867c76 --> db9e7bef_009d_3918_6e7d_543a36a38d75 d970b406_3424_b00e_55dd_82e98ab5aac2["v3"] 3560519c_9011_d357_7c0e_4e3a07867c76 --> d970b406_3424_b00e_55dd_82e98ab5aac2 64c87498_c46a_6944_ab9d_8e45519852a8["component"] 3560519c_9011_d357_7c0e_4e3a07867c76 --> 64c87498_c46a_6944_ab9d_8e45519852a8 style 3560519c_9011_d357_7c0e_4e3a07867c76 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import Vue from 'vue'
import { defineAsyncComponent, h, ref, nextTick, defineComponent } from 'v3'
import { Component } from 'types/component'
const timeout = (n: number = 0) => new Promise(r => setTimeout(r, n))
const loadingComponent = defineComponent({
template: `<div>loading</div>`
})
const resolvedComponent = defineComponent({
template: `<div>resolved</div>`
})
describe('api: defineAsyncComponent', () => {
afterEach(() => {
Vue.config.errorHandler = undefined
})
test('simple usage', async () => {
let resolve: (comp: Component) => void
const Foo = defineAsyncComponent(
() =>
new Promise(r => {
resolve = r as any
})
)
const toggle = ref(true)
const vm = new Vue({
render: () => (toggle.value ? h(Foo) : null)
}).$mount()
expect(vm.$el.nodeType).toBe(8)
resolve!(resolvedComponent)
// first time resolve, wait for macro task since there are multiple
// microtasks / .then() calls
await timeout()
expect(vm.$el.innerHTML).toBe('resolved')
toggle.value = false
await nextTick()
expect(vm.$el.nodeType).toBe(8)
// already resolved component should update on nextTick
toggle.value = true
await nextTick()
expect(vm.$el.innerHTML).toBe('resolved')
})
test('with loading component', async () => {
let resolve: (comp: Component) => void
const Foo = defineAsyncComponent({
loader: () =>
new Promise(r => {
resolve = r as any
}),
loadingComponent,
// ... (182 more lines)
Domain
Subdomains
Functions
Dependencies
- component
- v3
- vue
Source
Frequently Asked Questions
What does apiAsyncComponent.spec.ts do?
apiAsyncComponent.spec.ts is a source file in the vue codebase, written in typescript. It belongs to the VueCore domain, Observer subdomain.
What functions are defined in apiAsyncComponent.spec.ts?
apiAsyncComponent.spec.ts defines 1 function(s): timeout.
What does apiAsyncComponent.spec.ts depend on?
apiAsyncComponent.spec.ts imports 3 module(s): component, v3, vue.
Where is apiAsyncComponent.spec.ts in the architecture?
apiAsyncComponent.spec.ts is located at test/unit/features/v3/apiAsyncComponent.spec.ts (domain: VueCore, subdomain: Observer, directory: test/unit/features/v3).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free