Skip to content

Commit

Permalink
init thumbnail presenter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcam-src committed Dec 3, 2024
1 parent cd0d359 commit 5eee3d5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/presenters/blacklight/thumbnail_presenter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true
require 'rails_helper'
require Rails.root.join('app/overrides/presenters/blacklight/thumbnail_presenter_override.rb')

RSpec.describe Blacklight::ThumbnailPresenter do
describe '#retrieve_values' do
it 'does not attempt to process a solr document if it is nil' do
# Mock field config and view context
field_config = double('FieldConfig')
view_context = double('ViewContext')
presenter = Blacklight::ThumbnailPresenter.new(nil, view_context, field_config)

retriever_instance = Blacklight::FieldRetriever.new(nil, nil, nil)
allow(Blacklight::FieldRetriever).to receive(:new).and_return(retriever_instance)
allow(retriever_instance).to receive(:fetch).and_return('default_thumbnail')
allow(presenter).to receive(:extract_solr_document)

presenter.send(:retrieve_values, field_config)
expect(Blacklight::FieldRetriever).to have_received(:new).with(nil, field_config, view_context)
# Presenter should not process the document if it's nil
expect(presenter).not_to have_received(:extract_solr_document)
end
end
end

0 comments on commit 5eee3d5

Please sign in to comment.