node/test/parallel/test-http-request-invalid-method-error.js
Ashton Kinslow c5ccc50d1f 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>
2016-12-03 11:52:00 +01:00

13 lines
279 B
JavaScript

'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);
}
);