2
0

component.spec.ts 583 B

12345678910111213141516171819202122
  1. import { ref, setText, template, watchEffect } from '../src'
  2. import { describe, expect } from 'vitest'
  3. import { makeRender } from './_utils'
  4. const define = makeRender()
  5. describe('component', () => {
  6. test('unmountComponent', async () => {
  7. const { host, app } = define(() => {
  8. const count = ref(0)
  9. const t0 = template('<div></div>')
  10. const n0 = t0()
  11. watchEffect(() => {
  12. setText(n0, count.value)
  13. })
  14. return n0
  15. }).render()
  16. expect(host.innerHTML).toBe('<div>0</div>')
  17. app.unmount()
  18. expect(host.innerHTML).toBe('')
  19. })
  20. })