Sha256: 98965926622ae3181fa3b52cc98e323f76be9678b913eca8b528509a57a5b16f

Contents?: true

Size: 1.72 KB

Versions: 10

Compression:

Stored size: 1.72 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

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

  let(:rendered) do
    Capybara::Node::Simple.new(render)
  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-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

10 entries across 10 versions & 1 rubygems

Version Path
blacklight-7.19.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.18.1 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.18.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.17.2 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.17.1 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.17.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.16.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.15.2 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.15.1 spec/components/blacklight/facet_field_checkboxes_component_spec.rb
blacklight-7.15.0 spec/components/blacklight/facet_field_checkboxes_component_spec.rb