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);
|
||||
});
|
||||
response.on('error', function(e) {
|
||||
|
||||
console.log('[Insight.js.201]'); //TODO
|
||||
return callback(e, ret);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -58,7 +58,10 @@ describe('Insight model', function() {
|
|||
var i = new Insight();
|
||||
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();
|
||||
|
||||
|
||||
|
@ -69,9 +72,7 @@ describe('Insight model', function() {
|
|||
|
||||
request.on = function(event, cb) {
|
||||
if (event === 'error') return;
|
||||
if (event === 'data') return {
|
||||
hola: 'chau'
|
||||
};
|
||||
if (event === 'data') return cb(JSON.stringify(unspent));
|
||||
return cb();
|
||||
};
|
||||
|
||||
|
@ -87,12 +88,13 @@ describe('Insight model', function() {
|
|||
|
||||
i.getUnspent(['2MuD5LnZSViZZYwZbpVsagwrH8WWvCztdmV', '2NBSLoMvsHsf2Uv3LA17zV4beH6Gze6RovA'], function(e, ret) {
|
||||
should.not.exist(e);
|
||||
should.exist(ret);
|
||||
ret.should.deep.equal(unspent);
|
||||
http.request.restore();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it.skip('should return txid', function(done) {
|
||||
it('should return txid', function(done) {
|
||||
var i = new Insight();
|
||||
|
||||
var http = require('http');
|
||||
|
@ -102,9 +104,7 @@ describe('Insight model', function() {
|
|||
|
||||
request.on = function(event, cb) {
|
||||
if (event === 'error') return;
|
||||
if (event === 'data') return {
|
||||
hola: 'chau'
|
||||
};
|
||||
if (event === 'data') return cb('{ "txid": "1234" }');
|
||||
return cb();
|
||||
};
|
||||
|
||||
|
@ -112,10 +112,17 @@ describe('Insight model', function() {
|
|||
req.write = function() {};
|
||||
req.end = function() {};
|
||||
|
||||
sinon
|
||||
.stub(http, 'request')
|
||||
.returns(req)
|
||||
.yields(request);
|
||||
|
||||
i.sendRawTransaction(rawtx, function(a) {
|
||||
should.exist(a);
|
||||
a.should.equal('1234');
|
||||
http.request.restore();
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue