ssrRenderPortal.spec.ts 715 B

1234567891011121314151617181920212223242526272829
  1. import { createApp } from 'vue'
  2. import { renderToString, SSRContext } from '../src/renderToString'
  3. import { ssrRenderPortal } from '../src/helpers/ssrRenderPortal'
  4. describe('ssrRenderPortal', () => {
  5. test('portal rendering', async () => {
  6. const ctx = {
  7. portals: {}
  8. } as SSRContext
  9. await renderToString(
  10. createApp({
  11. data() {
  12. return { msg: 'hello' }
  13. },
  14. ssrRender(_ctx, _push, _parent) {
  15. ssrRenderPortal(
  16. _push => {
  17. _push(`<div>content</div>`)
  18. },
  19. '#target',
  20. _parent
  21. )
  22. }
  23. }),
  24. ctx
  25. )
  26. expect(ctx.portals!['#target']).toBe(`<div>content</div>`)
  27. })
  28. })