summaryrefslogtreecommitdiff
path: root/test/parallel/test-http2-util-assert-valid-pseudoheader.js
blob: b0d7ac0e58f1d5a1f9b1ac8309f4f1864eaa7aed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// 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'
});