Sha256: 4462e8c716d9484aa1383158e8ac6a49c024c1e20d436927039708b918854acd

Contents?: true

Size: 1.17 KB

Versions: 51

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

RSpec.describe Blacklight::HiddenSearchStateComponent, type: :component do
  subject(:rendered) { render_inline_to_capybara_node(instance) }

  let(:params) do
    { q: "query",
      search_field: "search_field",
      per_page: 10,
      extra_arbitrary_key: "arbitrary_value",
      f: { field1: %w[a b], field2: ["z"] } }
  end
  let(:instance) { described_class.new(params: params) }

  it "converts a hash with nested complex data to Rails-style hidden form fields" do
    expect(rendered).to have_selector("input[type='hidden'][name='q'][value='query']", visible: :hidden)
    expect(rendered).to have_selector("input[type='hidden'][name='per_page'][value='10']", visible: :hidden)
    expect(rendered).to have_selector("input[type='hidden'][name='extra_arbitrary_key'][value='arbitrary_value']", visible: :hidden)
    expect(rendered).to have_selector("input[type='hidden'][name='f[field2][]'][value='z']", visible: :hidden)
    expect(rendered).to have_selector("input[type='hidden'][name='f[field1][]'][value='a']", visible: :hidden)
    expect(rendered).to have_selector("input[type='hidden'][name='f[field1][]'][value='b']", visible: :hidden)
  end
end

Version data entries

51 entries across 51 versions & 2 rubygems

Version Path
blacklight-7.40.0 spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-7.39.0 spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-7.38.0 spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-8.2.2 spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-8.2.1 spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-8.2.0 spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-7.37.0 spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-7.36.2 spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-7.36.1 spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-7.36.0 spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-7.35.0 spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-8.1.0 spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-7.34.0 spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-8.0.1 spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-8.0.0 spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-8.0.0.beta8 spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-8.0.0.beta7 spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-8.0.0.beta6 spec/components/blacklight/hidden_search_state_component_spec.rb
blacklight-8.0.0.beta5 spec/components/blacklight/hidden_search_state_component_spec.rb