11cb0ef41Sopenharmony_ci// Flags: --expose-internals
21cb0ef41Sopenharmony_ci'use strict';
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ciconst common = require('../common');
51cb0ef41Sopenharmony_ciif (!common.hasCrypto)
61cb0ef41Sopenharmony_ci  common.skip('missing crypto');
71cb0ef41Sopenharmony_ciconst assert = require('assert');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciconst {
101cb0ef41Sopenharmony_ci  assertIsObject,
111cb0ef41Sopenharmony_ci  assertWithinRange,
121cb0ef41Sopenharmony_ci  sessionName
131cb0ef41Sopenharmony_ci} = require('internal/http2/util');
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci// Code coverage for sessionName utility function
161cb0ef41Sopenharmony_ciassert.strictEqual(sessionName(0), 'server');
171cb0ef41Sopenharmony_ciassert.strictEqual(sessionName(1), 'client');
181cb0ef41Sopenharmony_ci[2, '', 'test', {}, [], true].forEach((i) => {
191cb0ef41Sopenharmony_ci  assert.strictEqual(sessionName(2), '<invalid>');
201cb0ef41Sopenharmony_ci});
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci// Code coverage for assertWithinRange function
231cb0ef41Sopenharmony_ciassert.throws(
241cb0ef41Sopenharmony_ci  () => assertWithinRange('test', -1),
251cb0ef41Sopenharmony_ci  {
261cb0ef41Sopenharmony_ci    code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
271cb0ef41Sopenharmony_ci    name: 'RangeError',
281cb0ef41Sopenharmony_ci    message: 'Invalid value for setting "test": -1'
291cb0ef41Sopenharmony_ci  });
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ciassertWithinRange('test', 1);
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ciassert.throws(
341cb0ef41Sopenharmony_ci  () => assertIsObject('foo', 'test'),
351cb0ef41Sopenharmony_ci  {
361cb0ef41Sopenharmony_ci    code: 'ERR_INVALID_ARG_TYPE',
371cb0ef41Sopenharmony_ci    name: 'TypeError',
381cb0ef41Sopenharmony_ci    message: 'The "test" argument must be of type object. Received ' +
391cb0ef41Sopenharmony_ci             "type string ('foo')"
401cb0ef41Sopenharmony_ci  });
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ciassert.throws(
431cb0ef41Sopenharmony_ci  () => assertIsObject('foo', 'test', ['Date']),
441cb0ef41Sopenharmony_ci  {
451cb0ef41Sopenharmony_ci    code: 'ERR_INVALID_ARG_TYPE',
461cb0ef41Sopenharmony_ci    name: 'TypeError',
471cb0ef41Sopenharmony_ci    message: 'The "test" argument must be an instance of Date. Received type ' +
481cb0ef41Sopenharmony_ci             "string ('foo')"
491cb0ef41Sopenharmony_ci  });
501cb0ef41Sopenharmony_ci
511cb0ef41Sopenharmony_ciassertIsObject({}, 'test');
52