Sha256: 2b2c04d0cf0750b32faaefd157ffa7f468003ea9e92024736148183fc6d344e8

Contents?: true

Size: 1.14 KB

Versions: 69

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Blacklight::Document::GroupComponent, type: :component do
  subject(:component) { described_class.new(group: group, **attr) }

  let(:attr) { {} }
  let(:view_context) { controller.view_context }
  let(:render) do
    component.render_in(view_context)
  end

  let(:rendered) do
    Capybara::Node::Simple.new(render)
  end

  let(:docs) { 10.times.map { double } }

  let(:group) do
    instance_double(Blacklight::Solr::Response::Group, key: 'group1', field: 'group_field', total: 15, docs: docs)
  end

  before do
    allow(view_context).to receive(:render_document_index).with(docs).and_return('results')
  end

  it 'renders the group with a header' do
    expect(rendered).to have_selector 'div.group'
    expect(rendered).to have_selector 'h2', text: 'group1'
    expect(rendered).not_to have_link 'more'
  end

  it 'renders the group documents' do
    expect(rendered).to have_content 'results'
  end

  context 'with a limit applied' do
    let(:attr) { { group_limit: 5 } }

    it 'renders a control to see more results' do
      expect(rendered).to have_link 'more'
    end
  end
end

Version data entries

69 entries across 69 versions & 2 rubygems

Version Path
blacklight-7.23.0.1 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.23.0 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.22.2 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.22.1 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.22.0 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.21.2 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.21.1 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.21.0 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.20.1 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.20.0 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.19.2 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.19.1 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.19.0 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.18.1 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.18.0 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.17.2 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.17.1 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.17.0 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.16.0 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.15.2 spec/components/blacklight/document/group_component_spec.rb