From 6b5254e6ad9d6c09e7be78f533a42b9b4549e2c2 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Tue, 31 Mar 2015 12:58:51 -0300 Subject: [PATCH] test blockchain explorer --- lib/blockchainexplorer.js | 2 -- test/blockchainexplorer.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 test/blockchainexplorer.js diff --git a/lib/blockchainexplorer.js b/lib/blockchainexplorer.js index bee70b9..c11a82c 100644 --- a/lib/blockchainexplorer.js +++ b/lib/blockchainexplorer.js @@ -31,10 +31,8 @@ function BlockChainExplorer(opts) { explorer.getTransactions = _.bind(getTransactionsInsight, explorer, url); explorer.initSocket = _.bind(initSocketInsight, explorer, url); return explorer; - break; default: throw new Error('Provider ' + provider + ' not supported'); - break; }; }; diff --git a/test/blockchainexplorer.js b/test/blockchainexplorer.js new file mode 100644 index 0000000..b1fbd3d --- /dev/null +++ b/test/blockchainexplorer.js @@ -0,0 +1,35 @@ +'use strict'; + +var _ = require('lodash'); +var chai = require('chai'); +var sinon = require('sinon'); +var should = chai.should(); +var BlockchainExplorer = require('../lib/blockchainexplorer'); + +describe('Blockchain explorer', function() { + describe('#constructor', function() { + it('should return a blockchain explorer with basic methods', function() { + var exp = BlockchainExplorer({ + provider: 'insight', + network: 'testnet', + }); + should.exist(exp); + exp.should.respondTo('broadcast'); + exp.should.respondTo('getTransactions'); + exp.should.respondTo('getUnspentUtxos'); + exp.should.respondTo('initSocket'); + var exp = BlockchainExplorer({ + provider: 'insight', + network: 'livenet', + }); + should.exist(exp); + }); + it('should fail on unsupported provider', function() { + (function() { + var exp = BlockchainExplorer({ + provider: 'dummy', + }); + }).should.throw('not supported'); + }); + }); +});