chore: better test case

closes #10129
pull/10134/head
Simon Holthausen 10 months ago
parent c05e94f26e
commit f3265c580c

@ -1,5 +1,37 @@
import { flushSync } from 'svelte';
import { test } from '../../test';
export default test({
html: `1 1`
html: `<button>false</button><button>false</button><button>false</button><button>false</button>`,
test({ assert, target }) {
const [button1, button2, button3, button4] = target.querySelectorAll('button');
button1.click();
flushSync();
assert.htmlEqual(
target.innerHTML,
`<button>true</button><button>false</button><button>false</button><button>false</button>`
);
button2.click();
flushSync();
assert.htmlEqual(
target.innerHTML,
`<button>true</button><button>true</button><button>false</button><button>false</button>`
);
button3.click();
flushSync();
assert.htmlEqual(
target.innerHTML,
`<button>true</button><button>true</button><button>true</button><button>false</button>`
);
button4.click();
flushSync();
assert.htmlEqual(
target.innerHTML,
`<button>true</button><button>true</button><button>true</button><button>true</button>`
);
}
});

@ -1,12 +1,15 @@
<script>
let button = { title: '', label: '' };
let title = '';
let label = '';
title = label = '1'; // to add dependencies/generate update block
$: button.title = title;
$: button.label = label;
let array;
$: {
// test that this doesn't rerun on array change
array = []
array[0] = [false, false];
array[1] = [false, false];
}
</script>
{button.title} {button.label}
{#each array as row, i}
{#each row as item, j}
<button on:click={() => array[i][j] = !array[i][j]}>{item}</button>
{/each}
{/each}

Loading…
Cancel
Save