1// Flags: --expose-internals 2'use strict'; 3 4require('../common'); 5const assert = require('assert'); 6 7// Tests the assertValidPseudoHeader function that is used within the 8// mapToHeaders function. The assert function is not exported so we 9// have to test it through mapToHeaders 10 11const { mapToHeaders } = require('internal/http2/util'); 12 13// These should not throw 14mapToHeaders({ ':status': 'a' }); 15mapToHeaders({ ':path': 'a' }); 16mapToHeaders({ ':authority': 'a' }); 17mapToHeaders({ ':scheme': 'a' }); 18mapToHeaders({ ':method': 'a' }); 19 20assert.throws(() => mapToHeaders({ ':foo': 'a' }), { 21 code: 'ERR_HTTP2_INVALID_PSEUDOHEADER', 22 name: 'TypeError', 23 message: '":foo" is an invalid pseudoheader or is used incorrectly' 24}); 25