Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Genia Kazymova committed Dec 12, 2023
1 parent 87c36ab commit 858b067
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions spec/lib/trln_argon/highwire_field_mapping_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
describe TrlnArgon::SolrDocument::HighwireFieldMapping do
include described_class
class SolrDocumentTestClass
include Blacklight::Solr::Document
include TrlnArgon::SolrDocument
end

describe '#highwire_metadata_tags' do
let(:document1) do
SolrDocumentTestClass.new(
'title_main' => 'Title',
'publisher_a' => 'Publisher',
'statement_of_responsibility_a' => [
{ name: 'Author 1', rel: 'author' },
{ name: 'Author 2', rel: 'editor' }
]
)
end

let(:document2) do
SolrDocumentTestClass.new(
'title_main' => 'Title',
'publisher_a' => 'Publisher'
)
end

it 'generates metadata tags based on the mapping' do
result = document1.highwire_metadata_tags
expect(result).to include(
['citation_title', 'Title'],
['citation_publisher', 'Publisher'],
['citation_author', { 'name' => 'Author 1', 'rel' => 'author' }],
['citation_author', { 'name' => 'Author 2', 'rel' => 'editor' }]
)
end

it 'does not include citation_author if there are no authors' do
result = document2.highwire_metadata_tags
expect(result).not_to include(['citation_author'])
end
end
end

0 comments on commit 858b067

Please sign in to comment.