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

35 lines
723 B

export default {
props: {
foo: [1],
bar: [2],
clicked: 'neither'
},
html: `
<button>foo</button>
<button>bar</button>
<p>clicked: neither</p>
`,
async test({ assert, component, target, window }) {
const buttons = target.querySelectorAll('button');
const event = new window.MouseEvent('click');
await buttons[0].dispatchEvent(event);
assert.equal(component.clicked, 'foo');
assert.htmlEqual(target.innerHTML, `
<button>foo</button>
<button>bar</button>
<p>clicked: foo</p>
`);
await buttons[1].dispatchEvent(event);
assert.equal(component.clicked, 'bar');
assert.htmlEqual(target.innerHTML, `
<button>foo</button>
<button>bar</button>
<p>clicked: bar</p>
`);
}
};