2020-03-11 04:52:08 +08:00
|
|
|
import { compile } from '../src'
|
|
|
|
|
|
|
|
describe('ssr compile: portal', () => {
|
|
|
|
test('should work', () => {
|
|
|
|
expect(compile(`<portal :target="target"><div/></portal>`).code)
|
|
|
|
.toMatchInlineSnapshot(`
|
|
|
|
"const { ssrRenderPortal: _ssrRenderPortal } = require(\\"@vue/server-renderer\\")
|
|
|
|
|
|
|
|
return function ssrRender(_ctx, _push, _parent) {
|
2020-03-28 08:49:01 +08:00
|
|
|
_ssrRenderPortal(_push, (_push) => {
|
2020-03-11 04:52:08 +08:00
|
|
|
_push(\`<div></div>\`)
|
2020-03-28 11:45:50 +08:00
|
|
|
}, _ctx.target, false, _parent)
|
2020-03-11 04:52:08 +08:00
|
|
|
}"
|
|
|
|
`)
|
|
|
|
})
|
2020-03-28 11:45:50 +08:00
|
|
|
|
|
|
|
test('disabled prop handling', () => {
|
|
|
|
expect(compile(`<portal :target="target" disabled><div/></portal>`).code)
|
|
|
|
.toMatchInlineSnapshot(`
|
|
|
|
"const { ssrRenderPortal: _ssrRenderPortal } = require(\\"@vue/server-renderer\\")
|
|
|
|
|
|
|
|
return function ssrRender(_ctx, _push, _parent) {
|
|
|
|
_ssrRenderPortal(_push, (_push) => {
|
|
|
|
_push(\`<div></div>\`)
|
|
|
|
}, _ctx.target, true, _parent)
|
|
|
|
}"
|
|
|
|
`)
|
|
|
|
|
|
|
|
expect(
|
|
|
|
compile(`<portal :target="target" :disabled="foo"><div/></portal>`).code
|
|
|
|
).toMatchInlineSnapshot(`
|
|
|
|
"const { ssrRenderPortal: _ssrRenderPortal } = require(\\"@vue/server-renderer\\")
|
|
|
|
|
|
|
|
return function ssrRender(_ctx, _push, _parent) {
|
|
|
|
_ssrRenderPortal(_push, (_push) => {
|
|
|
|
_push(\`<div></div>\`)
|
|
|
|
}, _ctx.target, _ctx.foo, _parent)
|
|
|
|
}"
|
|
|
|
`)
|
|
|
|
})
|
2020-03-11 04:52:08 +08:00
|
|
|
})
|