// example.jsx import type { Renew } from '@/index'; import { h, Fragment, render, mount, ref, nextTick } from '@/index'; const testChangeRef = ref void)>(null); const Renew2 = mount<{ count1: number; change: () => void; }>(() => { return ({ count1, change }) => { return (
  • count1: {count1}
  • ); }; }); const RenewHoc = mount(function one(renew, _props) { let count1 = 0; const change = () => { count1 += 1; renew(); }; testChangeRef.value = change; return () => { return ; }; }); const Renew = mount(function one(renew, _props) { let count1 = 0; const change = () => { count1 += 1; renew(); }; testChangeRef.value = change; return () => { return ( ); }; }); const testWrap = document.getElementById('root') || document.createElement('div'); if (import.meta.vitest) { const { it, expect } = import.meta.vitest; it('It also works when the root element that the component draws is a component.', () => { render(, testWrap); expect(testWrap.outerHTML).toBe( '
  • count1: 0
  • ' ); }); it('Value updates work correctly when the root element drawn by the component is a component.', () => { if (testChangeRef.value) { testChangeRef.value(); } nextTick().then(() => { expect(testWrap.outerHTML).toBe( '
  • count1: 1
  • ' ); }); }); it('The root element drawn by a component behaves normally when it is not a component.', () => { const testWrap = document.getElementById('root') || document.createElement('div'); render(, testWrap); expect(testWrap.outerHTML).toBe( '
  • count1: 0
  • ' ); }); } else { render(, testWrap); }