node/test/parallel/test-whatwg-events-customevent.js
Antoine du Hamel 2856475f3e
test: ensure assertions are reached on more tests
PR-URL: https://github.com/nodejs/node/pull/60634
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2025-11-15 13:16:37 +00:00

33 lines
737 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
// Manually converted from https://github.com/web-platform-tests/wpt/blob/master/dom/events/CustomEvent.html
// in order to define the `document` ourselves
{
const type = 'foo';
const target = new EventTarget();
target.addEventListener(type, common.mustCall((evt) => {
assert.strictEqual(evt.type, type);
}));
target.dispatchEvent(new Event(type));
}
{
assert.throws(() => {
new Event();
}, TypeError);
}
{
const event = new Event('foo');
assert.strictEqual(event.type, 'foo');
assert.strictEqual(event.bubbles, false);
assert.strictEqual(event.cancelable, false);
assert.strictEqual(event.detail, undefined);
}