Skip to content

Commit

Permalink
chore: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
ubugeeei committed Mar 17, 2024
1 parent d690331 commit 6922775
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/runtime-vapor/__tests__/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function makeRender<Component = ObjectComponent | SetupFn>(
slots: Slots = {},
container: string | ParentNode = '#host',
) => {
app = createVaporApp(component, props)
app = createVaporApp(component, props, slots)
instance = app.mount(container)

return res()
Expand Down
19 changes: 7 additions & 12 deletions packages/runtime-vapor/__tests__/componentSlots.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// NOTE: This test is implemented based on the case of `runtime-core/__test__/componentSlots.spec.ts`.

import {
createComponent,
defineComponent,
getCurrentInstance,
nextTick,
ref,
render as renderComponent,
template,
} from '../src'
import { createSlots } from '../src/slot'
Expand All @@ -28,9 +28,7 @@ describe('component: slots', () => {

const { render } = define({
render() {
const t0 = template('<div></div>')
const n0 = t0()
renderComponent(Comp, {}, slots, n0 as ParentNode)
return createComponent(Comp, {}, slots)
},
})

Expand Down Expand Up @@ -58,12 +56,12 @@ describe('component: slots', () => {
)

test('initSlots: instance.slots should be set correctly', () => {
let proxy: any
let instance: any
const { render } = define({
render() {
const t0 = template('<div></div>')
const n0 = t0()
proxy = getCurrentInstance()
instance = getCurrentInstance()
return n0
},
})
Expand All @@ -78,7 +76,8 @@ describe('component: slots', () => {
},
}),
)
expect(proxy.slots.header()).toMatchObject([
console.log('🚀 ~ test ~ proxy:', instance)
expect(instance.slots.header()).toMatchObject([
document.createTextNode('header'),
])
})
Expand Down Expand Up @@ -116,9 +115,7 @@ describe('component: slots', () => {

const { render } = define({
render() {
const t0 = template('<div></div>')
const n0 = t0()
renderComponent(
return createComponent(
Child,
{},
createSlots({
Expand All @@ -129,9 +126,7 @@ describe('component: slots', () => {
: [template('<div></div>')()]
},
}),
n0 as ParentNode,
)
return []
},
})

Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-vapor/src/apiCreateVaporApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function createVaporApp(

mount(rootContainer): any {
if (!instance) {
instance = createComponentInstance(rootComponent, rootProps)
instance = createComponentInstance(rootComponent, rootProps, rootSlots)
setupComponent(instance)
render(instance, rootContainer)
return instance
Expand Down

0 comments on commit 6922775

Please sign in to comment.