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/event-handler-each-context-.../_config.js

36 lines
717 B

export default {
html: `
<button>off</button>
<button>on</button>
<button>off</button>
<p>on: 1</p>
`,
async test({ assert, component, target, window }) {
const buttons = target.querySelectorAll('button');
const event = new window.MouseEvent('click');
await buttons[0].dispatchEvent(event);
assert.htmlEqual(target.innerHTML, `
<button>on</button>
<button>on</button>
<button>off</button>
<p>on: 2</p>
`);
await buttons[2].dispatchEvent(event);
assert.htmlEqual(target.innerHTML, `
<button>on</button>
<button>on</button>
<button>on</button>
<p>on: 3</p>
`);
assert.deepEqual(component.switches, [
{ on: true },
{ on: true },
{ on: true }
]);
}
};