diff --git a/packages/runtime-core/__tests__/helpers/renderSlot.spec.ts b/packages/runtime-core/__tests__/helpers/renderSlot.spec.ts new file mode 100644 index 00000000..3f5e321e --- /dev/null +++ b/packages/runtime-core/__tests__/helpers/renderSlot.spec.ts @@ -0,0 +1,25 @@ +import { renderSlot } from '../../src/helpers/renderSlot' +import { h } from '../../src/h' +import { mockWarn } from '@vue/shared' + +describe('renderSlot', () => { + mockWarn() + it('should render slot', () => { + let child + const vnode = renderSlot( + { default: () => [(child = h('child'))] }, + 'default' + ) + expect(vnode.children).toEqual([child]) + }) + + it('should render slot fallback', () => { + const vnode = renderSlot({}, 'default', {}, () => ['fallback']) + expect(vnode.children).toEqual(['fallback']) + }) + + it('should warn render ssr slot', () => { + renderSlot({ default: (a, b, c) => [h('child')] }, 'default') + expect('SSR-optimized slot function detected').toHaveBeenWarned() + }) +})