You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/binding-input-group-each-6/_config.js

88 lines
2.9 KiB

export default {
html: `
<label><input type="checkbox" value="x"> x</label>
<label><input type="checkbox" value="y"> y</label>
<label><input type="checkbox" value="z"> z</label>
<p></p>
<label><input type="checkbox" value="x"> x</label>
<label><input type="checkbox" value="y"> y</label>
<label><input type="checkbox" value="z"> z</label>
<p></p>
<label><input type="checkbox" value="x"> x</label>
<label><input type="checkbox" value="y"> y</label>
<label><input type="checkbox" value="z"> z</label>
<p></p>
`,
async test({ assert, component, target, window }) {
const inputs = target.querySelectorAll('input');
assert.equal(inputs[0].checked, false);
assert.equal(inputs[1].checked, false);
assert.equal(inputs[2].checked, false);
assert.equal(inputs[3].checked, false);
assert.equal(inputs[4].checked, false);
assert.equal(inputs[5].checked, false);
assert.equal(inputs[6].checked, false);
assert.equal(inputs[7].checked, false);
assert.equal(inputs[8].checked, false);
const event = new window.Event('change');
inputs[2].checked = true;
await inputs[2].dispatchEvent(event);
assert.htmlEqual(target.innerHTML, `
<label><input type="checkbox" value="x"> x</label>
<label><input type="checkbox" value="y"> y</label>
<label><input type="checkbox" value="z"> z</label>
<p>z</p>
<label><input type="checkbox" value="x"> x</label>
<label><input type="checkbox" value="y"> y</label>
<label><input type="checkbox" value="z"> z</label>
<p></p>
<label><input type="checkbox" value="x"> x</label>
<label><input type="checkbox" value="y"> y</label>
<label><input type="checkbox" value="z"> z</label>
<p></p>
`);
inputs[4].checked = true;
await inputs[4].dispatchEvent(event);
assert.htmlEqual(target.innerHTML, `
<label><input type="checkbox" value="x"> x</label>
<label><input type="checkbox" value="y"> y</label>
<label><input type="checkbox" value="z"> z</label>
<p>z</p>
<label><input type="checkbox" value="x"> x</label>
<label><input type="checkbox" value="y"> y</label>
<label><input type="checkbox" value="z"> z</label>
<p>y</p>
<label><input type="checkbox" value="x"> x</label>
<label><input type="checkbox" value="y"> y</label>
<label><input type="checkbox" value="z"> z</label>
<p></p>
`);
inputs[5].checked = true;
await inputs[5].dispatchEvent(event);
assert.htmlEqual(target.innerHTML, `
<label><input type="checkbox" value="x"> x</label>
<label><input type="checkbox" value="y"> y</label>
<label><input type="checkbox" value="z"> z</label>
<p>z</p>
<label><input type="checkbox" value="x"> x</label>
<label><input type="checkbox" value="y"> y</label>
<label><input type="checkbox" value="z"> z</label>
<p>y, z</p>
<label><input type="checkbox" value="x"> x</label>
<label><input type="checkbox" value="y"> y</label>
<label><input type="checkbox" value="z"> z</label>
<p></p>
`);
}
};