Skip to content

Commit d5f4d98

Browse files
juanarbolRafaelGSS
authored andcommitted
test: make test-eventemitter-asyncresource.js shorter
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com> PR-URL: #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>
1 parent 5d48011 commit d5f4d98

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

test/parallel/test-eventemitter-asyncresource.js

+11-14
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,14 @@ throws(
143143
{ code: 'ERR_INVALID_THIS' }
144144
);
145145

146-
throws(
147-
() => Reflect.get(EventEmitterAsyncResource.prototype, 'asyncId', {}),
148-
{ code: 'ERR_INVALID_THIS' }
149-
);
150-
151-
throws(
152-
() => Reflect.get(EventEmitterAsyncResource.prototype, 'triggerAsyncId', {}),
153-
{ code: 'ERR_INVALID_THIS' }
154-
);
155-
156-
throws(
157-
() => Reflect.get(EventEmitterAsyncResource.prototype, 'asyncResource', {}),
158-
{ code: 'ERR_INVALID_THIS' }
159-
);
146+
['asyncId', 'triggerAsyncId', 'asyncResource'].forEach((getter) => {
147+
throws(
148+
() => Reflect.get(EventEmitterAsyncResource.prototype, getter, {}),
149+
{
150+
code: 'ERR_INVALID_THIS',
151+
name: /TypeError/,
152+
message: 'Value of "this" must be of type EventEmitterAsyncResource',
153+
stack: new RegExp(`at get ${getter}`)
154+
}
155+
);
156+
});

0 commit comments

Comments
 (0)