         @socket = new EventEmitter
 
         @authDevice = sinon.stub().yields null, {uuid: 'device'}
-        @sut = new MeshbluSocketIOHandler authDevice: @authDevice
+        @sut = new MeshbluSocketIOHandler authDevice: @authDevice, meshbluEventEmitter: @meshbluEventEmitter
         @sut.initialize @socket
         @callback = sinon.spy()
         @socket.emit 'identity', uuid: 'device', token: 'wrong', @callback

        @socket = new EventEmitter

        @authDevice = sinon.stub().yields new Error 'not authorized'
        @sut = new MeshbluSocketIOHandler authDevice: @authDevice
        @sut.initialize @socket
        @socket.emit 'identity', {uuid: 'something', token: 'something-else'}, (@result) =>


MeshbluSocketIOHandler = require '../../lib/MeshbluSocketIOHandler'

describe 'MeshbluSocketIOHandler', ->
  beforeEach ->
    @meshbluEventEmitter = new EventEmitter

  describe 'initialize', ->
    beforeEach ->
      @sut = new MeshbluSocketIOHandler meshbluEventEmitter: @meshbluEventEmitter
      @socket = new EventEmitter
      @sut.initialize @socket

