Sha256: 96e6399caea1381b3657882811ef21da766227f1867eb578e6e332e094c7198a

Contents?: true

Size: 1.49 KB

Versions: 9

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

RSpec.describe "catalog/facet_layout" do
  let :blacklight_config do
    Blacklight::Configuration.new do |config|
      config.facet_fields[facet_field.field] = facet_field
    end
  end

  let :facet_field do
    Blacklight::Configuration::FacetField.new(field: 'some_field').normalize!
  end

  before do
    allow(view).to receive_messages(blacklight_config: blacklight_config)
  end

  it "has a facet-specific class" do
    render partial: 'catalog/facet_layout', locals: { facet_field: facet_field }
    expect(rendered).to have_css '.blacklight-some_field'
  end

  it "has a title with a link for a11y" do
    render partial: 'catalog/facet_layout', locals: { facet_field: facet_field }
    expect(rendered).to have_css 'h3', text: 'Some Field'
  end

  it "is collapsable" do
    render partial: 'catalog/facet_layout', locals: { facet_field: facet_field }
    expect(rendered).to have_css 'button.collapsed[data-toggle="collapse"][data-bs-toggle="collapse"][aria-expanded="false"]'
    expect(rendered).to have_css '.collapse .card-body'
  end

  it "is configured to be open by default" do
    allow(facet_field).to receive_messages(collapse: false)
    render partial: 'catalog/facet_layout', locals: { facet_field: facet_field }
    expect(rendered).to have_css 'button[data-toggle="collapse"][data-bs-toggle="collapse"][aria-expanded="true"]'
    expect(rendered).to have_no_css '.card-header.collapsed'
    expect(rendered).to have_css '.collapse.show .card-body'
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
blacklight-8.8.0 spec/views/catalog/_facet_layout.html.erb_spec.rb
blacklight-8.7.0 spec/views/catalog/_facet_layout.html.erb_spec.rb
blacklight-8.6.1 spec/views/catalog/_facet_layout.html.erb_spec.rb
blacklight-8.6.0 spec/views/catalog/_facet_layout.html.erb_spec.rb
blacklight-8.5.1 spec/views/catalog/_facet_layout.html.erb_spec.rb
blacklight-8.5.0 spec/views/catalog/_facet_layout.html.erb_spec.rb
blacklight-8.4.0 spec/views/catalog/_facet_layout.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_layout.html.erb_spec.rb
blacklight-8.3.0 spec/views/catalog/_facet_layout.html.erb_spec.rb