Sha256: be6f46ff6e7f643888ce646d8cf789aa4f7d49cd6a8f3aada0028669d93a3b85

Contents?: true

Size: 1.4 KB

Versions: 50

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Blacklight::FacetItemComponent, type: :component do
  subject(:rendered) do
    render_inline_to_capybara_node(described_class.new(facet_item: facet_item))
  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' do |link|
      link['rel'] == 'nofollow'
    end
    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' do |link|
        link['rel'] == 'nofollow'
      end
      expect(rendered).to have_selector '.selected.facet-count', text: '10'
    end
  end
end

Version data entries

50 entries across 50 versions & 2 rubygems

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