import { mount, render, Fragment, ref, h, nextTick } from '@/index'; const testChangeRef = ref void)>(null); const Loop = mount(function (renew) { let list: { value: string }[] = [ { value: '일' }, { value: '이' }, { value: '삼' }, { value: '사' }, ]; const handle = () => { list = [{ value: '사사' }, { value: '삼삼' }, { value: '이이' }]; renew(); }; testChangeRef.value = () => { handle(); }; return () => (
first
{list.map(item => (
{item.value}
))}
end
); }); const testWrap = document.getElementById('root') || document.createElement('div'); render(, testWrap); if (import.meta.vitest) { const { it, expect } = import.meta.vitest; it('It should be reflected in the DOM exactly in the order of the loop initialization.', () => { expect(testWrap.outerHTML).toBe( '
first
일
이
삼
사
end
' ); }); it('Even if there are no keys in the loop, "replace" should be reflected correctly.', () => { if (testChangeRef.value) { testChangeRef.value(); } nextTick().then(() => { expect(testWrap.outerHTML).toBe( '
first
사사
삼삼
이이
end
' ); }); }); }