From 076c2c2c541b34aa81c4cb572a5743abc333ec97 Mon Sep 17 00:00:00 2001 From: Ashton Kinslow Date: Thu, 1 Dec 2016 15:12:39 -0600 Subject: [PATCH] test: test for http.request() invalid method error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a test for when an invalid http method is passed into http.request() to verify an error is thrown, that the error is the correct type, and the error message is correct. PR-URL: https://github.com/nodejs/node/pull/10080 Reviewed-By: Matteo Collina Reviewed-By: Evan Lucas Reviewed-By: Colin Ihrig Reviewed-By: Michaƫl Zasso --- .../test-http-request-invalid-method-error.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 test/parallel/test-http-request-invalid-method-error.js diff --git a/test/parallel/test-http-request-invalid-method-error.js b/test/parallel/test-http-request-invalid-method-error.js new file mode 100644 index 00000000000000..febb340eacd2a4 --- /dev/null +++ b/test/parallel/test-http-request-invalid-method-error.js @@ -0,0 +1,12 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const http = require('http'); + +assert.throws( + () => { http.request({method: '\0'}); }, + (error) => { + return (error instanceof TypeError) && + /Method must be a valid HTTP token/.test(error); + } +);