import { mount, render, Fragment, h, ref, nextTick } from '@/index'; const testChangeRef = ref void)>(null); const testChangeRef2 = ref void)>(null); const testChangeRef3 = ref void)>(null); const Loop = mount(function (renew) { let pType: boolean = true; const handle = () => { pType = false; renew(); }; testChangeRef.value = () => { handle(); }; return () => (
start
{pType ? (
1
2
3
4
) : (
two
three
four
)}
end
); }); const Loop2 = mount(function (renew) { let pType: boolean = true; const handle = () => { pType = false; renew(); }; testChangeRef2.value = () => { handle(); }; return () => (
start
{pType ? (
33
) : (
two
three
four
)}
end
); }); const Loop3 = mount(function (renew) { let pType: boolean = true; const handle = () => { pType = false; renew(); }; testChangeRef3.value = () => { handle(); }; return () => (
start
{pType ? ( '777abcss' ) : (
two
three
four
)}
end
); }); if (import.meta.vitest) { const { it, expect } = import.meta.vitest; it('typeReplace (fragment to fragment).', () => { const testWrap = document.createElement('div'); render(, testWrap); expect(testWrap.outerHTML).toBe( '
start
1
2
3
4
end
' ); if (testChangeRef.value) { testChangeRef.value(); } nextTick().then(() => { expect(testWrap.outerHTML).toBe( '
start
two
three
four
end
' ); }); }); it('typeReplace (element to fragment).', () => { const testWrap = document.createElement('div'); render(, testWrap); expect(testWrap.outerHTML).toBe( '
start
33
end
' ); if (testChangeRef2.value) { testChangeRef2.value(); } nextTick().then(() => { expect(testWrap.outerHTML).toBe( '
start
two
three
four
end
' ); }); }); it('typeReplace (text to fragment).', () => { const testWrap = document.createElement('div'); render(, testWrap); expect(testWrap.outerHTML).toBe( '
start
777abcss
end
' ); if (testChangeRef3.value) { testChangeRef3.value(); } nextTick().then(() => { expect(testWrap.outerHTML).toBe( '
start
two
three
four
end
' ); }); }); } else { render(, document.getElementById('root')); }