Sha256: b80131cc98e3beca2235255836de4ab2803697ebcbbd965e3dc0e7ddf2432351

Contents?: true

Size: 1.51 KB

Versions: 5

Compression:

Stored size: 1.51 KB

Contents

describe 'Firehose.LongPoll', ->
  beforeEach ->
    @klass    = Firehose.LongPoll
    @instance = new @klass()

  afterEach -> @instance.stop()

  #= Specs ===

  it '.ieSupported returns a Boolean', ->
    expect( typeof @klass.ieSupported() ).toBe 'boolean'

  it '.supported returns a Boolean', ->
    expect( typeof @klass.supported() ).toBe 'boolean'

  describe '#stop', ->
    beforeEach ->
      @instance._lastRequest     = $.ajax()
      @instance._lastPingRequest = $.ajax()

    it 'aborts the last request', ->
      sinon.spy @instance._lastRequest, 'abort'
      Object.freeze @instance # Prevents the delete call from modifying the request object, so we can verify the call
      @instance.stop()
      expect( @instance._lastRequest.abort.called ).toBe true

    it 'deletes reference to the last request', ->
      @instance.stop()
      expect( @instance._lastRequest? ).toBe false

    it 'aborts the last ping request', ->
      sinon.spy @instance._lastPingRequest, 'abort'
      Object.freeze @instance # Prevents the delete call from modifying the request object, so we can verify the call
      @instance.stop()
      expect( @instance._lastPingRequest.abort.called ).toBe true

    it 'deletes reference to the last ping request', ->
      @instance.stop()
      expect( @instance._lastPingRequest? ).toBe false

  describe 'callbacks', ->
    for callback in ['_request','_success','_ping','_error']
      it "has a #{callback} callback function", ->
        expect( @instance[callback] ).toEqual jasmine.any Function

Version data entries

5 entries across 5 versions & 1 rubygems

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