From cf0b1b4df120c29232e1c0f6859a80640ebf5137 Mon Sep 17 00:00:00 2001 From: Esteban Ordano Date: Thu, 23 Oct 2014 17:26:32 -0300 Subject: [PATCH] Mocha tests fixed --- js/models/Identity.js | 38 +++++++++++++++++++++++--------------- plugins/GoogleDrive.js | 6 ------ test/Identity.js | 8 ++++---- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/js/models/Identity.js b/js/models/Identity.js index 6f65cdc8c..064b6b5ad 100644 --- a/js/models/Identity.js +++ b/js/models/Identity.js @@ -155,15 +155,19 @@ Identity.create = function(email, password, opts, cb) { if (err) { return cb(err); } - iden.pluginManager.get('remote-backup').store( - iden, - iden.insightSaveOpts, - function(error) { - // FIXME: Ignoring this error may not be the best thing to do. But remote storage - // is not required for the user to use the wallet. - return cb(null, iden, w); - } - ); + if (iden.pluginManager.get && iden.pluginManager.get('remote-backup')) { + iden.pluginManager.get('remote-backup').store( + iden, + iden.insightSaveOpts, + function(error) { + // FIXME: Ignoring this error may not be the best thing to do. But remote storage + // is not required for the user to use the wallet. + return cb(null, iden, w); + } + ); + } else { + return cb(null, iden, w); + } }); }); }; @@ -197,7 +201,11 @@ Identity.open = function(email, password, opts, cb) { Identity._openProfile(email, password, iden.storage, function(err, profile) { if (err) { if (err.message && err.message.indexOf('PNOTFOUND') !== -1) { - return opts.pluginManager.get('remote-backup').retrieve(email, password, opts, cb); + if (opts.pluginManager && opts.pluginManager.get('remote-backup')) { + return opts.pluginManager.get('remote-backup').retrieve(email, password, opts, cb); + } else { + return cb(err); + } } return cb(err); } @@ -492,11 +500,11 @@ Identity.prototype.createWallet = function(opts, cb) { this.addWallet(w, function(err) { if (err) return cb(err); self.openWallets.push(w); - self.pluginManager.get('remote-backup').store(self, self.insightSaveOpts, function(error) { - // Ignore error - w.netStart(); - return cb(null, w); - }); + if (self.pluginManager.get && self.pluginManager.get('remote-backup')) { + self.pluginManager.get('remote-backup').store(self, self.insightSaveOpts, _.noop); + } + w.netStart(); + return cb(null, w); }); }; diff --git a/plugins/GoogleDrive.js b/plugins/GoogleDrive.js index 00417cdd6..109fc2b8c 100644 --- a/plugins/GoogleDrive.js +++ b/plugins/GoogleDrive.js @@ -313,10 +313,4 @@ GoogleDrive.prototype.allKeys = function(cb) { }); }; -GoogleDrive.prototype.key = function(k) { - var v = localStorage.key(k); - return v; -}; - - module.exports = GoogleDrive; diff --git a/test/Identity.js b/test/Identity.js index 123fe024c..3169d1925 100644 --- a/test/Identity.js +++ b/test/Identity.js @@ -351,7 +351,7 @@ describe('Identity model', function() { }); it('should create an encrypted object', function() { - var ret = JSON.parse(iden.export()); + var ret = JSON.parse(iden.exportAsJson()); ret.iterations.should.equal(13); ret.profile.should.equal('penc'); _.each([0, 1, 2, 3, 4], function(i) { @@ -382,7 +382,7 @@ describe('Identity model', function() { it('should check the import string', function(done) { - Identity.import(JSON.stringify({ + Identity.importFromJson(JSON.stringify({ profile: '1234' }), '1234', config, function(err, ret) { err.should.contain('BADSTR'); @@ -392,7 +392,7 @@ describe('Identity model', function() { it('should check the import string 2', function(done) { - Identity.import(JSON.stringify({ + Identity.importFromJson(JSON.stringify({ iterations: 10, }), '1234', config, function(err, ret) { err.should.contain('BADSTR'); @@ -401,7 +401,7 @@ describe('Identity model', function() { }); it('should import a simple wallet', function(done) { - Identity.import(JSON.stringify({ + Identity.importFromJson(JSON.stringify({ iterations: 10, profile: '1234' }), '1234', config, function(err, iden) {