-import { defineComponent, h } from '@vue/runtime-dom'
+import { createVNode, defineComponent, h, renderSlot } from '@vue/runtime-dom'
import { makeInteropRender } from './_utils'
import { createComponent, defineVaporComponent } from '../src'
describe.todo('emit', () => {})
- describe.todo('slots', () => {})
+ describe('slots', () => {
+ test('basic', () => {
+ const VDomChild = defineComponent({
+ setup(_, { slots }) {
+ return () => renderSlot(slots, 'default')
+ },
+ })
+
+ const VaporChild = defineVaporComponent({
+ setup() {
+ return createComponent(
+ VDomChild as any,
+ null,
+ {
+ default: () => document.createTextNode('default slot'),
+ },
+ true,
+ )
+ },
+ })
+
+ const { html } = define({
+ setup() {
+ return () => h(VaporChild as any)
+ },
+ }).render()
+
+ expect(html()).toBe('default slot')
+ })
+
+ test('functional slot', () => {
+ const VDomChild = defineComponent({
+ setup(_, { slots }) {
+ return () => createVNode(slots.default!)
+ },
+ })
+
+ const VaporChild = defineVaporComponent({
+ setup() {
+ return createComponent(
+ VDomChild as any,
+ null,
+ {
+ default: () => document.createTextNode('default slot'),
+ },
+ true,
+ )
+ },
+ })
+
+ const { html } = define({
+ setup() {
+ return () => h(VaporChild as any)
+ },
+ }).render()
+
+ expect(html()).toBe('default slot')
+ })
+ })
describe.todo('provide', () => {})
source = dynamicSources[i]
isDynamic = isFunction(source)
source = isDynamic ? (source as Function)() : source
- if (hasOwn(source, key)) {
+ if (source && hasOwn(source, key)) {
const value = isDynamic ? source[key] : source[key]()
if (merged) {
merged.push(value)