Skip to content

Commit

Permalink
Add test of title generation
Browse files Browse the repository at this point in the history
  • Loading branch information
masaball committed Nov 11, 2024
1 parent 677cae9 commit 35cd919
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions spec/models/iiif_canvas_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,33 @@
end
end

describe "#to_s" do
subject { presenter.to_s }

context 'single-section item' do
it 'prioritizes MediaObject#title for section title' do
expect(subject).to eq master_file.structure_title
expect(subject).to eq media_object.title
expect(subject).to_not eq master_file.display_title
end
end

context 'multi-section item' do
let(:second) { FactoryBot.build(:master_file, media_object: media_object, derivatives: [derivative]) }

before :each do
media_object.sections = [master_file, second]
media_object.save!
end

it 'prioritizes MasterFile#display_title for section titles' do
expect(subject).to eq master_file.structure_title
expect(subject).to eq master_file.display_title
expect(subject).to_not eq media_object.title
end
end
end

describe '#display_content' do
subject { presenter.display_content.first }

Expand Down

0 comments on commit 35cd919

Please sign in to comment.