test(runtime-core): add test for renderSlot (#1160)

This commit is contained in:
underfin 2020-05-18 22:14:09 +08:00 committed by GitHub
parent 6574a5bf29
commit efa3214866
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()
})
})