import { h, Fragment, render, mount, ref, nextTick } from '@/index'; const testChangeRef = ref void)>(null); const Depth2 = mount<{ count: number }>(() => ({ count }) => ( depth2: {count} )); const Depth1 = mount<{ count: number }>(() => ({ count }) => ( depth1: {count} )); const Root = mount(renew => { let count = 0; const toggle = () => { count += 1; renew(); }; testChangeRef.value = () => { toggle(); }; return () => ( ); }); const testWrap = document.getElementById('root') || document.createElement('div'); render(, testWrap); if (import.meta.vitest) { const { it, expect } = import.meta.vitest; it('Test that props are passed well to nested components.', () => { expect(testWrap.outerHTML).toBe( '
depth1: 0 depth2: 0
' ); }); it('If we receive a prop from a parent whose value has been incremented by 1, they will all be incremented by 1.', () => { if (testChangeRef.value) { testChangeRef.value(); } nextTick().then(() => { expect(testWrap.outerHTML).toBe( '
depth1: 1 depth2: 1
' ); }); }); it('Once again, if we are passed a prop whose value has been incremented by 1 from the parent, they will all be incremented by 1.', () => { if (testChangeRef.value) { testChangeRef.value(); } nextTick().then(() => { expect(testWrap.outerHTML).toBe( '
depth1: 2 depth2: 2
' ); }); }); }