test: make test-eventemitter-asyncresource.js shorter

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/45146
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Juan José
2022-11-01 15:15:41 -05:00
committed by GitHub
parent 5e74cb6076
commit 74d214761c

View File

@@ -143,17 +143,14 @@ throws(
{ 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' }
);
['asyncId', 'triggerAsyncId', 'asyncResource'].forEach((getter) => {
throws(
() => Reflect.get(EventEmitterAsyncResource.prototype, getter, {}),
{
code: 'ERR_INVALID_THIS',
name: /TypeError/,
message: 'Value of "this" must be of type EventEmitterAsyncResource',
stack: new RegExp(`at get ${getter}`)
}
);
});