Files
node/test/parallel/test-http2-util-asserts.js
Ruben Bridgewater 574d061c3c test: remove assert.doesNotThrow()
There is actually no reason to use `assert.doesNotThrow()` in the
tests. If a test throws, just let the error bubble up right away
instead of first catching it and then rethrowing it.

Backport-PR-URL: https://github.com/nodejs/node/pull/19244
PR-URL: https://github.com/nodejs/node/pull/18669
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-03-21 10:50:02 +00:00

43 lines
914 B
JavaScript

// Flags: --expose-internals
'use strict';
const common = require('../common');
const {
assertIsObject,
assertWithinRange,
} = require('internal/http2/util');
[
undefined,
{},
Object.create(null),
new Date(),
new (class Foo {})()
].forEach((i) => {
assertIsObject(i, 'foo', 'Object');
});
[
1,
false,
'hello',
NaN,
Infinity,
[],
[{}]
].forEach((i) => {
common.expectsError(() => assertIsObject(i, 'foo', 'Object'),
{
code: 'ERR_INVALID_ARG_TYPE',
message: /^The "foo" argument must be of type Object$/
});
});
assertWithinRange('foo', 1, 0, 2);
common.expectsError(() => assertWithinRange('foo', 1, 2, 3),
{
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
message: /^Invalid value for setting "foo": 1$/
});