Sha256: da7a7cd3d98416478064de0897de37799607097a233b0401d85656385f5af784

Contents?: true

Size: 1.31 KB

Versions: 36

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

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(:blacklight_config) { Blacklight::Configuration.new }

  before do
    assign(:pagination, pagination)
    assign(:facet, facet)
    allow(view).to receive(:blacklight_config).and_return(blacklight_config)
    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 a "clear filter" button' do
    render
    expect(rendered).to have_selector '.btn.disabled', text: 'Clear Filter'
  end

  context 'with a selected index' do
    let(:pagination) { Blacklight::Solr::FacetPaginator.new([], prefix: '5') }

    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 'Clear Filter'
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
blacklight-6.25.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.24.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.23.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.22.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.21.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.20.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.19.2 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.19.1 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.19.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.18.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.17.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.16.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.15.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.14.1 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.14.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.13.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.12.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.11.2 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.11.1 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb
blacklight-6.11.0 spec/views/catalog/_facet_index_navigation.html.erb_spec.rb