Sha256: cd2e2c28aa346de58974e9d27011db4494787eadfa985c1bfd1faba3543ab9b4

Contents?: true

Size: 1.34 KB

Versions: 23

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

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

  let(:rendered) do
    Capybara::Node::Simple.new(render)
  end

  let(:facet_item) do
    instance_double(
      Blacklight::FacetItemPresenter,
      facet_config: Blacklight::Configuration::FacetField.new,
      label: 'x',
      hits: 10,
      href: '/catalog?f=x',
      selected?: false
    )
  end

  it 'links to the facet and shows the number of hits' do
    expect(rendered).to have_selector 'li'
    expect(rendered).to have_link 'x', href: '/catalog?f=x'
    expect(rendered).to have_selector '.facet-count', text: '10'
  end

  context 'with a selected facet' do
    let(:facet_item) do
      instance_double(
        Blacklight::FacetItemPresenter,
        facet_config: Blacklight::Configuration::FacetField.new,
        label: 'x',
        hits: 10,
        href: '/catalog',
        selected?: true
      )
    end

    it 'links to the facet and shows the number of hits' do
      expect(rendered).to have_selector 'li'
      expect(rendered).to have_selector '.selected', text: 'x'
      expect(rendered).to have_link '[remove]', href: '/catalog'
      expect(rendered).to have_selector '.selected.facet-count', text: '10'
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
blacklight-7.19.1 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.19.0 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.18.1 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.18.0 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.17.2 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.17.1 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.17.0 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.16.0 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.15.2 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.15.1 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.15.0 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.14.1 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.14.0 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.13.2 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.13.1 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.13.0 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.12.1 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.12.0 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.11.1 spec/components/blacklight/facet_item_component_spec.rb
blacklight-7.10.0 spec/components/blacklight/facet_item_component_spec.rb