|
2 | 2 |
|
3 | 3 | require "test_helper" |
4 | 4 |
|
5 | | -class AvoidGenericLinkTextCounterTest < LinterTestCase |
| 5 | +class AvoidGenericLinkTextTest < LinterTestCase |
6 | 6 | def linter_class |
7 | 7 | ERBLint::Linters::GitHub::Accessibility::AvoidGenericLinkText |
8 | 8 | end |
@@ -51,8 +51,7 @@ def test_warns_when_link_text_is_banned_text_with_punctuation_and_space |
51 | 51 | @linter.run(processed_source) |
52 | 52 |
|
53 | 53 | refute_empty @linter.offenses |
54 | | - # 3 offenses, 1 related to matching counter comment not present despite violations |
55 | | - assert_equal 4, @linter.offenses.count |
| 54 | + assert_equal 3, @linter.offenses.count |
56 | 55 | end |
57 | 56 |
|
58 | 57 | def test_does_not_warn_when_banned_text_is_part_of_more_text |
@@ -143,50 +142,17 @@ def test_handles_files_with_various_links |
143 | 142 | @linter.run(processed_source) |
144 | 143 |
|
145 | 144 | refute_empty @linter.offenses |
146 | | - # 3 offenses, 1 related to matching counter comment not present despite violations |
147 | | - assert_equal 4, @linter.offenses.count |
| 145 | + assert_equal 3, @linter.offenses.count |
148 | 146 | end |
149 | 147 |
|
150 | | - def test_does_not_warns_if_element_has_correct_counter_comment |
| 148 | + def test_does_not_warns_if_element_has_correct_counter_comment_if_config_enabled |
151 | 149 | @file = <<~ERB |
152 | 150 | <%# erblint:counter GitHub::Accessibility::AvoidGenericLinkTextCounter 1 %> |
153 | 151 | <a>Link</a> |
154 | 152 | ERB |
| 153 | + @linter.config.counter_enabled = true |
155 | 154 | @linter.run(processed_source) |
156 | 155 |
|
157 | 156 | assert_equal 0, @linter.offenses.count |
158 | 157 | end |
159 | | - |
160 | | - def test_autocorrects_when_ignores_are_not_correct |
161 | | - @file = <<~ERB |
162 | | - <p> |
163 | | - <a href="github.com" aria-label='Click here to learn more'>Click here</a> |
164 | | - <a href="github.com" aria-label='Some totally different text'>Click here</a> |
165 | | - <a href="github.com" aria-labelledby='someElement'>Click here</a> |
166 | | - </p> |
167 | | - <p> |
168 | | - <%= link_to "learn more", billing_path, "aria-label": "something" %> |
169 | | - <%= link_to "learn more", billing_path, aria: { label: "something" } %> |
170 | | - <%= link_to "learn more", billing_path, aria: { describedby: "element123" } %> |
171 | | - <%= link_to "learn more", billing_path, "aria-describedby": "element123" %> |
172 | | - </p> |
173 | | - ERB |
174 | | - refute_equal @file, corrected_content |
175 | | - |
176 | | - expected_content = <<~ERB |
177 | | - <%# erblint:counter GitHub::Accessibility::AvoidGenericLinkTextCounter 3 %> |
178 | | - <p> |
179 | | - <a href="github.com" aria-label='Click here to learn more'>Click here</a> |
180 | | - <a href="github.com" aria-label='Some totally different text'>Click here</a> |
181 | | - <a href="github.com" aria-labelledby='someElement'>Click here</a> |
182 | | - </p> |
183 | | - <p> |
184 | | - <%= link_to "learn more", billing_path, "aria-label": "something" %> |
185 | | - <%= link_to "learn more", billing_path, aria: { label: "something" } %> |
186 | | - <%= link_to "learn more", billing_path, aria: { describedby: "element123" } %> |
187 | | - <%= link_to "learn more", billing_path, "aria-describedby": "element123" %> |
188 | | - </p> |
189 | | - ERB |
190 | | - assert_equal expected_content, corrected_content |
191 | | - end |
192 | 158 | end |
0 commit comments