Sha256: a6aa0408a2670c759b1b0a3c72375fb730f38639f9396599163b233abe472051

Contents?: true

Size: 1.68 KB

Versions: 37

Compression:

Stored size: 1.68 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Blacklight::FacetFieldCheckboxesComponent, type: :component do
  subject(:rendered) do
    render_inline_to_capybara_node(described_class.new(facet_field: facet_field))
  end

  let(:facet_field) do
    instance_double(
      Blacklight::FacetFieldPresenter,
      facet_field: Blacklight::Configuration::NullField.new(key: 'field'),
      paginator: paginator,
      key: 'field',
      label: 'Field',
      active?: false,
      collapsed?: false,
      modal_path: nil,
      html_id: 'facet-field',
      search_state: search_state
    )
  end

  let(:paginator) do
    instance_double(Blacklight::FacetPaginator, items: [
                      double(label: 'a', hits: 10, value: 'a'),
                      double(label: 'b', hits: 33, value: 'b'),
                      double(label: 'c', hits: 3, value: 'c')
                    ])
  end

  let(:search_state) { Blacklight::SearchState.new(params.with_indifferent_access, Blacklight::Configuration.new) }
  let(:params) { { f: { field: ['a'] } } }

  it 'renders a collapsible card' do
    expect(rendered).to have_selector '.card'
    expect(rendered).to have_button 'Field'
    expect(rendered).to have_selector 'button[data-bs-target="#facet-field"]'
    expect(rendered).to have_selector '#facet-field.collapse.show'
  end

  it 'renders the facet items' do
    expect(rendered).to have_selector 'ul.facet-values'
    expect(rendered).to have_selector 'li', count: 3

    expect(rendered).to have_field 'f_inclusive[field][]', with: 'a'
    expect(rendered).to have_field 'f_inclusive[field][]', with: 'b'
    expect(rendered).to have_field 'f_inclusive[field][]', with: 'c'
  end
end

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
blacklight-7.40.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.39.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.38.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.37.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.36.2 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.36.1 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.36.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.35.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.34.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.33.1 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.33.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.32.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.31.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.30.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.29.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.28.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.27.1 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.27.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.26.1 spec/components/blacklight/facet_field_checkboxes_component_spec.rb