Sha256: 7126921f5d76cf031ce66ce87a519a2442b1768e9eaaf09397dbd10b08fc5545

Contents?: true

Size: 1.36 KB

Versions: 5

Compression:

Stored size: 1.36 KB

Contents

describe 'Firehose.Consumer', ->
  beforeEach ->
    @klass    = Firehose.Consumer
    @instance = new @klass uri: 'test_uri', okInterval: 9999 # Stop crazy ajax loops during tests


  #= Specs ===

  describe 'new instance', ->
    describe '@config', ->
      beforeEach -> @subj = @instance.config

      for callback in ['message','error','connected','disconnected','failed']
        it "has a .#{callback} function", ->
          expect( @subj[callback] ).toEqual jasmine.any Function

      it 'has a params object', ->
        expect( @subj.params ).toEqual jasmine.any Object

      it 'has a parse function', ->
        expect( @subj.parse ).toEqual jasmine.any Function

  describe '#connect', ->
    it 'runs without error', -> @instance.connect()

    describe 'after #connect called', ->
      beforeEach -> @instance.connect()

      it 'creates a @transport instance', ->
        expect( @instance.transport ).toEqual jasmine.any Firehose.Transport

  describe '#stop', ->
    describe 'when .connect called earlier', ->
      beforeEach ->
        @instance.connect()
        sinon.spy @instance.transport, 'stop'

      it 'calls stop once on @transport', ->
        @instance.stop()
        expect( @instance.transport.stop.calledOnce ).toBe true

      it 'stops the upgrade timeout', ->
        @instance.stop()
        expect( @instance.upgradeTimeout? ).toBe false

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
firehose-1.3.6 spec/javascripts/firehose/consumer_spec.coffee
firehose-1.2.20 spec/javascripts/firehose/consumer_spec.coffee
firehose-1.2.13 spec/javascripts/firehose/consumer_spec.coffee
firehose-1.2.12 spec/javascripts/firehose/consumer_spec.coffee
firehose-1.2.11 spec/javascripts/firehose/consumer_spec.coffee