From 392fb8586b87370c22b35f9f134dcd7619ccb3c0 Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Wed, 2 Jul 2014 10:44:20 -0300 Subject: [PATCH] Fix tests and increase coverage of them --- test/test.Wallet.js | 4 +--- test/test.WalletFactory.js | 9 ++++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/test/test.Wallet.js b/test/test.Wallet.js index c50434f49..20dd4b6ba 100644 --- a/test/test.Wallet.js +++ b/test/test.Wallet.js @@ -735,15 +735,13 @@ describe('Wallet model', function() { }); }); - it('#updateIndexes should store and emit event', function(done) { + it('#updateIndexes should store wallet', function(done) { mockFakeActivity(function(index) { return index <= 14 && index % 2 == 0; }); var spyStore = sinon.spy(w, 'store'); - var spyEmit = sinon.spy(w, 'emit'); w.updateIndexes(function(err) { sinon.assert.callCount(spyStore, 1); - sinon.assert.callCount(spyEmit, 2); done(); }); }); diff --git a/test/test.WalletFactory.js b/test/test.WalletFactory.js index 1201d6824..cbc165b67 100644 --- a/test/test.WalletFactory.js +++ b/test/test.WalletFactory.js @@ -109,13 +109,16 @@ describe('WalletFactory model', function() { var wf = new WalletFactory(config, '0.0.1'); var wallet = {id: "fake wallet", updateIndexes: function(cb) { cb(); }}; wf.fromEncryptedObj = sinon.stub().returns(wallet); - var callback = sinon.spy(); - var w = wf.import("encrypted", "password", callback); + var w = wf.import("encrypted", "password"); should.exist(w); wallet.should.equal(w); - sinon.assert.callCount(callback, 1); + + wf.fromEncryptedObj = sinon.stub().returns(null); + (function() { + wf.import("encrypted", "password") + }).should.throw(); }); it('BIP32 length problem', function() {