Skip to content

Commit

Permalink
test: test for http.request() invalid method error
Browse files Browse the repository at this point in the history
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: nodejs#10080
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
ashtonian authored and addaleax committed Dec 8, 2016
1 parent f38cb9b commit 076c2c2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/parallel/test-http-request-invalid-method-error.js
Original file line number Diff line number Diff line change
@@ -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);
}
);

0 comments on commit 076c2c2

Please sign in to comment.