mirror of https://github.com/BTCPrivate/copay.git
add stub to _request
This commit is contained in:
parent
1cb10219e9
commit
b9b09d5f11
|
@ -180,29 +180,20 @@ describe('Insight model', function() {
|
|||
});
|
||||
|
||||
|
||||
it('should handle getTransaction errors', function(done) {
|
||||
|
||||
var http = require('http');
|
||||
var request = {
|
||||
statusCode: 200
|
||||
};
|
||||
|
||||
request.on = function(event, cb) {
|
||||
if (event === 'error') return;
|
||||
if (event === 'data') return cb('{ "txid": "1234" }');
|
||||
return cb();
|
||||
};
|
||||
|
||||
var req = {};
|
||||
req.write = function() {};
|
||||
req.end = function() {};
|
||||
|
||||
sinon
|
||||
.stub(http, 'request')
|
||||
.returns(req)
|
||||
.yields(request);
|
||||
|
||||
it('should handle getTransaction null response', function(done) {
|
||||
var w = new Insight();
|
||||
w._request = sinon.stub().yields();
|
||||
w.getTransactions(['asdasd'], function(ret) {
|
||||
ret.length.should.equal(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
it('should handle getTransaction empty response', function(done) {
|
||||
var w = new Insight();
|
||||
w._request = sinon.stub().yields([]);
|
||||
w.getTransactions(['asdasd'], function(ret) {
|
||||
ret.length.should.equal(0);
|
||||
done();
|
||||
|
|
Loading…
Reference in New Issue