Sha256: 40ed3a60ca3d09c39ff02235ff5f150ba511a50a0c73eeaf7b94b28499189b31

Contents?: true

Size: 1.46 KB

Versions: 21

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Blacklight::FacetGroupedItemPresenter, type: :presenter do
  subject(:presenter) do
    described_class.new(group, facet_item, facet_config, view_context, facet_field, search_state)
  end

  let(:facet_config) { Blacklight::Configuration::FacetField.new(key: 'key') }
  let(:facet_field) { instance_double(Blacklight::Solr::Response::Facets::FacetField) }
  let(:view_context) { controller.view_context }

  let(:facet_item) { 'a' }
  let(:group) { %w[a b c] }
  let(:blacklight_config) do
    Blacklight::Configuration.new.configure do |config|
      config.add_facet_field :key
    end
  end
  let(:search_state) { Blacklight::SearchState.new(params, blacklight_config) }
  let(:params) { { f_inclusive: { key: group } } }

  describe '#selected' do
    it { is_expected.to be_selected }

    context 'when the item is not in the group' do
      let(:facet_item) { 'd' }

      it { is_expected.not_to be_selected }
    end

    describe '#href' do
      it 'removes the item from the "group" of filters' do
        expect(Rack::Utils.parse_query(URI(presenter.href).query)).to include 'f_inclusive[key][]' => %w[b c]
      end

      context 'when the item is not in the group' do
        let(:facet_item) { 'd' }

        it 'adds the item to the "group" of filters' do
          expect(Rack::Utils.parse_query(URI(presenter.href).query)).to include 'f_inclusive[key][]' => %w[a b c d]
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
blacklight-8.6.1 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-8.6.0 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-8.5.1 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-8.5.0 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-8.4.0 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-8.3.0 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-8.2.2 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-8.2.1 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-8.2.0 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-8.1.0 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-8.0.1 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-8.0.0 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-8.0.0.beta8 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-8.0.0.beta7 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-8.0.0.beta6 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-8.0.0.beta5 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-8.0.0.beta4 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-8.0.0.beta3 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-8.0.0.beta2 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb