@@ -7,83 +7,156 @@ def linter_class
77 ERBLint ::Linters ::GitHub ::Accessibility ::AvoidGenericLinkTextCounter
88 end
99
10- def test_warns_when_link_text_is_click_here
11- @file = "<a>Click here</a>"
12- @linter . run ( processed_source )
10+ # def test_warns_when_link_text_is_click_here
11+ # @file = "<a>Click here</a>"
12+ # @linter.run(processed_source)
1313
14- refute_empty @linter . offenses
15- end
14+ # refute_empty @linter.offenses
15+ # end
1616
17- def test_warns_when_link_text_is_learn_more
18- @file = "<a>Learn more</a>"
19- @linter . run ( processed_source )
17+ # def test_warns_when_link_text_is_learn_more
18+ # @file = "<a>Learn more</a>"
19+ # @linter.run(processed_source)
2020
21- refute_empty @linter . offenses
22- end
21+ # refute_empty @linter.offenses
22+ # end
2323
24- def test_warns_when_link_text_is_read_more
25- @file = "<a>Read more</a>"
26- @linter . run ( processed_source )
24+ # def test_warns_when_link_text_is_read_more
25+ # @file = "<a>Read more</a>"
26+ # @linter.run(processed_source)
2727
28- refute_empty @linter . offenses
29- end
28+ # refute_empty @linter.offenses
29+ # end
3030
31- def test_warns_when_link_text_is_more
32- @file = "<a>More</a>"
33- @linter . run ( processed_source )
31+ # def test_warns_when_link_text_is_more
32+ # @file = "<a>More</a>"
33+ # @linter.run(processed_source)
3434
35- refute_empty @linter . offenses
36- end
35+ # refute_empty @linter.offenses
36+ # end
3737
38- def test_warns_when_link_text_is_link
39- @file = "<a>Link</a>"
40- @linter . run ( processed_source )
38+ # def test_warns_when_link_text_is_link
39+ # @file = "<a>Link</a>"
40+ # @linter.run(processed_source)
4141
42- refute_empty @linter . offenses
43- end
42+ # refute_empty @linter.offenses
43+ # end
4444
45- def test_does_not_warn_when_banned_text_is_part_of_more_text
46- @file = "<a>Learn more about GitHub Stars</a>"
47- @linter . run ( processed_source )
45+ # def test_does_not_warn_when_banned_text_is_part_of_more_text
46+ # @file = "<a>Learn more about GitHub Stars</a>"
47+ # @linter.run(processed_source)
4848
49- assert_empty @linter . offenses
50- end
49+ # assert_empty @linter.offenses
50+ # end
5151
52- def test_warns_when_link_rails_helper_text_is_banned_text
53- @file = "<%= link_to('click here', redirect_url, id: 'redirect') %>"
54- @linter . run ( processed_source )
52+ # def test_ignores_when_aria_label_with_variable_is_set_on_link_tag
53+ # @file = <<~ERB
54+ # <a aria-label="<%= tooltip_text %>">Learn more</a>
55+ # ERB
56+ # @linter.run(processed_source)
5557
56- refute_empty @linter . offenses
57- end
58+ # assert_empty @linter.offenses
59+ # end
5860
59- def test_does_not_warn_when_generic_text_is_link_rails_helper_sub_text
60- @file = "<%= link_to('click here to learn about github', redirect_url, id: 'redirect') %>"
61- @linter . run ( processed_source )
61+ # def test_flags_when_aria_label_does_not_include_visible_link_text
62+ # @file = <<~ERB
63+ # <a aria-label="GitHub Sponsors">Learn more</a>
64+ # ERB
65+ # @linter.run(processed_source)
6266
63- assert_empty @linter . offenses
64- end
67+ # refute_empty @linter.offenses
68+ # end
6569
66- def test_does_not_warns_if_element_has_correct_counter_comment
67- @file = <<~ERB
68- <%# erblint:counter GitHub::Accessibility::AvoidGenericLinkTextCounter 1 %>
69- < a > Link</ a >
70- ERB
71- @linter . run ( processed_source )
70+ # def test_does_not_flag_when_aria_label_includes_visible_link_text
71+ # @file = <<~ERB
72+ # <a aria-label="Learn more about GitHub Sponsors">Learn more</a>
73+ # ERB
74+ # @linter.run(processed_source)
7275
73- assert_equal 0 , @linter . offenses . count
74- end
76+ # assert_empty @linter.offenses
77+ # end
78+
79+ # def test_ignores_when_aria_labelledby_is_set_on_link_tag
80+ # @file = "<a aria-labelledby='someElement'>Click here</a>"
81+ # @linter.run(processed_source)
82+
83+ # assert_empty @linter.offenses
84+ # end
85+
86+ # def test_warns_when_link_rails_helper_text_is_banned_text
87+ # @file = "<%= link_to('click here', redirect_url, id: 'redirect') %>"
88+ # @linter.run(processed_source)
89+
90+ # refute_empty @linter.offenses
91+ # end
7592
76- def test_autocorrects_when_ignores_are_not_correct
93+ # def test_ignores_when_link_rails_helper_text_is_banned_text_with_aria_labelled_by
94+ # @file = "<%= link_to('learn more', 'aria-labelledby': 'element1234', id: 'redirect') %>"
95+ # @linter.run(processed_source)
96+
97+ # assert_empty @linter.offenses
98+ # end
99+
100+ # def test_ignores_when_link_rails_helper_text_is_banned_text_with_aria_label_that_cannot_be_parsed_by_linter
101+ # @file = <<~ERB
102+ # <%= link_to('learn more', 'aria-label': some_variable, id: 'redirect') %>
103+ # ERB
104+ # @linter.run(processed_source)
105+
106+ # assert_empty @linter.offenses
107+ # end
108+
109+ def test_ignores_when_link_rails_helper_text_is_banned_text_with_aria_label_that_cannot_be_parsed_by_linter_because_interpolated
77110 @file = <<~ERB
78- <%# erblint:counter GitHub::Accessibility::AvoidGenericLinkTextCounter 2 %>
79- < a > Link</ a >
111+ <%= link_to ( 'learn more' , 'aria-label' : "Learn #{ @variable } ", id: 'redirect') %>
80112 ERB
81- refute_equal @file , corrected_content
113+ @linter . run ( processed_source )
82114
83- expected_content = <<~ERB
84- <%# erblint:counter GitHub::Accessibility::AvoidGenericLinkTextCounter 1 %>
85- < a > Link</ a >
86- ERB
87- assert_equal expected_content , corrected_content
115+ assert_empty @linter . offenses
88116 end
117+
118+ # def test_ignores_when_link_rails_helper_text_is_banned_text_with_aria_label_that_contains_visible_text
119+ # @file = "<%= link_to('learn more', 'aria-label': 'learn more about GitHub', id: 'redirect') %>"
120+ # @linter.run(processed_source)
121+
122+ # assert_empty @linter.offenses
123+ # end
124+
125+ # def test_warns_when_link_rails_helper_text_is_banned_text_with_aria_label_hash
126+ # @file = "<%= link_to('learn more', aria: { label: 'learn more about GitHub' }, id: 'redirect') %>"
127+ # @linter.run(processed_source)
128+
129+ # assert_empty @linter.offenses
130+ # end
131+
132+ # def test_does_not_warn_when_generic_text_is_link_rails_helper_sub_text
133+ # @file = "<%= link_to('click here to learn about github', redirect_url, id: 'redirect') %>"
134+ # @linter.run(processed_source)
135+
136+ # assert_empty @linter.offenses
137+ # end
138+
139+ # def test_does_not_warns_if_element_has_correct_counter_comment
140+ # @file = <<~ERB
141+ # <%# erblint:counter GitHub::Accessibility::AvoidGenericLinkTextCounter 1 %>
142+ # <a>Link</a>
143+ # ERB
144+ # @linter.run(processed_source)
145+
146+ # assert_equal 0, @linter.offenses.count
147+ # end
148+
149+ # def test_autocorrects_when_ignores_are_not_correct
150+ # @file = <<~ERB
151+ # <%# erblint:counter GitHub::Accessibility::AvoidGenericLinkTextCounter 2 %>
152+ # <a>Link</a>
153+ # ERB
154+ # refute_equal @file, corrected_content
155+
156+ # expected_content = <<~ERB
157+ # <%# erblint:counter GitHub::Accessibility::AvoidGenericLinkTextCounter 1 %>
158+ # <a>Link</a>
159+ # ERB
160+ # assert_equal expected_content, corrected_content
161+ # end
89162end
0 commit comments