Skip to content

Commit efa3214

Browse files
authored
test(runtime-core): add test for renderSlot (vuejs#1160)
1 parent 6574a5b commit efa3214

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { renderSlot } from '../../src/helpers/renderSlot'
2+
import { h } from '../../src/h'
3+
import { mockWarn } from '@vue/shared'
4+
5+
describe('renderSlot', () => {
6+
mockWarn()
7+
it('should render slot', () => {
8+
let child
9+
const vnode = renderSlot(
10+
{ default: () => [(child = h('child'))] },
11+
'default'
12+
)
13+
expect(vnode.children).toEqual([child])
14+
})
15+
16+
it('should render slot fallback', () => {
17+
const vnode = renderSlot({}, 'default', {}, () => ['fallback'])
18+
expect(vnode.children).toEqual(['fallback'])
19+
})
20+
21+
it('should warn render ssr slot', () => {
22+
renderSlot({ default: (a, b, c) => [h('child')] }, 'default')
23+
expect('SSR-optimized slot function detected').toHaveBeenWarned()
24+
})
25+
})

0 commit comments

Comments
 (0)