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

29 lines
558 B

export default {
data: {
items: ['foo', 'bar', 'baz'],
},
html: `
<button>foo</button>
<button>bar</button>
<button>baz</button>
`,
test(assert, component, target, window) {
const buttons = target.querySelectorAll('button');
const event = new window.MouseEvent('click');
const clicked = [];
component.on('clicked', event => {
clicked.push(event.node);
});
buttons[1].dispatchEvent(event);
assert.equal(clicked.length, 1);
assert.equal(clicked[0].nodeName, 'BUTTON');
assert.equal(clicked[0].textContent, 'bar');
}
};