Sha256: fc30bd68c1e262778775a6c71cd3100392528623185ba288ac572190a91e3c93

Contents?: true

Size: 931 Bytes

Versions: 9

Compression:

Stored size: 931 Bytes

Contents

require 'spec_helper'

require 'cucumber/pickles/helpers/waiter'

RSpec.describe '#Waiter' do

  it 'Return 0 pending requests on page load' do
    @session.visit('/with_js')

    expect(Waiter.pending_ajax_requests_num).to eq 0
  end

  it 'Return 1 pending requests with open request' do
    @session.visit('/with_js')

    @session.evaluate_script(
      <<~JS
        new XMLHttpRequest().open("GET", '')
      JS
    )

    expect(Waiter.pending_ajax_requests_num).to eq 1
  end

  it 'Return 0 pending requests with closed request' do
    @session.visit('/with_js')

    @session.evaluate_script("window.req = new XMLHttpRequest();")

    @session.evaluate_script("window.req.open('GET', '', true);")

    expect(Waiter.pending_ajax_requests_num).to eq 1

    @session.evaluate_script("window.req.send();")

    @session.evaluate_script("window.req.abort();")

    expect(Waiter.pending_ajax_requests_num).to eq 0
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pickles-0.1.8 spec/helpers/waiter_spec.rb
pickles-0.1.7 spec/helpers/waiter_spec.rb
pickles-0.1.6 spec/helpers/waiter_spec.rb
pickles-0.1.5 spec/helpers/waiter_spec.rb
pickles-0.1.4 spec/helpers/waiter_spec.rb
pickles-0.1.3 spec/helpers/waiter_spec.rb
pickles-0.1.2 spec/helpers/waiter_spec.rb
pickles-0.1.1 spec/helpers/waiter_spec.rb
pickles-0.1.0 spec/helpers/waiter_spec.rb