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.40.0 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.39.0 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.38.0 spec/components/blacklight/document/group_component_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/spec/components/blacklight/document/group_component_spec.rb
blacklight-8.2.2 spec/components/blacklight/document/group_component_spec.rb
blacklight-8.2.1 spec/components/blacklight/document/group_component_spec.rb
blacklight-8.2.0 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.37.0 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.36.2 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.36.1 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.36.0 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.35.0 spec/components/blacklight/document/group_component_spec.rb
blacklight-8.1.0 spec/components/blacklight/document/group_component_spec.rb
blacklight-7.34.0 spec/components/blacklight/document/group_component_spec.rb
blacklight-8.0.1 spec/components/blacklight/document/group_component_spec.rb
blacklight-8.0.0 spec/components/blacklight/document/group_component_spec.rb
blacklight-8.0.0.beta8 spec/components/blacklight/document/group_component_spec.rb
blacklight-8.0.0.beta7 spec/components/blacklight/document/group_component_spec.rb
blacklight-8.0.0.beta6 spec/components/blacklight/document/group_component_spec.rb
blacklight-8.0.0.beta5 spec/components/blacklight/document/group_component_spec.rb