[#152,view/timeline][s]: more robust data parsing with tests - fixes #152.

* Also discover and fix "bug" re momentjs timezone calculation and toDate.
This commit is contained in:
Rufus Pollock
2012-06-10 12:35:39 +01:00
parent 3cdd1c278b
commit 75a6bbd80a
2 changed files with 40 additions and 4 deletions

View File

@@ -48,3 +48,23 @@ test('render etc', function () {
view.remove();
});
test('_parseDate', function () {
var dataset = Fixture.getDataset();
var view = new recline.View.Timeline({
model: dataset
});
var testData = [
[ '1st August 1914', '1914-08-01T00:00:00.000Z' ],
[ '1 August 1914', '1914-08-01T00:00:00.000Z' ],
[ 'August 1st 1914', '1914-08-01T00:00:00.000Z' ],
[ '1914-08-01', '1914-08-01T00:00:00.000Z' ],
[ '1914-08-01T08:00', '1914-08-01T08:00:00.000Z' ],
[ 'afdaf afdaf', null ]
];
_.each(testData, function(item) {
var out = view._parseDate(item[0]);
if (out) out = out.toISOString();
equal(out, item[1]);
});
});