Sha256: 8a49be6f966f19958a4e9dbe33ec24185a99bd8c5b011fc747c665772847072a

Contents?: true

Size: 1.41 KB

Versions: 14

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

RSpec.describe 'catalog/_facet_index_navigation.html.erb' do
  let(:pagination) { Blacklight::Solr::FacetPaginator.new([]) }
  let(:facet) { Blacklight::Configuration::FacetField.new(index_range: '0'..'9', presenter: Blacklight::FacetFieldPresenter) }
  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_messages(blacklight_config: blacklight_config, facet_limit_for: 10)
    controller.request.path_parameters[:action] = 'index'
  end

  it 'renders the facet index navigation range' do
    render
    expect(rendered).to have_css '.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_css '.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_css '.active', text: '5'
    end

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

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
blacklight-8.8.4 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-8.8.3 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-8.8.2 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-9.0.0.beta1 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-8.8.1 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-8.8.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-8.7.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-8.6.1 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-8.6.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-8.5.1 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-8.5.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-8.4.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-8.3.0/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-8.3.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb