From 08909646e0006fac2a6403279f1a27f89ca4ba83 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 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. --- .../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); + } +);