Adding test for Identity

This commit is contained in:
Matias Pando 2015-01-07 18:25:36 -03:00
parent e415604870
commit f7c1e3d4ab
3 changed files with 49 additions and 3 deletions

View File

@ -672,7 +672,7 @@ describe('Identity model', function() {
describe('add / delete / list Wallets', function() {
var iden, w;
var iden, w, w2;
beforeEach(function() {
var storage = sinon.stub();
storage.setCredentials = sinon.stub();
@ -699,6 +699,12 @@ describe('Identity model', function() {
getName: sinon.stub().returns('treintaydos'),
close: sinon.stub(),
};
w2 = {
getId: sinon.stub().returns('33'),
getName: sinon.stub().returns('treintaytres'),
close: sinon.stub(),
};
});
it('should add wallet', function() {
@ -710,6 +716,40 @@ describe('Identity model', function() {
return w.getName() == 'treintaydos';
}).should.deep.equal(w);
iden.addWallet(w2);
iden.getWalletById('33').getName().should.equal('treintaytres');
iden.walletIds.should.deep.equal(['32', '33']);
});
it('should read and bind wallet', function(done) {
iden.addWallet(w);
iden.storage.getItem = sinon.stub().yields(w, JSON.stringify(iden));
iden.readAndBindWallet('32', function(err) {
iden.getWalletById('32').getName().should.equal('treintaydos');
done();
});
});
it('should open wallet', function() {
iden.addWallet(w);
iden.storage.getItem = sinon.stub().yields(w, JSON.stringify(iden));
iden.readAndBindWallet = sinon.spy();
iden.openWallets();
iden.readAndBindWallet.should.calledOnce;
});
it('should open wallets', function() {
iden.addWallet(w);
iden.addWallet(w2);
iden.storage.getItem = sinon.stub().yields(w, JSON.stringify(iden));
iden.readAndBindWallet = sinon.spy();
iden.openWallets();
iden.walletIds.should.deep.equal(['32', '33']);
iden.readAndBindWallet.callCount.should.be.equal(1);
});
it('should not add same wallet twice', function() {

View File

@ -548,6 +548,10 @@ describe('PublicKeyRing model', function() {
ret.pubKeys[1].length.should.equal(5);
});
it('#myCopayerId should return first copayerId ', function() {
var w = getCachedW().w;
w.myCopayerId().should.be.equal(w.getCopayerId(0));
});
});

View File

@ -382,9 +382,11 @@ describe('Wallet model', function() {
wallet.addressIsOwn('mmHqhvTVbxgJTnePa7cfweSRjBCy9bQQXJ').should.equal(false);
wallet.addressIsOwn('mgtUfP9sTJ6vPLoBxZLPEccGpcjNVryaCX').should.equal(false);
});
allAddresses = wallet.getAddressesOrdered();
it('#getAddressesOrdered', function() {
var wallet = cachedCreateW2();
var allAddresses = wallet.getAddressesOrdered();
for (var i = 0; i < allAddresses.length; i++) {
wallet.addressIsOwn(allAddresses[i]).should.equal(true);
}