node.js - How to test socket.io events being called with sinon.spy -


first of all, i'm trying test second time function being called returns correct value. more specific, i'm trying test second time event received socket.on() returns correct value.

i know sinon.spy() can detect whether function being called or not. seems not working socket.io events.

i'm trying test example,

var socketio = io.connect(someurl); socketio.on(eventname, cb); 

if event 'connect' called. tried

var spy = sinon.spy(socketio, 'on'); assert(spy.witharg(eventname).called); 

but says it's never being called.

furthermore, if i'd test data in callback function right or not, example

var socketio = io.connect(someurl); socketio.on(eventname, function(data) {     data.should.equal(something); }); 

is possible test that?


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -