28 lines
987 B
JavaScript
28 lines
987 B
JavaScript
// test/timing.test.js
|
|
window.testTiming = async function() {
|
|
const { ___unsafeRefreshState, Component, NewState, $, Util } = ApigoState;
|
|
console.log('Testing initialization timing...');
|
|
|
|
Component.register('TimingComp', container => {
|
|
container.state = NewState({ msg: 'Ready' });
|
|
}, Util.makeDom(`
|
|
<div id="timing-child">
|
|
<template $if="this.state?.msg">
|
|
<span id="timing-content" $text="this.state.msg"></span>
|
|
</template>
|
|
</div>
|
|
`));
|
|
|
|
document.body.innerHTML += `<TimingComp id="timing-inst"></TimingComp>`;
|
|
___unsafeRefreshState(document.documentElement);
|
|
|
|
await new Promise(r => setTimeout(r, 100));
|
|
|
|
const content = $('#timing-content');
|
|
if (!content) throw new Error('Component child failed to render content due to timing');
|
|
if (content.textContent !== 'Ready') throw new Error('Child content incorrect');
|
|
|
|
console.log('Timing tests passed');
|
|
return true;
|
|
}
|