Skip to content

Commit 22121d1

Browse files
committed
Adds tests for eyebrow mapping
1 parent ec22174 commit 22121d1

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

test/models/normalize_primo_record_test.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,4 +428,26 @@ def cdi_record
428428
normalized = NormalizePrimoRecord.new(full_record, 'test query').normalize
429429
assert_equal 'primo', normalized[:api]
430430
end
431+
432+
# Test eyebrow mapping
433+
test 'sets eyebrow to MIT Libraries Catalog for Alma records' do
434+
normalized = NormalizePrimoRecord.new(alma_record, 'test').normalize
435+
assert_equal 'MIT Libraries Catalog', normalized[:eyebrow]
436+
assert_includes normalized.keys, :eyebrow
437+
end
438+
439+
test 'sets eyebrow to MIT Libraries Catalog: Articles for CDI records' do
440+
normalized = NormalizePrimoRecord.new(cdi_record, 'test').normalize
441+
assert_equal 'MIT Libraries Catalog: Articles', normalized[:eyebrow]
442+
assert_includes normalized.keys, :eyebrow
443+
end
444+
445+
# This really should never happen, but this test confirms things don't break if it does
446+
test 'sets eyebrow to MIT Libraries Catalog: Articles when identifier is missing' do
447+
record = minimal_record.dup
448+
record.delete('recordid')
449+
normalized = NormalizePrimoRecord.new(record, 'test').normalize
450+
assert_equal 'MIT Libraries Catalog: Articles', normalized[:eyebrow]
451+
assert_includes normalized.keys, :eyebrow
452+
end
431453
end

test/models/normalize_timdex_record_test.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,45 @@ def minimal_record
223223
normalized = NormalizeTimdexRecord.new(full_record, 'test').normalize
224224
assert_equal 'timdex', normalized[:api]
225225
end
226+
227+
# Test eyebrow mapping
228+
test 'maps DSpace@MIT source to eyebrow label' do
229+
record = full_record.dup
230+
record['source'] = 'DSpace@MIT'
231+
normalized = NormalizeTimdexRecord.new(record, 'test').normalize
232+
assert_equal 'DSpace@MIT (MIT Research)', normalized[:eyebrow]
233+
assert_includes normalized.keys, :eyebrow
234+
end
235+
236+
test 'maps LibGuides source to eyebrow label' do
237+
record = full_record.dup
238+
record['source'] = 'LibGuides'
239+
normalized = NormalizeTimdexRecord.new(record, 'test').normalize
240+
assert_equal 'MIT Libraries Website: Guides', normalized[:eyebrow]
241+
assert_includes normalized.keys, :eyebrow
242+
end
243+
244+
test 'maps OpenGeoMetadata GIS Resources source to eyebrow label' do
245+
record = full_record.dup
246+
record['source'] = 'OpenGeoMetadata GIS Resources'
247+
normalized = NormalizeTimdexRecord.new(record, 'test').normalize
248+
assert_equal 'Non-MIT GeoSpatial Data', normalized[:eyebrow]
249+
assert_includes normalized.keys, :eyebrow
250+
end
251+
252+
test 'maps MIT GIS Resources source to eyebrow label' do
253+
record = full_record.dup
254+
record['source'] = 'MIT GIS Resources'
255+
normalized = NormalizeTimdexRecord.new(record, 'test').normalize
256+
assert_equal 'MIT GeoSpatial Data', normalized[:eyebrow]
257+
assert_includes normalized.keys, :eyebrow
258+
end
259+
260+
test 'uses source value as eyebrow for unmapped sources' do
261+
record = full_record.dup
262+
record['source'] = 'Custom Repository'
263+
normalized = NormalizeTimdexRecord.new(record, 'test').normalize
264+
assert_equal 'Custom Repository', normalized[:eyebrow]
265+
assert_includes normalized.keys, :eyebrow
266+
end
226267
end

0 commit comments

Comments
 (0)