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-duplica.../_config.js

82 lines
2.2 KiB

export default {
html: `
<p>Checked: </p>
<hr>
<input type='checkbox' value='a'>a<br>
<input type='checkbox' value='b'>b<br>
<input type='checkbox' value='c'>c<br>
<input type='checkbox' value='d'>d<br>
<hr>
<input type='checkbox' value='a'>a<br>
<input type='checkbox' value='b'>b<br>
<input type='checkbox' value='c'>c<br>
<input type='checkbox' value='d'>d<br>
`,
async test({ assert, component, target, window }) {
const inputs = target.querySelectorAll('input');
const p = target.querySelector('p');
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);
const event = new window.Event('change');
inputs[0].checked = true;
await inputs[0].dispatchEvent(event);
assert.htmlEqual(p.innerHTML, 'Checked: a');
assert.equal(inputs[0].checked, true);
assert.equal(inputs[1].checked, false);
assert.equal(inputs[2].checked, false);
assert.equal(inputs[3].checked, false);
assert.equal(inputs[4].checked, true);
assert.equal(inputs[5].checked, false);
assert.equal(inputs[6].checked, false);
assert.equal(inputs[7].checked, false);
inputs[3].checked = true;
await inputs[3].dispatchEvent(event);
assert.htmlEqual(p.innerHTML, 'Checked: a,d');
assert.equal(inputs[0].checked, true);
assert.equal(inputs[1].checked, false);
assert.equal(inputs[2].checked, false);
assert.equal(inputs[3].checked, true);
assert.equal(inputs[4].checked, true);
assert.equal(inputs[5].checked, false);
assert.equal(inputs[6].checked, false);
assert.equal(inputs[7].checked, true);
inputs[4].checked = false;
await inputs[4].dispatchEvent(event);
assert.htmlEqual(p.innerHTML, 'Checked: d');
assert.equal(inputs[0].checked, false);
assert.equal(inputs[1].checked, false);
assert.equal(inputs[2].checked, false);
assert.equal(inputs[3].checked, true);
assert.equal(inputs[4].checked, false);
assert.equal(inputs[5].checked, false);
assert.equal(inputs[6].checked, false);
assert.equal(inputs[7].checked, true);
}
};