@@ -675,4 +675,45 @@ def source_filter_count(controller)
675675 assert_select '.primo-continuation' , count : 1
676676 assert_select '.primo-continuation h2' , text : /Continue your search in Search Our Collections/
677677 end
678+
679+ test 'primo results shows no results message when search returns no results on first page' do
680+ mock_primo = mock ( 'primo_search' )
681+ mock_primo . expects ( :search ) . returns ( { 'docs' => [ ] , 'total' => 0 } )
682+ PrimoSearch . expects ( :new ) . returns ( mock_primo )
683+
684+ mock_normalizer = mock ( 'normalizer' )
685+ mock_normalizer . expects ( :normalize ) . returns ( [ ] )
686+ NormalizePrimoResults . expects ( :new ) . returns ( mock_normalizer )
687+
688+ get '/results?q=nonexistentterm&tab=primo'
689+ assert_response :success
690+ assert_select '.no-results' , count : 1
691+ assert_select '.no-results p' , text : /No results found for your search/
692+ refute_select '.primo-continuation'
693+ end
694+
695+ test 'timdex results shows no results message when search returns no results on first page' do
696+ mock_response = mock ( 'timdex_response' )
697+ mock_errors = mock ( 'timdex_errors' )
698+ mock_errors . stubs ( :details ) . returns ( { } )
699+ mock_response . stubs ( :errors ) . returns ( mock_errors )
700+
701+ mock_data = mock ( 'timdex_data' )
702+ mock_data . stubs ( :to_h ) . returns ( {
703+ 'search' => {
704+ 'hits' => 0 ,
705+ 'aggregations' => { } ,
706+ 'records' => [ ]
707+ }
708+ } )
709+ mock_response . stubs ( :data ) . returns ( mock_data )
710+
711+ TimdexBase ::Client . expects ( :query ) . returns ( mock_response )
712+
713+ get '/results?q=nonexistentterm&tab=timdex'
714+ assert_response :success
715+ assert_select '.no-results' , count : 1
716+ assert_select '.no-results p' , text : /No results found for your search/
717+ refute_select '.primo-continuation'
718+ end
678719end
0 commit comments