import { h, Fragment, render, mount, nextTick } from '@/index';
const Loop = mount(function () {
const list: { key: number; value: string }[] = [
{ key: 4, value: '4' },
{ key: 5, value: '5' },
{ key: 6, value: '6' },
{ key: 7, value: '7' },
];
return () => (
{list.map(item => (
{item.value}
))}
);
});
document.body.innerHTML =
'
';
const testWrap = document.getElementById('root') as HTMLElement;
const destroy = render(, testWrap, document.getElementById('next'));
if (import.meta.vitest) {
const { it, expect } = import.meta.vitest;
it("The 'destroy function' also works well when the loop type is stuck in the middle of the actual DOM.", () => {
setTimeout(() => {
expect(testWrap.outerHTML).toBe(
''
);
nextTick().then(() => {
it('The destroy function should work fine.', () => {
destroy();
expect(testWrap.outerHTML).toBe(
''
);
});
});
}, 100);
});
}