add some tests

This commit is contained in:
Andrew Schaaf 2011-06-07 15:09:19 -04:00
parent 86e8bbf431
commit 644bb65577

36
test/test.coffee Normal file
View file

@ -0,0 +1,36 @@
assert = require 'assert'
lib = require './../lib'
# Tue, 07 Jun 2011 18:51:45 GMT
t = new Date 1307472705867
TESTS = [
["%Y", "2011", "2011"]
["%m", "06"]
["%b", "Jun", "Jun"]
["%B", "June", "June"]
["%d", null, "07"]
["%H", null, "18"]
["%M", "51", "51"]
["%S", "45", "45"]
["%s", "1307472705"]
]
for [format, expectedNonUTC, expectedUTC] in TESTS
expectedUTC or= expectedNonUTC
for [name, expected] in [['strftime', expectedNonUTC], ['strftimeUTC', expectedUTC]]
if expected
got = lib[name] format, t
assert.equal expected, got, "Error for #{name}(#{JSON.stringify(format)}, t): expected #{JSON.stringify(expected)}, got #{JSON.stringify(got)}"