Sha256: 9feb258f59375322b41262ed7e2a746850e1d9dc62eeff7d328e00fa2b841651

Contents?: true

Size: 1.72 KB

Versions: 7

Compression:

Stored size: 1.72 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', item_component: Blacklight::FacetItemComponent, item_presenter: Blacklight::FacetItemPresenter),
      paginator: paginator,
      key: 'field',
      label: 'Field',
      active?: false,
      collapsed?: false,
      modal_path: nil,
      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_css '.card'
    expect(rendered).to have_button 'Field'
    expect(rendered).to have_css 'button[data-bs-target="#facet-field"]'
    expect(rendered).to have_css '#facet-field.collapse.show'
  end

  it 'renders the facet items' do
    expect(rendered).to have_css 'ul.facet-values'
    expect(rendered).to have_css '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

7 entries across 7 versions & 2 rubygems

Version Path
blacklight-8.6.1 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-8.6.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-8.5.1 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-8.5.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-8.4.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-8.3.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb