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

29 lines
694 B

export default {
html: `<button>undef</button>
<button>null</button>
<button>invalid</button>`,
async test({ assert, target, window }) {
const [buttonUndef, buttonNull, buttonInvalid] = target.querySelectorAll(
'button'
);
const event = new window.MouseEvent('click');
let err = '';
window.addEventListener('error', (e) => {
e.preventDefault();
err = e.message;
});
// All three should not throw if proper checking is done in runtime code
await buttonUndef.dispatchEvent(event);
assert.equal(err, '', err);
await buttonNull.dispatchEvent(event);
assert.equal(err, '', err);
await buttonInvalid.dispatchEvent(event);
assert.equal(err, '', err);
}
};