@@ -203,7 +203,7 @@ class SearchHelperTest < ActionView::TestCase
203203 @active_tab = 'bar'
204204 actual = link_to_tab ( 'Foo' )
205205
206- assert_select Nokogiri ::HTML ::Document . parse ( actual ) , 'a' do |link |
206+ assert_select Nokogiri ::HTML ::Document . parse ( actual ) , 'a' do |link |
207207 assert_select '[class*=?]' , 'active' , count : 0
208208 assert_select '[class*=?]' , 'tab-link'
209209 assert_select '[aria-current=?]' , 'page' , count : 0
@@ -214,7 +214,7 @@ class SearchHelperTest < ActionView::TestCase
214214 @active_tab = 'foo'
215215 actual = link_to_tab ( 'Foo' )
216216
217- assert_select Nokogiri ::HTML ::Document . parse ( actual ) , 'a' do |link |
217+ assert_select Nokogiri ::HTML ::Document . parse ( actual ) , 'a' do |link |
218218 assert_select link , '[class*=?]' , 'active'
219219 assert_select link , '[aria-current=?]' , 'page' , count : 1
220220 end
@@ -231,4 +231,36 @@ class SearchHelperTest < ActionView::TestCase
231231 expected_url = 'https://mit.primo.exlibrisgroup.com/discovery/search?query=any%2Ccontains%2Cdata+%26+analytics&vid=01MIT_INST%3AMIT'
232232 assert_equal expected_url , primo_search_url ( query )
233233 end
234+
235+ test 'tab label defaults to target when label is nil' do
236+ @active_tab = 'sample_tab'
237+ actual = link_to_tab ( 'Sample Tab' , nil )
238+ assert_select Nokogiri ::HTML ::Document . parse ( actual ) , 'a' do |link |
239+ assert_equal link . text , 'Sample Tab'
240+ end
241+ end
242+
243+ test 'tab label uses label when label is provided' do
244+ @active_tab = 'sample_tab'
245+ actual = link_to_tab ( 'Sample Tab' , 'Custom Label' )
246+ assert_select Nokogiri ::HTML ::Document . parse ( actual ) , 'a' do |link |
247+ assert_equal link . text , 'Custom Label'
248+ end
249+ end
250+
251+ test 'tab param uses clean_target when label is nil' do
252+ @active_tab = 'sample_tab'
253+ actual = link_to_tab ( 'Sample Tab' , nil )
254+ assert_select Nokogiri ::HTML ::Document . parse ( actual ) , 'a' do |link |
255+ assert_equal link . first [ :href ] , '/results?tab=sample_tab'
256+ end
257+ end
258+
259+ test 'tab param uses clean_target when label is provided' do
260+ @active_tab = 'sample_tab'
261+ actual = link_to_tab ( 'Sample Tab' , 'Custom Label' )
262+ assert_select Nokogiri ::HTML ::Document . parse ( actual ) , 'a' do |link |
263+ assert_equal link . first [ :href ] , '/results?tab=sample_tab'
264+ end
265+ end
234266end
0 commit comments