From f5e0dfa58d8b2a4e06fa9e7055563ebc29abb8c4 Mon Sep 17 00:00:00 2001 From: ssotomayor Date: Mon, 20 Oct 2014 12:55:18 -0300 Subject: [PATCH] PluginManager coverage tests. --- js/models/PluginManager.js | 7 ++++++- test/Identity.js | 9 +++++++++ test/mocks/FakeLocalStorage.js | 5 +++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/js/models/PluginManager.js b/js/models/PluginManager.js index e13de65d4..2a2788b61 100644 --- a/js/models/PluginManager.js +++ b/js/models/PluginManager.js @@ -13,7 +13,12 @@ function PluginManager(config) { continue; log.info('Loading plugin: ' + pluginName); - var pluginClass = require('../plugins/' + pluginName); + var pluginClass; + if(config.pluginsPath){ + pluginClass = require(config.pluginsPath + pluginName); + } else { + pluginClass = require('../plugins/' + pluginName); + } var pluginObj = new pluginClass(config[pluginName]); pluginObj.init(); this._register(pluginObj, pluginName); diff --git a/test/Identity.js b/test/Identity.js index a7f055f9b..ea5e2d8e1 100644 --- a/test/Identity.js +++ b/test/Identity.js @@ -4,6 +4,7 @@ var _ = require('underscore'); var chai = chai || require('chai'); var should = chai.should(); +var PluginManager = require('../js/models/PluginManager'); var FakeBlockchain = requireMock('FakeBlockchain'); @@ -411,6 +412,14 @@ describe('Identity model', function() { }); }); + + describe('#pluginManager', function() { + it('should create a new PluginManager object', function() { + var pm = sinon.stub().returns(new PluginManager({plugins: { FakeLocalStorage: true }, pluginsPath: '../../test/mocks/'})); + should.exist(pm); + }); + }); + describe('#joinWallet', function() { var opts = { secret: '8WtTuiFTkhP5ao7AF2QErSwV39Cbur6pdMebKzQXFqL59RscXM', diff --git a/test/mocks/FakeLocalStorage.js b/test/mocks/FakeLocalStorage.js index 7af20d569..b3714412e 100644 --- a/test/mocks/FakeLocalStorage.js +++ b/test/mocks/FakeLocalStorage.js @@ -2,7 +2,12 @@ function FakeLocalStorage() { this.ls = {}; + this.type = 'DB'; }; + +FakeLocalStorage.prototype.init = function() { +}; + FakeLocalStorage.prototype.removeItem = function(key, cb) { delete this.ls[key]; cb();