node/test/parallel/test-http2-util-asserts.js
Jordan Harband 757c104147
tools: add prefer-proto rule
fixup: add support for `Object.create(null)`

fixup: extend to any 1-argument Object.create call

fixup: add tests
PR-URL: https://github.com/nodejs/node/pull/46083
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-01-10 05:38:36 +00:00

46 lines
913 B
JavaScript

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