-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
test: add case to test-http-methods.js #14773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check is now redundant, you may safely remove it. |
||
| 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); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is covered by the next assert statement, so I'd say this is redundant. By the way, please use |
||
| assert.deepStrictEqual(methods.sort(), http.METHODS.sort()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously this test asserted that the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aside from that, can you please swap the order of arguments here? According to the function's signature, first argument should be an actual value and second one an expected value. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: use
const