diff options
author | Weijia Wang <381152119@qq.com> | 2017-08-10 18:58:22 +0800 |
---|---|---|
committer | Refael Ackermann <refack@gmail.com> | 2017-08-14 17:19:19 -0400 |
commit | 11a2ca29babcb35132e7d93244b69c544d52dfe4 (patch) | |
tree | a7372ad1c4dfc4300d8a050c8f1fe3cccdadc3b4 /test/parallel/test-http-mutable-headers.js | |
parent | 28a47aa1bbd4d278293fda2bb3f2df836d743816 (diff) | |
download | android-node-v8-11a2ca29babcb35132e7d93244b69c544d52dfe4.tar.gz android-node-v8-11a2ca29babcb35132e7d93244b69c544d52dfe4.tar.bz2 android-node-v8-11a2ca29babcb35132e7d93244b69c544d52dfe4.zip |
errors: migrate _http_outgoing
PR-URL: https://github.com/nodejs/node/pull/14735
Refs: https://github.com/nodejs/node/issues/11273
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'test/parallel/test-http-mutable-headers.js')
-rw-r--r-- | test/parallel/test-http-mutable-headers.js | 73 |
1 files changed, 49 insertions, 24 deletions
diff --git a/test/parallel/test-http-mutable-headers.js b/test/parallel/test-http-mutable-headers.js index 63f4b4cad2..929a566caf 100644 --- a/test/parallel/test-http-mutable-headers.js +++ b/test/parallel/test-http-mutable-headers.js @@ -50,18 +50,38 @@ const s = http.createServer(common.mustCall((req, res) => { assert.deepStrictEqual(res.hasHeader('Connection'), false); assert.deepStrictEqual(res.getHeader('Connection'), undefined); - assert.throws(() => { - res.setHeader(); - }, /^TypeError: Header name must be a valid HTTP Token \["undefined"\]$/); - assert.throws(() => { - res.setHeader('someHeader'); - }, /^Error: "value" required in setHeader\("someHeader", value\)$/); - assert.throws(() => { - res.getHeader(); - }, /^TypeError: "name" argument must be a string$/); - assert.throws(() => { - res.removeHeader(); - }, /^TypeError: "name" argument must be a string$/); + common.expectsError( + () => res.setHeader(), + { + code: 'ERR_INVALID_HTTP_TOKEN', + type: TypeError, + message: 'Header name must be a valid HTTP token ["undefined"]' + } + ); + common.expectsError( + () => res.setHeader('someHeader'), + { + code: 'ERR_MISSING_ARGS', + type: TypeError, + message: 'The "value" argument must be specified' + } + ); + common.expectsError( + () => res.getHeader(), + { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: 'The "name" argument must be of type string' + } + ); + common.expectsError( + () => res.removeHeader(), + { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: 'The "name" argument must be of type string' + } + ); const arrayValues = [1, 2, 3]; res.setHeader('x-test-header', 'testing'); @@ -89,18 +109,23 @@ const s = http.createServer(common.mustCall((req, res) => { assert.strictEqual(res.hasHeader('x-test-header2'), true); assert.strictEqual(res.hasHeader('X-TEST-HEADER2'), true); assert.strictEqual(res.hasHeader('X-Test-Header2'), true); - assert.throws(() => { - res.hasHeader(); - }, /^TypeError: "name" argument must be a string$/); - assert.throws(() => { - res.hasHeader(null); - }, /^TypeError: "name" argument must be a string$/); - assert.throws(() => { - res.hasHeader(true); - }, /^TypeError: "name" argument must be a string$/); - assert.throws(() => { - res.hasHeader({ toString: () => 'X-TEST-HEADER2' }); - }, /^TypeError: "name" argument must be a string$/); + [ + undefined, + null, + true, + {}, + { toString: () => 'X-TEST-HEADER2' }, + () => { } + ].forEach((val) => { + common.expectsError( + () => res.hasHeader(val), + { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: 'The "name" argument must be of type string' + } + ); + }); res.removeHeader('x-test-header2'); |