From ab9c2df11befd2f8e9f61a16a6fb7da43fbddbc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9?= Date: Tue, 1 Nov 2022 15:15:41 -0500 Subject: [PATCH] test: make `test-eventemitter-asyncresource.js` shorter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juan José Arboleda PR-URL: https://github.com/nodejs/node/pull/45146 Reviewed-By: Luigi Pinca Reviewed-By: Gerhard Stöbich Reviewed-By: James M Snell --- .../test-eventemitter-asyncresource.js | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/test/parallel/test-eventemitter-asyncresource.js b/test/parallel/test-eventemitter-asyncresource.js index 4cd2bc69207219..8290cdee1f20fb 100644 --- a/test/parallel/test-eventemitter-asyncresource.js +++ b/test/parallel/test-eventemitter-asyncresource.js @@ -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}`) + } + ); +});