|
|
@@ -1,4 +1,4 @@
|
|
|
-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'
|
|
|
|
|
|
@@ -9,7 +9,65 @@ describe('vdomInterop', () => {
|
|
|
|
|
|
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', () => {})
|
|
|
|