Tests improvements
This commit is contained in:
parent
8992fe2ea5
commit
f245ba8022
2 changed files with 16 additions and 20 deletions
|
|
@ -327,11 +327,8 @@ describe('RateService model', function() {
|
||||||
rs.isAvailable = sinon.stub().returns(false);
|
rs.isAvailable = sinon.stub().returns(false);
|
||||||
(function() {
|
(function() {
|
||||||
rs.listAlternatives();
|
rs.listAlternatives();
|
||||||
}).should.throw('not available');;
|
}).should.throw('not available');
|
||||||
|
|
||||||
rs.getAlternatives();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return list of available currencies', function() {
|
it('should return list of available currencies', function() {
|
||||||
var rs = new RateService();
|
var rs = new RateService();
|
||||||
rs.isAvailable = sinon.stub().returns(true);
|
rs.isAvailable = sinon.stub().returns(true);
|
||||||
|
|
@ -348,32 +345,24 @@ describe('RateService model', function() {
|
||||||
var list = rs.listAlternatives();
|
var list = rs.listAlternatives();
|
||||||
list.should.exist;
|
list.should.exist;
|
||||||
list.length.should.equal(2);
|
list.length.should.equal(2);
|
||||||
|
|
||||||
list = rs.getAlternatives();
|
|
||||||
list.should.exist;
|
|
||||||
list.length.should.equal(2);
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
it('should return an error when trying to get the list of available currencies', function() {
|
describe('#getAlternatives', function() {
|
||||||
|
it('should return nothing when trying to get the list of available currencies', function() {
|
||||||
var rs = new RateService();
|
var rs = new RateService();
|
||||||
rs.isAvailable = sinon.stub().returns(true);
|
|
||||||
rs.whenAvailable(function() {});
|
|
||||||
rs.isAvailable = sinon.stub().returns(false);
|
rs.isAvailable = sinon.stub().returns(false);
|
||||||
rs.whenAvailable(function() {});
|
rs.whenAvailable(function() {});
|
||||||
|
|
||||||
rs.getAlternatives().length.should.equal(0);
|
rs.getAlternatives().length.should.equal(0);
|
||||||
|
|
||||||
(function() {
|
|
||||||
rs.listAlternatives();
|
|
||||||
}).should.throw;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
describe('#singleton', function() {
|
describe('#singleton', function() {
|
||||||
it('should create only one instance', function() {
|
it('should create only one instance', function() {
|
||||||
var rs = RateService.singleton();
|
var rs = RateService.singleton();
|
||||||
rs.should.be.not.null;
|
rs.should.be.not.null;
|
||||||
rs = RateService.singleton();
|
var rs2 = RateService.singleton();
|
||||||
rs.should.be.not.null;
|
rs2.should.be.not.null;
|
||||||
|
rs.should.deep.equal(rs2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -203,6 +203,7 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
sinon.spy(w, 'sendIndexes');
|
sinon.spy(w, 'sendIndexes');
|
||||||
sinon.spy(w, 'sendTxProposal');
|
sinon.spy(w, 'sendTxProposal');
|
||||||
|
|
||||||
w.spend({
|
w.spend({
|
||||||
toAddress: toAddress,
|
toAddress: toAddress,
|
||||||
amountSat: amountSatStr,
|
amountSat: amountSatStr,
|
||||||
|
|
@ -213,6 +214,9 @@ describe('Wallet model', function() {
|
||||||
w.sendTxProposal.calledOnce.should.equal(true);
|
w.sendTxProposal.calledOnce.should.equal(true);
|
||||||
w.sendIndexes.calledOnce.should.equal(false);
|
w.sendIndexes.calledOnce.should.equal(false);
|
||||||
|
|
||||||
|
w.network.send.calledOnce.should.equal(true);
|
||||||
|
|
||||||
|
|
||||||
var p = w.getPendingTxProposalsCount();
|
var p = w.getPendingTxProposalsCount();
|
||||||
p.pending.should.be.equal(1);
|
p.pending.should.be.equal(1);
|
||||||
p.pendingForUs.should.be.equal(0);
|
p.pendingForUs.should.be.equal(0);
|
||||||
|
|
@ -766,13 +770,16 @@ describe('Wallet model', function() {
|
||||||
|
|
||||||
it('should close wallet', function(done) {
|
it('should close wallet', function(done) {
|
||||||
var w = createW2();
|
var w = createW2();
|
||||||
w.removeAllListeners = sinon.stub();
|
|
||||||
w.network.removeAllListeners = sinon.stub();
|
w.network.removeAllListeners = sinon.stub();
|
||||||
w.network.cleanUp = sinon.stub();
|
w.network.cleanUp = sinon.stub();
|
||||||
w.blockchain.removeAllListeners = sinon.stub();
|
w.blockchain.removeAllListeners = sinon.stub();
|
||||||
w.blockchain.destroy = sinon.stub();
|
w.blockchain.destroy = sinon.stub();
|
||||||
|
|
||||||
w.close(function() {
|
w.close(function() {
|
||||||
|
w.network.removeAllListeners.calledOnce.should.equal(true);
|
||||||
|
w.network.cleanUp.calledOnce.should.equal(true);
|
||||||
|
w.blockchain.removeAllListeners.calledOnce.should.equal(true);
|
||||||
|
w.network.cleanUp.calledOnce.should.equal(true);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue