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/each-block-keyed-bind-group/_config.js

66 lines
2.4 KiB

export default {
html: `
<label><input type="checkbox" value="Vanilla"> Vanilla</label>
<label><input type="checkbox" value="Strawberry"> Strawberry</label>
<label><input type="checkbox" value="Chocolate"> Chocolate</label>
<label><input type="checkbox" value="Lemon"> Lemon</label>
<label><input type="checkbox" value="Coconut"> Coconut</label>
`,
async test({ assert, target, window }) {
const [input1, input2, input3, input4, input5] = target.querySelectorAll('input');
const event = new window.Event('change');
input3.checked = true;
await input3.dispatchEvent(event);
assert.htmlEqual(target.innerHTML, `
<label><input type="checkbox" value="Chocolate"> Chocolate</label>
<label><input type="checkbox" value="Vanilla"> Vanilla</label>
<label><input type="checkbox" value="Strawberry"> Strawberry</label>
<label><input type="checkbox" value="Lemon"> Lemon</label>
<label><input type="checkbox" value="Coconut"> Coconut</label>
`);
assert.equal(input1.checked, false);
assert.equal(input2.checked, false);
assert.equal(input3.checked, true);
assert.equal(input4.checked, false);
assert.equal(input5.checked, false);
input4.checked = true;
await input4.dispatchEvent(event);
assert.htmlEqual(target.innerHTML, `
<label><input type="checkbox" value="Chocolate"> Chocolate</label>
<label><input type="checkbox" value="Lemon"> Lemon</label>
<label><input type="checkbox" value="Vanilla"> Vanilla</label>
<label><input type="checkbox" value="Strawberry"> Strawberry</label>
<label><input type="checkbox" value="Coconut"> Coconut</label>
`);
assert.equal(input1.checked, false);
assert.equal(input2.checked, false);
assert.equal(input3.checked, true);
assert.equal(input4.checked, true);
assert.equal(input5.checked, false);
input3.checked = false;
await input3.dispatchEvent(event);
assert.htmlEqual(target.innerHTML, `
<label><input type="checkbox" value="Lemon"> Lemon</label>
<label><input type="checkbox" value="Chocolate"> Chocolate</label>
<label><input type="checkbox" value="Vanilla"> Vanilla</label>
<label><input type="checkbox" value="Strawberry"> Strawberry</label>
<label><input type="checkbox" value="Coconut"> Coconut</label>
`);
assert.equal(input1.checked, false);
assert.equal(input2.checked, false);
assert.equal(input3.checked, false);
assert.equal(input4.checked, true);
assert.equal(input5.checked, false);
}
};