forked from moment/moment
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
var moment = require('../../moment'); | ||
|
||
exports.add = { | ||
setUp : function (done) { | ||
moment.createFromInputFallback = function () { | ||
throw new Error('input not handled by moment'); | ||
}; | ||
done(); | ||
}, | ||
|
||
'isDate recognizes Date objects' : function (test) { | ||
test.ok(moment.isDate(new Date()), 'no args (now)'); | ||
test.ok(moment.isDate(new Date([2014, 02, 15])), 'array args'); | ||
test.ok(moment.isDate(new Date('2014-03-15')), 'string args'); | ||
test.ok(moment.isDate(new Date('does NOT look like a date')), 'invalid date'); | ||
test.done(); | ||
}, | ||
|
||
'isDate rejects non-Date objects' : function (test) { | ||
test.ok(!moment.isDate(), 'nothing'); | ||
test.ok(!moment.isDate(undefined), 'undefined'); | ||
test.ok(!moment.isDate(null), 'string args'); | ||
test.ok(!moment.isDate(42), 'number'); | ||
test.ok(!moment.isDate('2014-03-15'), 'string'); | ||
test.ok(!moment.isDate([2014, 2, 15]), 'array'); | ||
test.ok(!moment.isDate({year: 2014, month: 2, day: 15}), 'object'); | ||
test.ok(!moment.isDate({toString: function () { | ||
return '[object Date]'; | ||
}}), 'lying object'); | ||
test.done(); | ||
} | ||
}; |