Skip to content

Commit e34e0a9

Browse files
sinansonmezaduh95
authored andcommitted
test: write tests for assertIsArray http2 util
PR-URL: #52511 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent 15c5686 commit e34e0a9

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

test/parallel/test-http2-misc-util.js

+30-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const assert = require('assert');
99
const {
1010
assertIsObject,
1111
assertWithinRange,
12-
sessionName
12+
sessionName,
13+
assertIsArray
1314
} = require('internal/http2/util');
1415

1516
// Code coverage for sessionName utility function
@@ -49,3 +50,31 @@ assert.throws(
4950
});
5051

5152
assertIsObject({}, 'test');
53+
54+
assert.throws(
55+
() => assertIsArray('foo', 'test'), {
56+
code: 'ERR_INVALID_ARG_TYPE',
57+
name: 'TypeError',
58+
message: 'The "test" argument must be an instance of Array. Received type ' +
59+
"string ('foo')"
60+
}
61+
);
62+
63+
assert.throws(
64+
() => assertIsArray({}, 'test'), {
65+
code: 'ERR_INVALID_ARG_TYPE',
66+
name: 'TypeError',
67+
message: 'The "test" argument must be an instance of Array. Received an instance of Object'
68+
}
69+
);
70+
71+
assert.throws(
72+
() => assertIsArray(1, 'test'), {
73+
code: 'ERR_INVALID_ARG_TYPE',
74+
name: 'TypeError',
75+
message: 'The "test" argument must be an instance of Array. Received type ' +
76+
'number (1)'
77+
}
78+
);
79+
80+
assertIsArray([], 'test');

0 commit comments

Comments
 (0)