From 4ad159bb75e6f0c3677bab2a2654ee485fef721a Mon Sep 17 00:00:00 2001 From: "Sinan Sonmez (Chaush)" <37421564+sinansonmez@users.noreply.github.com> Date: Mon, 15 Apr 2024 10:55:21 +0200 Subject: [PATCH] test: write tests for assertIsArray http2 util PR-URL: https://github.com/nodejs/node/pull/52511 Reviewed-By: Yagiz Nizipli Reviewed-By: Luigi Pinca Reviewed-By: Benjamin Gruenbaum --- test/parallel/test-http2-misc-util.js | 31 ++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-http2-misc-util.js b/test/parallel/test-http2-misc-util.js index 53eed542e2a605..d2416afab1c85b 100644 --- a/test/parallel/test-http2-misc-util.js +++ b/test/parallel/test-http2-misc-util.js @@ -9,7 +9,8 @@ const assert = require('assert'); const { assertIsObject, assertWithinRange, - sessionName + sessionName, + assertIsArray } = require('internal/http2/util'); // Code coverage for sessionName utility function @@ -49,3 +50,31 @@ assert.throws( }); assertIsObject({}, 'test'); + +assert.throws( + () => assertIsArray('foo', 'test'), { + code: 'ERR_INVALID_ARG_TYPE', + name: 'TypeError', + message: 'The "test" argument must be an instance of Array. Received type ' + + "string ('foo')" + } +); + +assert.throws( + () => assertIsArray({}, 'test'), { + code: 'ERR_INVALID_ARG_TYPE', + name: 'TypeError', + message: 'The "test" argument must be an instance of Array. Received an instance of Object' + } +); + +assert.throws( + () => assertIsArray(1, 'test'), { + code: 'ERR_INVALID_ARG_TYPE', + name: 'TypeError', + message: 'The "test" argument must be an instance of Array. Received type ' + + 'number (1)' + } +); + +assertIsArray([], 'test');