Bugfixes: get the unit tests passing again

This commit is contained in:
Quentin Brandon
2015-03-20 18:35:53 +09:00
parent af69eddd1c
commit 435f4f320f
4 changed files with 20 additions and 11 deletions
+13 -6
View File
@@ -3,11 +3,13 @@ var vows = require('vows')
, assert = require('assert')
, dateFormat = require('../lib/date_format');
function createFixedDate() {
return new Date(2010, 0, 11, 14, 31, 30, 5);
}
vows.describe('date_format').addBatch({
'Date extensions': {
topic: function() {
return new Date(2010, 0, 11, 14, 31, 30, 5);
},
topic: createFixedDate,
'should format a date as string using a pattern': function(date) {
assert.equal(
dateFormat.asString(dateFormat.DATETIME_FORMAT, date),
@@ -20,13 +22,16 @@ vows.describe('date_format').addBatch({
'2010-01-11 14:31:30.005'
);
},
'should provide a ISO8601 with timezone offset format': function(date) {
'should provide a ISO8601 with timezone offset format': function() {
var date = createFixedDate();
date.setMinutes(date.getMinutes() - date.getTimezoneOffset() - 660);
date.getTimezoneOffset = function() { return -660; };
assert.equal(
dateFormat.asString(dateFormat.ISO8601_WITH_TZ_OFFSET_FORMAT, date),
"2010-01-11T14:31:30+1100"
);
date = createFixedDate();
date.setMinutes(date.getMinutes() - date.getTimezoneOffset() + 120);
date.getTimezoneOffset = function() { return 120; };
assert.equal(
dateFormat.asString(dateFormat.ISO8601_WITH_TZ_OFFSET_FORMAT, date),
@@ -40,7 +45,9 @@ vows.describe('date_format').addBatch({
'14:31:30.005'
);
},
'should provide a custom format': function(date) {
'should provide a custom format': function() {
var date = createFixedDate();
date.setMinutes(date.getMinutes() - date.getTimezoneOffset() + 120);
date.getTimezoneOffset = function() { return 120; };
assert.equal(
dateFormat.asString("O.SSS.ss.mm.hh.dd.MM.yy", date),