Skip to content

Commit

Permalink
test: use test runner in eventtarget-once-twice test
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander “weej” Jones <[email protected]>
  • Loading branch information
alexweej committed Nov 6, 2024
1 parent 6f12f1e commit 11edaea
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions test/parallel/test-eventtarget-once-twice.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
'use strict';
const common = require('../common');
const { once } = require('events');

const et = new EventTarget();
(async function() {
await once(et, 'foo');
await once(et, 'foo');
})().then(common.mustCall());

et.dispatchEvent(new Event('foo'));
setImmediate(() => {
et.dispatchEvent(new Event('foo'));
});
const assert = require('node:assert/strict');
const { once } = require('node:events');
const { test } = require('node:test');
const { setImmediate } = require('node:timers/promises');

test('should resolve `once` twice', (t, done) => {

const et = new EventTarget();

(async () => {
await once(et, 'foo');
await once(et, 'foo');
done();
})();

(async () => {
et.dispatchEvent(new Event('foo'));
await setImmediate();
et.dispatchEvent(new Event('foo'));
})();

});

0 comments on commit 11edaea

Please sign in to comment.