mirror of https://github.com/BTCPrivate/copay.git
add tests for node
This commit is contained in:
parent
0481cf8e02
commit
8b5e616668
|
@ -195,6 +195,8 @@ Insight.prototype._requestNode = function(options, callback) {
|
||||||
return callback(e, ret);
|
return callback(e, ret);
|
||||||
});
|
});
|
||||||
response.on('error', function(e) {
|
response.on('error', function(e) {
|
||||||
|
|
||||||
|
console.log('[Insight.js.201]'); //TODO
|
||||||
return callback(e, ret);
|
return callback(e, ret);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -58,7 +58,10 @@ describe('Insight model', function() {
|
||||||
var i = new Insight();
|
var i = new Insight();
|
||||||
should.exist(i);
|
should.exist(i);
|
||||||
});
|
});
|
||||||
it.skip('should return array of unspent output', function(done) {
|
|
||||||
|
// Tests for Node
|
||||||
|
if (process.version) {
|
||||||
|
it('should return array of unspent output', function(done) {
|
||||||
var i = new Insight();
|
var i = new Insight();
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,9 +72,7 @@ describe('Insight model', function() {
|
||||||
|
|
||||||
request.on = function(event, cb) {
|
request.on = function(event, cb) {
|
||||||
if (event === 'error') return;
|
if (event === 'error') return;
|
||||||
if (event === 'data') return {
|
if (event === 'data') return cb(JSON.stringify(unspent));
|
||||||
hola: 'chau'
|
|
||||||
};
|
|
||||||
return cb();
|
return cb();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -87,12 +88,13 @@ describe('Insight model', function() {
|
||||||
|
|
||||||
i.getUnspent(['2MuD5LnZSViZZYwZbpVsagwrH8WWvCztdmV', '2NBSLoMvsHsf2Uv3LA17zV4beH6Gze6RovA'], function(e, ret) {
|
i.getUnspent(['2MuD5LnZSViZZYwZbpVsagwrH8WWvCztdmV', '2NBSLoMvsHsf2Uv3LA17zV4beH6Gze6RovA'], function(e, ret) {
|
||||||
should.not.exist(e);
|
should.not.exist(e);
|
||||||
should.exist(ret);
|
ret.should.deep.equal(unspent);
|
||||||
|
http.request.restore();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it.skip('should return txid', function(done) {
|
it('should return txid', function(done) {
|
||||||
var i = new Insight();
|
var i = new Insight();
|
||||||
|
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
|
@ -102,9 +104,7 @@ describe('Insight model', function() {
|
||||||
|
|
||||||
request.on = function(event, cb) {
|
request.on = function(event, cb) {
|
||||||
if (event === 'error') return;
|
if (event === 'error') return;
|
||||||
if (event === 'data') return {
|
if (event === 'data') return cb('{ "txid": "1234" }');
|
||||||
hola: 'chau'
|
|
||||||
};
|
|
||||||
return cb();
|
return cb();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -112,10 +112,17 @@ describe('Insight model', function() {
|
||||||
req.write = function() {};
|
req.write = function() {};
|
||||||
req.end = function() {};
|
req.end = function() {};
|
||||||
|
|
||||||
|
sinon
|
||||||
|
.stub(http, 'request')
|
||||||
|
.returns(req)
|
||||||
|
.yields(request);
|
||||||
|
|
||||||
i.sendRawTransaction(rawtx, function(a) {
|
i.sendRawTransaction(rawtx, function(a) {
|
||||||
should.exist(a);
|
should.exist(a);
|
||||||
|
a.should.equal('1234');
|
||||||
|
http.request.restore();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue