mirror of https://github.com/sveltejs/svelte
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.
90 lines
2.1 KiB
90 lines
2.1 KiB
// https://github.com/sveltejs/svelte/issues/6112
|
|
export default {
|
|
async test({ assert, target, component, window }) {
|
|
let inputs = target.querySelectorAll('input');
|
|
|
|
const check = (set) => {
|
|
for (let i = 0; i < inputs.length; i++) {
|
|
assert.equal(inputs[i].checked, set.has(i));
|
|
}
|
|
};
|
|
|
|
assert.htmlEqual(
|
|
target.innerHTML,
|
|
`
|
|
<div>1</div>
|
|
<div>2
|
|
<div class="arg">
|
|
<input type="checkbox" value="a">
|
|
<input type="checkbox" value="b">
|
|
</div>
|
|
<div class="arg">
|
|
<input type="checkbox" value="c">
|
|
<input type="checkbox" value="d">
|
|
</div>
|
|
</div>
|
|
<div>3
|
|
<div class="arg">
|
|
<input type="checkbox" value="a">
|
|
<input type="checkbox" value="b">
|
|
</div>
|
|
<div class="arg">
|
|
<input type="checkbox" value="c">
|
|
<input type="checkbox" value="d">
|
|
</div>
|
|
</div>
|
|
`
|
|
);
|
|
|
|
check(new Set([0, 2]));
|
|
|
|
const event = new window.Event('change');
|
|
|
|
// dom to value
|
|
inputs[3].checked = true;
|
|
await inputs[3].dispatchEvent(event);
|
|
|
|
check(new Set([0, 2, 3]));
|
|
assert.deepEqual(component.pipelineOperations[1].operation.args[1].value, ['c', 'd']);
|
|
|
|
// remove item
|
|
component.pipelineOperations = component.pipelineOperations.slice(1);
|
|
await Promise.resolve();
|
|
|
|
assert.htmlEqual(
|
|
target.innerHTML,
|
|
`
|
|
<div>2
|
|
<div class="arg">
|
|
<input type="checkbox" value="a">
|
|
<input type="checkbox" value="b">
|
|
</div>
|
|
<div class="arg">
|
|
<input type="checkbox" value="c">
|
|
<input type="checkbox" value="d">
|
|
</div>
|
|
</div>
|
|
<div>3
|
|
<div class="arg">
|
|
<input type="checkbox" value="a">
|
|
<input type="checkbox" value="b">
|
|
</div>
|
|
<div class="arg">
|
|
<input type="checkbox" value="c">
|
|
<input type="checkbox" value="d">
|
|
</div>
|
|
</div>
|
|
`
|
|
);
|
|
|
|
inputs = target.querySelectorAll('input');
|
|
check(new Set([0, 2, 3]));
|
|
|
|
inputs[5].checked = true;
|
|
await inputs[5].dispatchEvent(event);
|
|
|
|
check(new Set([0, 2, 3, 5]));
|
|
assert.deepEqual(component.pipelineOperations[1].operation.args[0].value, ['b']);
|
|
}
|
|
};
|