mirror of
https://github.com/samsonjs/strftime.git
synced 2026-04-27 14:57:37 +00:00
add some tests
This commit is contained in:
parent
86e8bbf431
commit
644bb65577
1 changed files with 36 additions and 0 deletions
36
test/test.coffee
Normal file
36
test/test.coffee
Normal 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)}"
|
||||||
|
|
||||||
Loading…
Reference in a new issue