Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: validate EventEmitterAsyncResource methods throw on invalid this
  • Loading branch information
kuriyosh committed Feb 19, 2022
commit a237d8d775cad28d6414055af72616ef17082ed8
27 changes: 27 additions & 0 deletions test/parallel/test-eventemitter-asyncresource.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const {
const {
deepStrictEqual,
strictEqual,
throws,
} = require('assert');

const {
Expand Down Expand Up @@ -130,3 +131,29 @@ function makeHook(trackedTypes) {
],
]));
})().then(common.mustCall());

// Member methods ERR_INVALID_THIS
throws(
() => EventEmitterAsyncResource.prototype.emit(),
{ code: 'ERR_INVALID_THIS' }
);

throws(
() => EventEmitterAsyncResource.prototype.emitDestroy(),
{ code: 'ERR_INVALID_THIS' }
);

throws(
() => Reflect.get(EventEmitterAsyncResource.prototype, 'asyncId', {}),
{ code: 'ERR_INVALID_THIS' }
);

throws(
() => Reflect.get(EventEmitterAsyncResource.prototype, 'triggerAsyncId', {}),
{ code: 'ERR_INVALID_THIS' }
);

throws(
() => Reflect.get(EventEmitterAsyncResource.prototype, 'asyncResource', {}),
{ code: 'ERR_INVALID_THIS' }
);