Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6922775

Browse files
committedMar 17, 2024·
chore: fix test
1 parent d690331 commit 6922775

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed
 

‎packages/runtime-vapor/__tests__/_utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function makeRender<Component = ObjectComponent | SetupFn>(
3434
slots: Slots = {},
3535
container: string | ParentNode = '#host',
3636
) => {
37-
app = createVaporApp(component, props)
37+
app = createVaporApp(component, props, slots)
3838
instance = app.mount(container)
3939

4040
return res()

‎packages/runtime-vapor/__tests__/componentSlots.spec.ts

+7-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// NOTE: This test is implemented based on the case of `runtime-core/__test__/componentSlots.spec.ts`.
22

33
import {
4+
createComponent,
45
defineComponent,
56
getCurrentInstance,
67
nextTick,
78
ref,
8-
render as renderComponent,
99
template,
1010
} from '../src'
1111
import { createSlots } from '../src/slot'
@@ -28,9 +28,7 @@ describe('component: slots', () => {
2828

2929
const { render } = define({
3030
render() {
31-
const t0 = template('<div></div>')
32-
const n0 = t0()
33-
renderComponent(Comp, {}, slots, n0 as ParentNode)
31+
return createComponent(Comp, {}, slots)
3432
},
3533
})
3634

@@ -58,12 +56,12 @@ describe('component: slots', () => {
5856
)
5957

6058
test('initSlots: instance.slots should be set correctly', () => {
61-
let proxy: any
59+
let instance: any
6260
const { render } = define({
6361
render() {
6462
const t0 = template('<div></div>')
6563
const n0 = t0()
66-
proxy = getCurrentInstance()
64+
instance = getCurrentInstance()
6765
return n0
6866
},
6967
})
@@ -78,7 +76,8 @@ describe('component: slots', () => {
7876
},
7977
}),
8078
)
81-
expect(proxy.slots.header()).toMatchObject([
79+
console.log('🚀 ~ test ~ proxy:', instance)
80+
expect(instance.slots.header()).toMatchObject([
8281
document.createTextNode('header'),
8382
])
8483
})
@@ -116,9 +115,7 @@ describe('component: slots', () => {
116115

117116
const { render } = define({
118117
render() {
119-
const t0 = template('<div></div>')
120-
const n0 = t0()
121-
renderComponent(
118+
return createComponent(
122119
Child,
123120
{},
124121
createSlots({
@@ -129,9 +126,7 @@ describe('component: slots', () => {
129126
: [template('<div></div>')()]
130127
},
131128
}),
132-
n0 as ParentNode,
133129
)
134-
return []
135130
},
136131
})
137132

‎packages/runtime-vapor/src/apiCreateVaporApp.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function createVaporApp(
4040

4141
mount(rootContainer): any {
4242
if (!instance) {
43-
instance = createComponentInstance(rootComponent, rootProps)
43+
instance = createComponentInstance(rootComponent, rootProps, rootSlots)
4444
setupComponent(instance)
4545
render(instance, rootContainer)
4646
return instance

0 commit comments

Comments
 (0)
Please sign in to comment.