Sha256: 8a092f3c2b571bd6975ddcf287b407244d722e32b33ddefbdb649e8dc9b60570

Contents?: true

Size: 1.69 KB

Versions: 31

Compression:

Stored size: 1.69 KB

Contents

# frozen_string_literal: true
describe "catalog/index.json" do
  let(:response) { instance_double(Blacklight::Solr::Response) }
  let(:docs) { [{ id: '123', title_t: 'Book1' }, { id: '456', title_t: 'Book2' }] }
  let(:facets) { double("facets") }
  let(:config) { instance_double(Blacklight::Configuration) }
  let(:presenter) { Blacklight::JsonPresenter.new(response, docs, facets, config) }

  it "renders index json" do
    allow(presenter).to receive(:pagination_info).and_return({ current_page: 1, next_page: 2,
                                                               prev_page: nil })
    allow(presenter).to receive(:search_facets_as_json).and_return(
          [{ name: "format", label: "Format",
             items: [{ value: 'Book', hits: 30, label: 'Book' }] }])
    assign :presenter, presenter
    render template: "catalog/index.json", format: :json
    hash = JSON.parse(rendered)
    expect(hash).to eq('response' => { 'docs' => [{ 'id' => '123', 'title_t' => 'Book1' },
                                                  { 'id' => '456', 'title_t' => 'Book2' }],
                                       'facets' => [{ 'name' => "format", 'label' => "Format",
                                                      'items' => [
                                                        { 'value' => 'Book',
                                                          'hits' => 30,
                                                          'label' => 'Book' }] }],
                                       'pages' => { 'current_page' =>  1,
                                                    'next_page' => 2,
                                                    'prev_page' => nil } }
                      )
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
blacklight-6.25.0 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.24.0 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.23.0 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.22.0 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.21.0 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.20.0 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.19.2 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.19.1 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.19.0 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.18.0 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.17.0 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.16.0 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.15.0 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.14.1 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.14.0 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.13.0 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.12.0 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.11.2 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.11.1 spec/views/catalog/index.json.jbuilder_spec.rb
blacklight-6.11.0 spec/views/catalog/index.json.jbuilder_spec.rb