From e8999e37b60935ccf9718530264acc59438bca3a Mon Sep 17 00:00:00 2001 From: Louis Chatriot Date: Sat, 25 May 2013 10:54:54 +0200 Subject: [PATCH] Tested database loading --- test/db.test.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/test/db.test.js b/test/db.test.js index 675cd35..7c26cd1 100644 --- a/test/db.test.js +++ b/test/db.test.js @@ -7,6 +7,7 @@ var Datastore = require('../lib/datastore') , assert = require('chai').assert , _ = require('underscore') , async = require('async') + , model = require('../lib/model') ; @@ -35,10 +36,20 @@ describe('Database', function () { }); - describe('Loading the database data from file', function () { + describe.only('Loading the database data from file', function () { it('Every line represents a document', function () { - // TODO + var now = new Date() + , rawData = model.serialize({a: 2, ages: [1, 5, 12]}) + '\n' + + model.serialize({hello: 'world'}) + '\n' + + model.serialize({nested: { today: now }}) + , treatedData = Datastore.treatRawData(rawData) + ; + + treatedData.length.should.equal(3); + _.isEqual(treatedData[0], { a: 2, ages: [1, 5, 12] }).should.equal(true); + _.isEqual(treatedData[1], { hello: 'world' }).should.equal(true); + _.isEqual(treatedData[2], { nested: { today: now } }).should.equal(true); }); }); // ==== End of 'Loading the database data from file' ==== //