From d4bb88eed8a6cd48eda5c564d58a547a3078c6c5 Mon Sep 17 00:00:00 2001 From: himself65 Date: Wed, 5 Jun 2019 13:29:12 +0800 Subject: [PATCH] test: simplify tests code PR-URL: https://github.com/nodejs/node/pull/28065 Reviewed-By: Colin Ihrig Reviewed-By: Yongsheng Zhang Reviewed-By: Ruben Bridgewater Reviewed-By: Richard Lau Reviewed-By: Trivikram Kamat Reviewed-By: Rich Trott --- test/parallel/test-accessor-properties.js | 29 +++++++---------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/test/parallel/test-accessor-properties.js b/test/parallel/test-accessor-properties.js index 463118593ff2a3..cbd3ed65bb9dfb 100644 --- a/test/parallel/test-accessor-properties.js +++ b/test/parallel/test-accessor-properties.js @@ -33,27 +33,16 @@ const UDP = internalBinding('udp_wrap').UDP; }, TypeError); const StreamWrapProto = Object.getPrototypeOf(TTY.prototype); + const properties = ['bytesRead', 'fd', '_externalStream']; - // Should not throw for Object.getOwnPropertyDescriptor - assert.strictEqual( - typeof Object.getOwnPropertyDescriptor(StreamWrapProto, 'bytesRead'), - 'object' - ); - - assert.strictEqual( - typeof Object.getOwnPropertyDescriptor(StreamWrapProto, 'fd'), - 'object' - ); - - assert.strictEqual( - typeof Object.getOwnPropertyDescriptor(StreamWrapProto, '_externalStream'), - 'object' - ); - - assert.strictEqual( - typeof Object.getOwnPropertyDescriptor(StreamWrapProto, 'fd'), - 'object' - ); + properties.forEach((property) => { + // Should not throw for Object.getOwnPropertyDescriptor + assert.strictEqual( + typeof Object.getOwnPropertyDescriptor(StreamWrapProto, property), + 'object', + 'typeof property descriptor ' + property + ' is not \'object\'' + ); + }); if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check // There are accessor properties in crypto too