mirror of https://github.com/BTCPrivate/copay.git
Adding test for Identity
This commit is contained in:
parent
e415604870
commit
f7c1e3d4ab
|
@ -672,7 +672,7 @@ describe('Identity model', function() {
|
||||||
|
|
||||||
|
|
||||||
describe('add / delete / list Wallets', function() {
|
describe('add / delete / list Wallets', function() {
|
||||||
var iden, w;
|
var iden, w, w2;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
var storage = sinon.stub();
|
var storage = sinon.stub();
|
||||||
storage.setCredentials = sinon.stub();
|
storage.setCredentials = sinon.stub();
|
||||||
|
@ -699,6 +699,12 @@ describe('Identity model', function() {
|
||||||
getName: sinon.stub().returns('treintaydos'),
|
getName: sinon.stub().returns('treintaydos'),
|
||||||
close: sinon.stub(),
|
close: sinon.stub(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
w2 = {
|
||||||
|
getId: sinon.stub().returns('33'),
|
||||||
|
getName: sinon.stub().returns('treintaytres'),
|
||||||
|
close: sinon.stub(),
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add wallet', function() {
|
it('should add wallet', function() {
|
||||||
|
@ -710,6 +716,40 @@ describe('Identity model', function() {
|
||||||
return w.getName() == 'treintaydos';
|
return w.getName() == 'treintaydos';
|
||||||
}).should.deep.equal(w);
|
}).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() {
|
it('should not add same wallet twice', function() {
|
||||||
|
|
|
@ -548,6 +548,10 @@ describe('PublicKeyRing model', function() {
|
||||||
ret.pubKeys[1].length.should.equal(5);
|
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));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -382,9 +382,11 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
wallet.addressIsOwn('mmHqhvTVbxgJTnePa7cfweSRjBCy9bQQXJ').should.equal(false);
|
wallet.addressIsOwn('mmHqhvTVbxgJTnePa7cfweSRjBCy9bQQXJ').should.equal(false);
|
||||||
wallet.addressIsOwn('mgtUfP9sTJ6vPLoBxZLPEccGpcjNVryaCX').should.equal(false);
|
wallet.addressIsOwn('mgtUfP9sTJ6vPLoBxZLPEccGpcjNVryaCX').should.equal(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('#getAddressesOrdered', function() {
|
||||||
allAddresses = wallet.getAddressesOrdered();
|
var wallet = cachedCreateW2();
|
||||||
|
var allAddresses = wallet.getAddressesOrdered();
|
||||||
for (var i = 0; i < allAddresses.length; i++) {
|
for (var i = 0; i < allAddresses.length; i++) {
|
||||||
wallet.addressIsOwn(allAddresses[i]).should.equal(true);
|
wallet.addressIsOwn(allAddresses[i]).should.equal(true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue