From 2e9afa73709f69086995bc05441bedbc190acf29 Mon Sep 17 00:00:00 2001 From: Remie Bolte Date: Sun, 20 Sep 2015 19:56:35 +0200 Subject: [PATCH] fixes #78 : Add UnitTests for modules Fixing unit tests for settings module, pushing settings changed does not work if settings.json does not exist --- test/modules/settings.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/modules/settings.test.js b/test/modules/settings.test.js index 415abfef..c960a0a3 100644 --- a/test/modules/settings.test.js +++ b/test/modules/settings.test.js @@ -54,10 +54,20 @@ describe('YouTransfer Settings module', function() { // -------------------------------------------------------------------------------------- Testing write it('should be possible to set title', function(done) { + + sandbox.stub(fs, 'readFile', function (file, encoding, callback) { + callback(null, JSON.stringify({})); + }); + + sandbox.stub(fs, 'writeFile', function (file, data, encoding, callback) { + callback(null); + }); + settings.push({ title: title }, function(err) { should.not.exist(err); done(); }); + }); it('should throw an error if it is not possible to read settings file', function(done) {