-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathcontents_list_with_body_test.rb
55 lines (42 loc) · 1.61 KB
/
contents_list_with_body_test.rb
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
require "component_test_helper"
class ContentsListWithBodyTest < ComponentTestCase
def component_path
"components/contents_list_with_body"
end
def contents_list
[
{ href: "/one", text: "1. One" },
{ href: "/two", text: "2. Two" },
]
end
def block
"<p>Foo</p>".html_safe
end
test "renders nothing without a block" do
assert_empty render(component_path, contents: contents_list)
end
test "yields the block without contents data" do
assert_includes(render(component_path, {}) { block }, block)
end
test "renders a sticky-element-container" do
render(component_path, contents: contents_list) { block }
assert_select("#contents.app-c-contents-list-with-body")
assert_select("#contents[data-module='sticky-element-container']")
end
test "does not apply the sticky-element-container data-module without contents data" do
render(component_path, {}) { block }
assert_select("#contents[data-module='sticky-element-container']", count: 0)
end
test "renders a contents-list component" do
render(component_path, contents: contents_list) { block }
assert_select(".app-c-contents-list-with-body .gem-c-contents-list")
assert_select ".gem-c-contents-list__link[href='/one']", text: "1. One"
end
test "renders a back-to-top component" do
render(component_path, contents: contents_list) { block }
assert_select(%(.app-c-contents-list-with-body
.app-c-contents-list-with-body__link-wrapper
.app-c-contents-list-with-body__link-container
.app-c-back-to-top[href='#contents']))
end
end