insight-bitcore-api
Version:
An open-source bitcoin blockchain API. The Insight API provides you with a convenient, powerful and simple way to query and broadcast data on the bitcoin network and build your own services with it.
31 lines (25 loc) • 776 B
JavaScript
;
var chai = require('chai');
var should = chai.should;
var expect = chai.expect;
var sinon = require('sinon');
var socket = require('../app/controllers/socket');
var bitcore = require('bitcore');
var EventEmitter = require('events').EventEmitter;
describe('socket server', function() {
it('should be able to call init with no args', function() {
socket.init.should.not.throw();
});
it('should register socket handlers', function() {
var io = {
sockets: new EventEmitter(),
}
socket.init(io);
var mockSocket = {};
mockSocket.on = sinon.spy();
io.sockets.emit('connection', mockSocket);
mockSocket.on.calledWith('subscribe');
mockSocket.on.calledWith('sync');
mockSocket.on.calledWith('message');
});
});