File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Flags: --expose-internals
2
+ 'use strict' ;
3
+
4
+ const common = require ( '../common' ) ;
5
+
6
+ // Tests the assertValidPseudoHeader function that is used within the
7
+ // mapToHeaders function. The assert function is not exported so we
8
+ // have to test it through mapToHeaders
9
+
10
+ const { mapToHeaders } = require ( 'internal/http2/util' ) ;
11
+ const assert = require ( 'assert' ) ;
12
+
13
+ function isNotError ( val ) {
14
+ assert ( ! ( val instanceof Error ) ) ;
15
+ }
16
+
17
+ function isError ( val ) {
18
+ common . expectsError ( {
19
+ code : 'ERR_HTTP2_INVALID_PSEUDOHEADER' ,
20
+ type : Error ,
21
+ message : '":foo" is an invalid pseudoheader or is used incorrectly'
22
+ } ) ( val ) ;
23
+ }
24
+
25
+ isNotError ( mapToHeaders ( { ':status' : 'a' } ) ) ;
26
+ isNotError ( mapToHeaders ( { ':path' : 'a' } ) ) ;
27
+ isNotError ( mapToHeaders ( { ':authority' : 'a' } ) ) ;
28
+ isNotError ( mapToHeaders ( { ':scheme' : 'a' } ) ) ;
29
+ isNotError ( mapToHeaders ( { ':method' : 'a' } ) ) ;
30
+
31
+ isError ( mapToHeaders ( { ':foo' : 'a' } ) ) ;
You can’t perform that action at this time.
0 commit comments