Sha256: 5a7d4b55c1b6e62d4bd3a1bc284e024483f3f36990304c1b03743d1a5bbfd31e

Contents?: true

Size: 1.44 KB

Versions: 55

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

RSpec.describe 'catalog/_facet_index_navigation.html.erb', type: :view do
  let(:pagination) { Blacklight::Solr::FacetPaginator.new([]) }
  let(:facet) { Blacklight::Configuration::FacetField.new(index_range: '0'..'9') }
  let(:display_facet) { double(items: [], offset: 0, prefix: '', sort: 'index') }
  let(:blacklight_config) { Blacklight::Configuration.new }

  before do
    assign(:display_facet, display_facet)
    assign(:facet, facet)
    allow(view).to receive(:blacklight_config).and_return(blacklight_config)
    allow(view).to receive(:facet_limit_for).and_return(10)
    controller.request.path_parameters[:action] = 'index'
  end

  it 'renders the facet index navigation range' do
    render
    expect(rendered).to have_selector '.pagination'
    expect(rendered).to have_link '0', href: '/?facet.prefix=0&facet.sort=index'
    expect(rendered).to have_link '1'
    expect(rendered).to have_link '8'
    expect(rendered).to have_link '9'
  end

  it 'renders an "all" button' do
    render
    expect(rendered).to have_selector '.page-link', text: 'All'
  end

  context 'with a selected index' do
    let(:display_facet) { double(items: [], offset: 0, prefix: '5', sort: 'index') }

    it 'highlights the selected index' do
      render
      expect(rendered).to have_selector '.active', text: '5'
    end

    it 'enables the clear facets button' do
      render
      expect(rendered).to have_link 'All'
    end
  end
end

Version data entries

55 entries across 55 versions & 2 rubygems

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