Sha256: 145586f3bec1b3742db5d14f76f57d2a44d190f386d0faf4e5711fbc11e24c94

Contents?: true

Size: 1.78 KB

Versions: 18

Compression:

Stored size: 1.78 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Blacklight::Gallery::DocumentComponent, type: :component do
  subject(:component) do
    if Blacklight::VERSION > '8'
      described_class.new(document: presenter, **attr)
    else
      described_class.new(document: document, presenter: presenter, **attr)
    end
  end

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

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

  let(:document) do
    SolrDocument.new(
      id: 'x',
      thumbnail_path_ss: 'http://example.com/image.jpg',
      title_tsim: 'This is my document title'
    )
  end

  let(:presenter) { Blacklight::IndexPresenter.new(document, view_context, blacklight_config) }

  let(:blacklight_config) do
    CatalogController.blacklight_config.deep_copy.tap do |config|
      if Blacklight::VERSION > '8'
        config.track_search_session.storage = false
      else
        config.track_search_session = false
      end
      config.index.thumbnail_field = 'thumbnail_path_ss'
    end
  end

  before do
    allow(vc_test_controller).to receive(:blacklight_config).and_return(blacklight_config)
    allow(view_context).to receive(:current_search_session).and_return(nil)
    allow(view_context).to receive(:search_session).and_return({})
    allow(view_context).to receive(:blacklight_config).and_return(blacklight_config)

    # dumb hack to get our stubbing into the thumbnail component
    allow(vc_test_controller).to receive(:view_context).and_return(view_context)
  end

  it 'has a thumbnail and caption' do
    expect(rendered).to have_selector '.document-thumbnail img'
    expect(rendered).to have_selector '.caption', text: 'This is my document title'
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
blacklight-gallery-4.8.3 spec/components/blacklight/gallery/document_component_spec.rb
blacklight-gallery-4.8.2 spec/components/blacklight/gallery/document_component_spec.rb
blacklight-gallery-4.8.1 spec/components/blacklight/gallery/document_component_spec.rb
blacklight-gallery-4.8.0 spec/components/blacklight/gallery/document_component_spec.rb
blacklight-gallery-4.7.0 spec/components/blacklight/gallery/document_component_spec.rb
blacklight-gallery-4.6.4 spec/components/blacklight/gallery/document_component_spec.rb
blacklight-gallery-4.6.3 spec/components/blacklight/gallery/document_component_spec.rb
blacklight-gallery-4.6.2 spec/components/blacklight/gallery/document_component_spec.rb
blacklight-gallery-4.6.1 spec/components/blacklight/gallery/document_component_spec.rb
blacklight-gallery-4.6.0 spec/components/blacklight/gallery/document_component_spec.rb
blacklight-gallery-4.5.4 spec/components/blacklight/gallery/document_component_spec.rb
blacklight-gallery-4.5.3 spec/components/blacklight/gallery/document_component_spec.rb
blacklight-gallery-4.5.2 spec/components/blacklight/gallery/document_component_spec.rb
blacklight-gallery-4.5.1 spec/components/blacklight/gallery/document_component_spec.rb
blacklight-gallery-4.5.0 spec/components/blacklight/gallery/document_component_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-gallery-4.4.1/spec/components/blacklight/gallery/document_component_spec.rb
blacklight-gallery-4.4.1 spec/components/blacklight/gallery/document_component_spec.rb
blacklight-gallery-4.4.0 spec/components/blacklight/gallery/document_component_spec.rb