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
611 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

export default {
test({ assert, component, 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);
}
};