Browse Source

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.

PR-URL: https://github.com/nodejs/node/pull/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>
v6
Ashton Kinslow 8 years ago
committed by Michaël Zasso
parent
commit
c5ccc50d1f
  1. 12
      test/parallel/test-http-request-invalid-method-error.js

12
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);
}
);
Loading…
Cancel
Save