     describe 'when authDevice yields a device', ->
       beforeEach ->
         @authDevice = sinon.stub().yields null, uuid: '1234'
-        @sut = new MeshbluWebsocketHandler authDevice: @authDevice, MessageIOClient: @MessageIOClient
+        @sut = new MeshbluWebsocketHandler authDevice: @authDevice, MessageIOClient: @MessageIOClient, meshbluEventEmitter: @meshbluEventEmitter
         @sut.messageIOClient = @messageIOClient
         @sut.sendFrame = sinon.stub()
         @sut.setOnlineStatus = sinon.spy()

    describe 'when authDevice yields an error', ->
      beforeEach ->
        @authDevice = sinon.stub().yields new Error
        @sut = new MeshbluWebsocketHandler authDevice: @authDevice
        @sut.sendError = sinon.spy()

        @sut.unregister uuid: '1345', online: true

        beforeEach (done) ->
          @throttles = query: rateLimit: sinon.stub().yields null, false
          @authDevice = sinon.stub().yields new Error
          @sut = new MeshbluWebsocketHandler throttles: @throttles, authDevice: @authDevice, meshbluEventEmitter: @meshbluEventEmitter
          @sut.socket = id: '1555'
          @sut.sendError = sinon.spy => done()
          sinon.spy @sut, 'emit'
