@@ -33,6 +33,28 @@ def test_labels_list_with_header
3333 assert_selector "ul[aria-labelledby='#{ id } ']"
3434 end
3535
36+ def test_renders_list_with_list_arguments
37+ render_inline ( Primer ::Beta ::BorderBox . new ( list_arguments : { id : "fake-tbody" , role : "rowgroup" } ) ) do |component |
38+ component . with_row { "Row" }
39+ end
40+
41+ assert_selector "ul#fake-tbody"
42+ assert_selector 'ul[role="rowgroup"]'
43+ end
44+
45+ def test_labels_list_with_header_and_additional_label
46+ render_inline ( Primer ::Beta ::BorderBox . new ( list_arguments : { aria : { labelledby : "my-footer" } } ) ) do |component |
47+ component . with_header { "Header" }
48+ component . with_row { "Row" }
49+ component . with_footer ( id : "my-footer" ) { "Footer" }
50+ end
51+
52+ header_id = page . find_css ( ".Box-header" ) . first [ :id ]
53+ footer_id = page . find_css ( ".Box-footer" ) . first [ :id ]
54+ assert_selector "ul[aria-labelledby*='#{ header_id } ']"
55+ assert_selector "ul[aria-labelledby*='#{ footer_id } ']"
56+ end
57+
3658 def test_renders_body
3759 render_inline ( Primer ::Beta ::BorderBox . new ) do |component |
3860 component . with_body { "Body" }
@@ -69,6 +91,24 @@ def test_renders_the_list_element_with_an_id_if_provided
6991 assert_selector ( "li.Box-row" , count : 1 )
7092 end
7193
94+ def test_warns_when_list_id_param_passed
95+ with_silence_deprecations ( false ) do
96+ ::Primer ::ViewComponents . deprecation . expects ( :warn ) . with ( "The `list_id:` param is deprecated. Use `list_arguments: { id: ... }` instead. It will be removed in a future version." ) . once
97+ render_inline ( Primer ::Beta ::BorderBox . new ( list_id : "an-id" ) ) do |component |
98+ component . with_row { "First" }
99+ end
100+ end
101+ end
102+
103+ def test_list_arguments_id_takes_precedence_over_deprecated_list_id
104+ render_inline ( Primer ::Beta ::BorderBox . new ( list_id : "old-id" , list_arguments : { id : "new-id" } ) ) do |component |
105+ component . with_row { "First" }
106+ end
107+
108+ assert_selector ( "ul#new-id" , count : 1 )
109+ assert_no_selector ( "ul#old-id" )
110+ end
111+
72112 def test_renders_condensed
73113 render_inline ( Primer ::Beta ::BorderBox . new ( padding : :condensed ) ) do |component |
74114 component . with_body { "Body" }
0 commit comments