// example.jsx import type { Renew } from '@/index'; import { h, Fragment, render, mount, ref, nextTick, updateCallback, } from '@/index'; const testChangeRef = ref void)>(null); const Renew = mount((renew, _props) => { let count1 = 0; let count2 = 0; let count3 = 0; let count4 = 0; const el = ref(null); const change = () => { count1 += 1; renew(); count2 += 2; renew(); count3 += 3; renew(); count4 -= 1; renew(); renew(); renew(); renew(); }; testChangeRef.value = change; updateCallback(() => { console.log('UPDATE'); return () => { console.log('UPDATED'); }; }); return () => (
  • count1: {count1}
  • count2: {count2}
  • count3: {count3}
  • count4: {count4}
  • ); }); const testWrap = document.getElementById('root') || document.createElement('div'); render(, testWrap); if (import.meta.vitest) { const { it, expect } = import.meta.vitest; it('Is renew working properly?', () => { expect(testWrap.outerHTML).toBe( '
  • count1: 0
  • count2: 0
  • count3: 0
  • count4: 0
  • ' ); if (testChangeRef.value) { testChangeRef.value(); testChangeRef.value(); testChangeRef.value(); } nextTick().then(() => { expect(testWrap.outerHTML).toBe( '
  • count1: 3
  • count2: 6
  • count3: 9
  • count4: -3
  • ' ); }); }); }