test IIFE support

Jack Goodall 2 months ago
parent 59a96c9a97
commit c8294cc632

@ -5,14 +5,9 @@ export default test({
async test({ assert, target, logs }) {
const checkboxes = target.querySelectorAll('input');
// input.value = '2';
// input.dispatchEvent(new window.Event('input'));
flushSync();
assert.htmlEqual(target.innerHTML, `<input type="checkbox" >`.repeat(4));
// assert.deepEqual(logs, ['b', '2', 'a', '2']);
assert.htmlEqual(target.innerHTML, `<input type="checkbox" >`.repeat(checkboxes.length));
flushSync(() => {
checkboxes.forEach((checkbox) => checkbox.click());
@ -20,12 +15,12 @@ export default test({
assert.deepEqual(logs, [
'getArrayBindings',
'getObjectBindings',
...repeatArray(4, ['check', false])
...repeatArray(checkboxes.length, ['check', false])
]);
}
});
/** @template T */
function repeatArray(/** @type {number} */ times = 1, /** @type {T[]} */ array) {
function repeatArray(/** @type {number} */ times, /** @type {T[]} */ array) {
return /** @type {T[]} */ Array.from({ length: times }, () => array).flat();
}

@ -28,4 +28,6 @@
<input type="checkbox" bind:checked={...getArrayBindings()} />
<input type="checkbox" bind:checked={...(() => check_bindings)()} />
<input type="checkbox" bind:checked={...getObjectBindings()} />

Loading…
Cancel
Save