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

17 lines
600 B

export default {
test({ assert, target, window }) {
// Click events don't focus elements in JSDOM obviously they would
// in real browsers. More realistically, you'd use this for e.g.
// this.select(), but that's harder to test than this.focus()
const wont = target.querySelector('.wont-focus');
const will = target.querySelector('.will-focus');
wont.dispatchEvent(new window.MouseEvent('click'));
assert.equal(window.document.activeElement, window.document.body);
will.dispatchEvent(new window.MouseEvent('click'));
assert.equal(window.document.activeElement, will);
}
};