-
Notifications
You must be signed in to change notification settings - Fork 29.1k
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
test: added tests for unixtimestamp generation #11886
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
require('../common'); | ||
var assert = require('assert'); | ||
var fs = require('fs'); | ||
|
||
[undefined, null, {}, []].forEach((input) => throws(input)); | ||
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. You could probably just inline |
||
|
||
function throws(input) { | ||
assert.throws(() => fs._toUnixTimestamp(input) | ||
, 'Error: Cannot parse time: ' + input); | ||
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. The second argument here should be either the type of error thrown or a check function. You can use 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. Alternatively, make this second argument a regex... 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. @jasnell I guess the regex is going to fit better...let me push the change 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. Can you make the second argument a regular expression (with |
||
} | ||
|
||
[1, '1', Date.now()].forEach((input) => { | ||
assert.doesNotThrow(() => fs._toUnixTimestamp(input)); | ||
}); |
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.
s/var/const