From 30ea061afb54717ba737e5f65ac56b96630310bd Mon Sep 17 00:00:00 2001 From: Oky Antoro Date: Fri, 11 Aug 2017 22:30:03 +0700 Subject: [PATCH 1/3] test: add case to test-http-methods.js Add more case to check existence of DELETE and PUT methods. Refs: https://github.com/nodejs/node/issues/14544 --- test/parallel/test-http-methods.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/parallel/test-http-methods.js b/test/parallel/test-http-methods.js index 9d00d8598d10f8..71dd6fc33effcf 100644 --- a/test/parallel/test-http-methods.js +++ b/test/parallel/test-http-methods.js @@ -27,7 +27,9 @@ const util = require('util'); assert(Array.isArray(http.METHODS)); assert(http.METHODS.length > 0); +assert(http.METHODS.includes('DELETE')); assert(http.METHODS.includes('GET')); assert(http.METHODS.includes('HEAD')); assert(http.METHODS.includes('POST')); +assert(http.METHODS.includes('PUT')); assert.deepStrictEqual(util._extend([], http.METHODS), http.METHODS.sort()); From cde2aa89170925a0827a71b0a71212469188d9aa Mon Sep 17 00:00:00 2001 From: Oky Antoro Date: Sat, 12 Aug 2017 01:02:10 +0700 Subject: [PATCH 2/3] test: cover all http methods in HTTP parser --- test/parallel/test-http-methods.js | 47 +++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-http-methods.js b/test/parallel/test-http-methods.js index 71dd6fc33effcf..d52e41b4154fc4 100644 --- a/test/parallel/test-http-methods.js +++ b/test/parallel/test-http-methods.js @@ -23,13 +23,46 @@ require('../common'); const assert = require('assert'); const http = require('http'); -const util = require('util'); +// This test ensures all http methods from HTTP parser are exposed +// to http library + +var methods = [ + 'DELETE', + 'GET', + 'HEAD', + 'POST', + 'PUT', + 'CONNECT', + 'OPTIONS', + 'TRACE', + 'COPY', + 'LOCK', + 'MKCOL', + 'MOVE', + 'PROPFIND', + 'PROPPATCH', + 'SEARCH', + 'UNLOCK', + 'BIND', + 'REBIND', + 'UNBIND', + 'ACL', + 'REPORT', + 'MKACTIVITY', + 'CHECKOUT', + 'MERGE', + 'M-SEARCH', + 'NOTIFY', + 'SUBSCRIBE', + 'UNSUBSCRIBE', + 'PATCH', + 'PURGE', + 'MKCALENDAR', + 'LINK', + 'UNLINK' +]; assert(Array.isArray(http.METHODS)); assert(http.METHODS.length > 0); -assert(http.METHODS.includes('DELETE')); -assert(http.METHODS.includes('GET')); -assert(http.METHODS.includes('HEAD')); -assert(http.METHODS.includes('POST')); -assert(http.METHODS.includes('PUT')); -assert.deepStrictEqual(util._extend([], http.METHODS), http.METHODS.sort()); +assert.equal(methods.length, http.METHODS.length); +assert.deepStrictEqual(methods.sort(), http.METHODS.sort()); From aaf36d2b57121cb5cc3187cb7773e3b43b84b6df Mon Sep 17 00:00:00 2001 From: Oky Antoro Date: Sat, 12 Aug 2017 07:47:16 +0700 Subject: [PATCH 3/3] test: remove redundant test case in test-http-methods.js --- test/parallel/test-http-methods.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-http-methods.js b/test/parallel/test-http-methods.js index d52e41b4154fc4..cd62a77e1fd096 100644 --- a/test/parallel/test-http-methods.js +++ b/test/parallel/test-http-methods.js @@ -27,7 +27,7 @@ const http = require('http'); // This test ensures all http methods from HTTP parser are exposed // to http library -var methods = [ +const methods = [ 'DELETE', 'GET', 'HEAD', @@ -62,7 +62,5 @@ var methods = [ 'LINK', 'UNLINK' ]; -assert(Array.isArray(http.METHODS)); -assert(http.METHODS.length > 0); -assert.equal(methods.length, http.METHODS.length); -assert.deepStrictEqual(methods.sort(), http.METHODS.sort()); + +assert.deepStrictEqual(http.METHODS, methods.sort());