import { h, Fragment, render, mount, ref, nextTick } from 'lithent'; import { computed } from '@/index'; const testChangeRef = ref void)>(null); const Component = mount(renew => { let count = 1; const increase = () => { count += 1; renew(); }; testChangeRef.value = increase; const result = computed(() => [1, 3, 5, 7, 9].reduce( (accumulator, current) => accumulator + current * count, 0 ) ); return () => ( <> computed: {result.v} ); }); 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( '
computed: 25
' ); if (testChangeRef.value) { testChangeRef.value(); testChangeRef.value(); testChangeRef.value(); } nextTick().then(() => { expect(testWrap.outerHTML).toBe( '
computed: 100
' ); }); }); }