Skip to content

Commit eb5b32f

Browse files
committed
test: fix resolveAssets test + test resolveDynamicComponent in slots
1 parent 4dc8ffc commit eb5b32f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

packages/runtime-core/__tests__/helpers/resolveAssets.spec.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
Component,
77
Directive,
88
resolveDynamicComponent,
9-
getCurrentInstance
9+
h
1010
} from '@vue/runtime-test'
1111
import { mockWarn } from '@vue/shared'
1212

@@ -100,14 +100,23 @@ describe('resolveAssets', () => {
100100
baz: { render: () => 'baz' }
101101
}
102102
let foo, bar, baz // dynamic components
103+
104+
const Child = {
105+
render(this: any) {
106+
return this.$slots.default()
107+
}
108+
}
109+
103110
const Root = {
104111
components: { foo: dynamicComponents.foo },
105112
setup() {
106-
const instance = getCurrentInstance()!
107113
return () => {
108-
foo = resolveDynamicComponent('foo', instance) // <component is="foo"/>
109-
bar = resolveDynamicComponent(dynamicComponents.bar, instance) // <component :is="bar"/>, function
110-
baz = resolveDynamicComponent(dynamicComponents.baz, instance) // <component :is="baz"/>, object
114+
foo = resolveDynamicComponent('foo') // <component is="foo"/>
115+
bar = resolveDynamicComponent(dynamicComponents.bar) // <component :is="bar"/>, function
116+
return h(Child, () => {
117+
// check inside child slots
118+
baz = resolveDynamicComponent(dynamicComponents.baz) // <component :is="baz"/>, object
119+
})
111120
}
112121
}
113122
}

0 commit comments

Comments
 (0)