1// Flags: --expose-internals 2'use strict'; 3 4const common = require('../common'); 5if (!common.hasCrypto) 6 common.skip('missing crypto'); 7const assert = require('assert'); 8 9const { 10 assertIsObject, 11 assertWithinRange, 12 sessionName 13} = require('internal/http2/util'); 14 15// Code coverage for sessionName utility function 16assert.strictEqual(sessionName(0), 'server'); 17assert.strictEqual(sessionName(1), 'client'); 18[2, '', 'test', {}, [], true].forEach((i) => { 19 assert.strictEqual(sessionName(2), '<invalid>'); 20}); 21 22// Code coverage for assertWithinRange function 23assert.throws( 24 () => assertWithinRange('test', -1), 25 { 26 code: 'ERR_HTTP2_INVALID_SETTING_VALUE', 27 name: 'RangeError', 28 message: 'Invalid value for setting "test": -1' 29 }); 30 31assertWithinRange('test', 1); 32 33assert.throws( 34 () => assertIsObject('foo', 'test'), 35 { 36 code: 'ERR_INVALID_ARG_TYPE', 37 name: 'TypeError', 38 message: 'The "test" argument must be of type object. Received ' + 39 "type string ('foo')" 40 }); 41 42assert.throws( 43 () => assertIsObject('foo', 'test', ['Date']), 44 { 45 code: 'ERR_INVALID_ARG_TYPE', 46 name: 'TypeError', 47 message: 'The "test" argument must be an instance of Date. Received type ' + 48 "string ('foo')" 49 }); 50 51assertIsObject({}, 'test'); 52