diff --git a/test/parallel/test-eventtarget.js b/test/parallel/test-eventtarget.js index 1e505cc7c48e5a..9487c22e26d1af 100644 --- a/test/parallel/test-eventtarget.js +++ b/test/parallel/test-eventtarget.js @@ -56,6 +56,21 @@ let asyncTest = Promise.resolve(); ev.preventDefault(); strictEqual(ev.defaultPrevented, false); } +{ + [ + 'foo', + 1, + false, + function() {}, + ].forEach((i) => ( + throws(() => new Event('foo', i), { + code: 'ERR_INVALID_ARG_TYPE', + name: 'TypeError', + message: 'The "options" argument must be of type object.' + + common.invalidArgTypeHelper(i) + }) + )); +} { const ev = new Event('foo'); strictEqual(ev.cancelBubble, false); @@ -221,31 +236,33 @@ let asyncTest = Promise.resolve(); false ].forEach((i) => { throws(() => target.dispatchEvent(i), { - code: 'ERR_INVALID_ARG_TYPE' + code: 'ERR_INVALID_ARG_TYPE', + name: 'TypeError', + message: 'The "event" argument must be an instance of Event.' + + common.invalidArgTypeHelper(i) }); }); + const err = (arg) => ({ + code: 'ERR_INVALID_ARG_TYPE', + name: 'TypeError', + message: 'The "listener" argument must be an instance of EventListener.' + + common.invalidArgTypeHelper(arg) + }); + [ 'foo', 1, {}, // No handleEvent function - false, - ].forEach((i) => { - throws(() => target.addEventListener('foo', i), { - code: 'ERR_INVALID_ARG_TYPE' - }); - }); + false + ].forEach((i) => throws(() => target.addEventListener('foo', i), err(i))); [ 'foo', 1, {}, // No handleEvent function false - ].forEach((i) => { - throws(() => target.removeEventListener('foo', i), { - code: 'ERR_INVALID_ARG_TYPE' - }); - }); + ].forEach((i) => throws(() => target.addEventListener('foo', i), err(i))); } {