Sha256: 014d0e7de7f3e423d2cd53291312d207bed791dbbdee3f4f8e0be9890509b7d6

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

describe BlacklightAdvancedSearch::RenderConstraintsOverride, type: :helper do
  let(:blacklight_config) do
    Blacklight::Configuration.new do |config|
      config.add_facet_field 'type'
    end
  end

  let(:advanced_query) do
    BlacklightAdvancedSearch::QueryParser.new(params, blacklight_config)
  end

  describe "#render_constraints_filters" do
    before do
      allow(helper).to receive(:blacklight_config).and_return(blacklight_config)
      allow(helper).to receive(:advanced_query).and_return(advanced_query)
      allow(helper).to receive(:search_action_path) do |*args|
        search_catalog_path(*args)
      end
    end

    subject(:rendered) { helper.render_constraints_filters({}) }

    context 'with an array of facet params' do
      let(:params) { ActionController::Parameters.new f_inclusive: { 'type' => ['a'] } }

      it "renders nothing" do
        expect(rendered).to have_text 'Remove constraint Type: a'
      end
    end

    context 'with scalar facet limit params' do
      let(:params) { ActionController::Parameters.new f_inclusive: { 'type' => 'a' } }

      it "renders the scalar value" do
        expect(rendered).to have_text 'Remove constraint Type: a'
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
blacklight_advanced_search-7.0.0 spec/lib/blacklight_advanced_search/render_constraints_override_spec.rb
blacklight_advanced_search-6.4.1 spec/lib/blacklight_advanced_search/render_constraints_override_spec.rb
blacklight_advanced_search-6.4.0 spec/lib/blacklight_advanced_search/render_constraints_override_spec.rb
blacklight_advanced_search-6.3.1 spec/lib/blacklight_advanced_search/render_constraints_override_spec.rb
blacklight_advanced_search-6.3.0 spec/lib/blacklight_advanced_search/render_constraints_override_spec.rb
blacklight_advanced_search-6.2.1 spec/lib/blacklight_advanced_search/render_constraints_override_spec.rb
blacklight_advanced_search-6.2.0 spec/lib/blacklight_advanced_search/render_constraints_override_spec.rb
blacklight_advanced_search-6.1.0 spec/lib/blacklight_advanced_search/render_constraints_override_spec.rb