Skip to content

Commit

Permalink
test: write tests for assertIsArray http2 util
Browse files Browse the repository at this point in the history
PR-URL: #52511
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
  • Loading branch information
sinansonmez authored Apr 15, 2024
1 parent 0debfa4 commit 1703ab5
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion test/parallel/test-http2-misc-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const assert = require('assert');
const {
assertIsObject,
assertWithinRange,
sessionName
sessionName,
assertIsArray
} = require('internal/http2/util');

// Code coverage for sessionName utility function
Expand Down Expand Up @@ -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');

0 comments on commit 1703ab5

Please sign in to comment.