node/test/parallel/test-http2-util-assert-valid-pseudoheader.js
James M Snell e94d16daf2
http2: throw from mapToHeaders
PR-URL: https://github.com/nodejs/node/pull/24063
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Note: Landed with one collaborator approval after PR
      was open for 18 days
2018-11-21 08:57:56 -08:00

24 lines
711 B
JavaScript

// Flags: --expose-internals
'use strict';
const common = require('../common');
// Tests the assertValidPseudoHeader function that is used within the
// mapToHeaders function. The assert function is not exported so we
// have to test it through mapToHeaders
const { mapToHeaders } = require('internal/http2/util');
// These should not throw
mapToHeaders({ ':status': 'a' });
mapToHeaders({ ':path': 'a' });
mapToHeaders({ ':authority': 'a' });
mapToHeaders({ ':scheme': 'a' });
mapToHeaders({ ':method': 'a' });
common.expectsError(() => mapToHeaders({ ':foo': 'a' }), {
code: 'ERR_HTTP2_INVALID_PSEUDOHEADER',
type: TypeError,
message: '":foo" is an invalid pseudoheader or is used incorrectly'
});