Sha256: 7d298ef86f3702c7bcbbc7982fd5626e25a841efe0465e74f8ce5436e4b8cf9c

Contents?: true

Size: 1.34 KB

Versions: 23

Compression:

Stored size: 1.34 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(:search_state) { Blacklight::SearchState.new(params, Blacklight::Configuration.new) }
  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

23 entries across 23 versions & 1 rubygems

Version Path
blacklight-7.24.0 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.23.0.1 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.23.0 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.22.2 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.22.1 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.22.0 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.21.2 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.21.1 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.21.0 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.20.1 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.20.0 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.19.2 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.19.1 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.19.0 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.18.1 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.18.0 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.17.2 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.17.1 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.17.0 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb
blacklight-7.16.0 spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb