Sha256: 4b0d783946b82c6a5c3e4af05a069cbd3a9e9f8a1d7fc9d7bfd59954779d632a

Contents?: true

Size: 920 Bytes

Versions: 58

Compression:

Stored size: 920 Bytes

Contents

# frozen_string_literal: true

RSpec.describe Blacklight::Solr::FacetPaginator, api: true do
  let(:f1) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '792', value: 'Book') }

  describe "#as_json" do
    subject { described_class.new([f1], offset: 0, limit: nil).as_json }

    it "is well structured" do
      expect(subject).to eq("items" => [{ "hits" => "792", "value" => "Book" }], "limit" => nil,
                            "offset" => 0, "sort" => "index")
    end
  end

  describe '#sort' do
    it 'defaults to "count" if a limit is provided' do
      expect(described_class.new([], limit: 10).sort).to eq 'count'
    end

    it 'defaults to "index" if no limit is given' do
      expect(described_class.new([]).sort).to eq 'index'
    end

    it 'handles json facet api-style parameter sorts' do
      expect(described_class.new([], sort: { count: :desc }).sort).to eq 'count'
    end
  end
end

Version data entries

58 entries across 58 versions & 2 rubygems

Version Path
blacklight-7.40.0 spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-7.39.0 spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-7.38.0 spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-8.2.2 spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-8.2.1 spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-8.2.0 spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-7.37.0 spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-7.36.2 spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-7.36.1 spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-7.36.0 spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-7.35.0 spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-8.1.0 spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-7.34.0 spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-8.0.1 spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-8.0.0 spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-8.0.0.beta8 spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-8.0.0.beta7 spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-8.0.0.beta6 spec/models/blacklight/solr/facet_paginator_spec.rb
blacklight-8.0.0.beta5 spec/models/blacklight/solr/facet_paginator_spec.rb