-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdetails_has_summary_test.rb
More file actions
75 lines (59 loc) · 1.93 KB
/
details_has_summary_test.rb
File metadata and controls
75 lines (59 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# frozen_string_literal: true
require "test_helper"
class DetailsHasSummary < LinterTestCase
def linter_class
ERBLint::Linters::GitHub::Accessibility::DetailsHasSummary
end
def test_warns_if_details_doesnt_have_a_summary
@file = "<details>I don't have a summary element</details>"
@linter.run(processed_source)
assert_equal 1, @linter.offenses.count
end
def test_does_not_warn_if_details_has_a_summary_in_a_weird_place
@file = "<details><p>Surprise text!</p><summary>Expand me!</summary></details>"
@linter.run(processed_source)
assert_empty @linter.offenses
end
def test_does_not_warn_if_details_has_a_summary
@file = "<details><summary>Expand me!</summary><button>Surprise button!</button></details>"
@linter.run(processed_source)
assert_empty @linter.offenses
end
def test_does_warns_if_details_has_a_summary_as_an_inner_child
@file = "<details><p><summary>Expand me!</summary></p><button>Surprise button!</button></details>"
@linter.run(processed_source)
assert_equal 1, @linter.offenses.count
end
def test_doesnt_warns_if_details_has_a_summary_content_tag
@file = <<~ERB
<details>
<%= content_tag(:summary) { "Expand me!" } %>
<p>Surprise text!</p>
</details>
ERB
@linter.run(processed_source)
assert_empty @linter.offenses
end
def test_doesnt_warns_if_details_has_a_summary_content_tag_with_do_block
@file = <<~ERB
<details>
<%= content_tag(:summary) do %>
Expand me!
<% end %>
<p>Surprise text!</p>
</details>
ERB
@linter.run(processed_source)
assert_empty @linter.offenses
end
def test_warns_if_details_has_a_non_summary_content_tag
@file = <<~ERB
<details>
<%= content_tag(:div) { "Expand me!" } %>
<p>Surprise text!</p>
</details>
ERB
@linter.run(processed_source)
assert_equal 1, @linter.offenses.count
end
end