// 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,
`
1
`
);
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,
`
`
);
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']);
}
};