From d8a226673bd9621a5a07346f8702d7dac2f25481 Mon Sep 17 00:00:00 2001 From: Anatoli Papirovski Date: Wed, 20 Sep 2017 08:22:49 -0400 Subject: [PATCH] test: expand http2 util test coverage for headers Expand existing test cases to hit some additional branches of toHeaderObject and mapToHeaders. PR-URL: https://github.com/nodejs/node/pull/15493 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater --- test/parallel/test-http2-cookies.js | 3 ++- test/parallel/test-http2-util-headers-list.js | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-http2-cookies.js b/test/parallel/test-http2-cookies.js index 3e20a5749d..b2f0a3bf6c 100644 --- a/test/parallel/test-http2-cookies.js +++ b/test/parallel/test-http2-cookies.js @@ -11,7 +11,8 @@ const server = h2.createServer(); const setCookie = [ 'a=b', - 'c=d; Wed, 21 Oct 2015 07:28:00 GMT; Secure; HttpOnly' + 'c=d; Wed, 21 Oct 2015 07:28:00 GMT; Secure; HttpOnly', + 'e=f' ]; // we use the lower-level API here diff --git a/test/parallel/test-http2-util-headers-list.js b/test/parallel/test-http2-util-headers-list.js index 8d665120c1..7e6bb7ece2 100644 --- a/test/parallel/test-http2-util-headers-list.js +++ b/test/parallel/test-http2-util-headers-list.js @@ -261,4 +261,10 @@ const regex = })(mapToHeaders({ [name]: 'abc' })); }); +common.expectsError({ + code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS', + message: regex +})(mapToHeaders({ [HTTP2_HEADER_TE]: ['abc'] })); + assert(!(mapToHeaders({ te: 'trailers' }) instanceof Error)); +assert(!(mapToHeaders({ te: ['trailers'] }) instanceof Error));