From 7ae643847883dfd8530276de59eab3df6b1d6f1a Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Thu, 19 Jun 2014 11:03:31 -0700 Subject: [PATCH] add tests for Wallet --- js/models/core/Wallet.js | 6 +++--- test/test.Wallet.js | 45 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index aa5cd6155..f0e94993d 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -233,11 +233,11 @@ Wallet.prototype.getCopayerId = function(index) { Wallet.prototype.getMyCopayerId = function() { - return this.getCopayerId(0); + return this.getCopayerId(0); //copayer id is hex of a public key }; Wallet.prototype.getMyCopayerIdPriv = function() { - return this.privateKey.getIdPriv(); + return this.privateKey.getIdPriv(); //copayer idpriv is hex of a private key }; @@ -260,7 +260,7 @@ Wallet.prototype._lockIncomming = function() { this.network.lockIncommingConnections(this.publicKeyRing.getAllCopayerIds()); }; -Wallet.prototype.netStart = function() { +Wallet.prototype.netStart = function(callback) { var self = this; var net = this.network; net.removeAllListeners(); diff --git a/test/test.Wallet.js b/test/test.Wallet.js index 5af27914f..4c89a54b4 100644 --- a/test/test.Wallet.js +++ b/test/test.Wallet.js @@ -755,4 +755,49 @@ describe('Wallet model', function() { Object.keys(w.addressBook).length.should.equal(3); }); + it('#getNetworkName', function() { + var w = createW(); + w.getNetworkName().should.equal('testnet'); + }); + + describe('#getMyCopayerId', function() { + it('should call getCopayerId', function() { + //this.timeout(10000); + var w = createW2(); + w.getCopayerId = sinon.spy(); + w.getMyCopayerId(); + w.getCopayerId.calledOnce.should.equal(true); + }); + }); + + describe('#getMyCopayerIdPriv', function() { + it('should call privateKey.getIdPriv', function() { + //this.timeout(10000); + var w = createW2(); + w.privateKey.getIdPriv = sinon.spy(); + w.getMyCopayerIdPriv(); + w.privateKey.getIdPriv.calledOnce.should.equal(true); + }); + }); + + describe('#netStart', function() { + + it('should call Network.start', function() { + //this.timeout(10000); + var w = createW2(); + w.network.start = sinon.spy(); + w.netStart(); + w.network.start.calledOnce.should.equal(true); + }); + + it('should call Network.start with a private key', function() { + //this.timeout(10000); + var w = createW2(); + w.network.start = sinon.spy(); + w.netStart(); + w.network.start.getCall(0).args[0].privkey.length.should.equal(64); + }); + + }); + });