Sha256: 4d85603cf1d2864ac16c3c8619b0b0cfc0eea770a27ad4a1cc973fb8178c1e73

Contents?: true

Size: 1.46 KB

Versions: 25

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

25 entries across 25 versions & 2 rubygems

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