Added test on Insight

This commit is contained in:
Matias Pando 2015-01-29 15:07:08 -03:00
parent d77b451fb7
commit a2c39714c4
1 changed files with 72 additions and 0 deletions

View File

@ -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();
});
});
});
});