Skip to content

Commit

Permalink
test: validate EventEmitterAsyncResource methods throw on invalid this
Browse files Browse the repository at this point in the history
  • Loading branch information
kuriyosh committed Feb 19, 2022
1 parent 82f6b0c commit a237d8d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/parallel/test-eventemitter-asyncresource.js
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' }
);

0 comments on commit a237d8d

Please sign in to comment.