Sha256: f8e74406e37f46683483a416eac1b44930220dea26e4f04428bfff35bee3cef1

Contents?: true

Size: 967 Bytes

Versions: 8

Compression:

Stored size: 967 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", '')
        new XMLHttpRequest().send()
      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

8 entries across 8 versions & 1 rubygems

Version Path
pickles-0.2.4 spec/helpers/waiter_spec.rb
pickles-0.2.3 spec/helpers/waiter_spec.rb
pickles-0.2.2 spec/helpers/waiter_spec.rb
pickles-0.2.1 spec/helpers/waiter_spec.rb
pickles-0.2.0 spec/helpers/waiter_spec.rb
pickles-0.1.12 spec/helpers/waiter_spec.rb
pickles-0.1.10 spec/helpers/waiter_spec.rb
pickles-0.1.9 spec/helpers/waiter_spec.rb