From a2c39714c4ef32f58c8e0c8dbcadfc3e347735c0 Mon Sep 17 00:00:00 2001 From: Matias Pando Date: Thu, 29 Jan 2015 15:07:08 -0300 Subject: [PATCH] Added test on Insight --- test/blockchain.Insight.js | 72 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/test/blockchain.Insight.js b/test/blockchain.Insight.js index e6f2dbd23..4b70af37a 100644 --- a/test/blockchain.Insight.js +++ b/test/blockchain.Insight.js @@ -429,4 +429,76 @@ describe('Insight model', function() { }); }); + describe('#request', function() { + it('should check request', function(done) { + var blockchain = new Insight(FAKE_OPTS); + blockchain.request('hola', function() { + done(); + }); + }); + }); + + describe('#requestPost', function() { + it('should check requestPost', function(done) { + var blockchain = new Insight(FAKE_OPTS); + blockchain.requestPost('hola', 'myData', function() { + done(); + }); + }); + }); + + describe('#broadcast', function() { + it('should check broadcast', function(done) { + var blockchain = new Insight(FAKE_OPTS); + blockchain.requestPost = sinon.stub().yields({ + error: 'error', + status: 500 + }); + blockchain.broadcast('myTX', function(err) { + err.should.not.be.undefined; + done(); + }); + }); + }); + + describe('#getTransactions', function() { + it('should check getTransactions', function(done) { + var blockchain = new Insight(FAKE_OPTS); + blockchain.requestPost = sinon.stub().yields({ + error: 'error', + status: 500 + }); + blockchain.getTransactions(['addr1'], 'to', 'from', function(err) { + err.should.not.be.undefined; + done(); + }); + }); + + it('should check getTransactions using to and from as numbers', function(done) { + var blockchain = new Insight(FAKE_OPTS); + blockchain.requestPost = sinon.stub().yields({ + error: 'error', + status: 500 + }); + blockchain.getTransactions(['addr1'], 1, 10, function(err) { + err.should.not.be.undefined; + done(); + }); + }); + }); + + describe('#getUnspent', function() { + it('should check getUnspent with error response', function(done) { + var blockchain = new Insight(FAKE_OPTS); + blockchain.requestPost = sinon.stub().yields({ + error: 'error', + status: 500 + }); + blockchain.getUnspent(['addr1'], function(err) { + err.should.not.be.undefined; + done(); + }); + }); + }); + });