import { h, Fragment, render, mount, ref, nextTick } from '@/index'; const testChangeRef = ref void)>(null); const Nested = mount(function (r) { let choiceNode = 7; const shuffle = () => { const randomValue = Math.floor(Math.random() * 10) + 1; choiceNode = randomValue; r(); }; testChangeRef.value = (changeValue: number) => { choiceNode = changeValue; r(); }; return () => ( {choiceNode === 1 &&
1
} {choiceNode === 2 &&
2
} {choiceNode === 3 &&
3
} {choiceNode === 4 &&
4
} {choiceNode === 5 &&
5
} {choiceNode === 6 &&
6
}
6.5
{choiceNode === 7 &&
7
}
{choiceNode === 8 &&
8
} {choiceNode === 9 &&
9
}
{choiceNode === 10 &&
10
}
11
); }); const testWrap = document.getElementById('root') || document.createElement('div'); render(, testWrap); if (import.meta.vitest) { const { it, expect } = import.meta.vitest; it('The initial value of 7 should be exposed in the correct order.', () => { expect(testWrap.outerHTML).toBe( '
6.5
7
11
' ); }); it('If you change the value to 2, the original value of 7 should disappear and 2 should come to the front in the proper order.', () => { if (testChangeRef.value) { testChangeRef.value(2); } nextTick().then(() => { expect(testWrap.outerHTML).toBe( '
2
6.5
11
' ); }); }); }