Skip to content

Commit 41cafcf

Browse files
author
p_doub
committed
Add table components testing
1 parent cd0682d commit 41cafcf

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
require_relative '../../support/utils'
2+
include Utils
3+
4+
describe 'Table Components table, th, tr, td', type: :feature, js: true do
5+
6+
it 'Example 1' do
7+
8+
class ExamplePage < Page::Cell::Page
9+
10+
def response
11+
components {
12+
table class: 'foo' do
13+
tr class: 'bar' do
14+
th text: 'First'
15+
th text: 'Matestack'
16+
th text: 'Table'
17+
end
18+
tr do
19+
td text: 'One'
20+
td text: 'Two'
21+
td text: 'Three'
22+
end
23+
tr do
24+
td text: 'Uno'
25+
td text: 'Dos'
26+
td text: 'Tres'
27+
end
28+
end
29+
}
30+
end
31+
32+
end
33+
34+
visit '/example'
35+
36+
static_output = page.html
37+
38+
expected_static_output = <<~HTML
39+
<table class="foo">
40+
<tbody>
41+
<tr class="bar">
42+
<th>First</th>
43+
<th>Matestack</th>
44+
<th>Table</th>
45+
</tr>
46+
<tr>
47+
<td>One</td>
48+
<td>Two</td>
49+
<td>Three</td>
50+
</tr>
51+
<tr>
52+
<td>Uno</td>
53+
<td>Dos</td>
54+
<td>Tres</td>
55+
</tr>
56+
</tbody>
57+
</table>
58+
HTML
59+
60+
expect(stripped(static_output)).to include(stripped(expected_static_output))
61+
end
62+
63+
it 'Example 2' do
64+
65+
class ExamplePage < Page::Cell::Page
66+
67+
def prepare
68+
@users = ['Jonas', 'Pascal', 'Chris']
69+
@numbers = ['One', 'Two', 'Three']
70+
@numeros = ['Uno', 'Dos', 'Tres']
71+
end
72+
73+
def response
74+
components {
75+
table class: 'foo' do
76+
tr class: 'bar' do
77+
@users.each do |user|
78+
th text: user
79+
end
80+
end
81+
tr do
82+
@numbers.each do |number|
83+
td text: number
84+
end
85+
end
86+
tr do
87+
@numeros.each do |numero|
88+
td text: numero
89+
end
90+
end
91+
tr do
92+
td do
93+
plain 'Do'
94+
end
95+
td text: 'Custom'
96+
td do
97+
plain 'Stuff'
98+
end
99+
end
100+
end
101+
}
102+
end
103+
104+
end
105+
106+
visit '/example'
107+
108+
static_output = page.html
109+
110+
expected_static_output = <<~HTML
111+
<table class="foo">
112+
<tbody>
113+
<tr class="bar">
114+
<th>Jonas</th>
115+
<th>Pascal</th>
116+
<th>Chris</th>
117+
</tr>
118+
<tr>
119+
<td>One</td>
120+
<td>Two</td>
121+
<td>Three</td>
122+
</tr>
123+
<tr>
124+
<td>Uno</td>
125+
<td>Dos</td>
126+
<td>Tres</td>
127+
</tr>
128+
<tr>
129+
<td>Do</td>
130+
<td>Custom</td>
131+
<td>Stuff</td>
132+
</tr>
133+
</tbody>
134+
</table>
135+
HTML
136+
137+
expect(stripped(static_output)).to include(stripped(expected_static_output))
138+
end
139+
140+
end

0 commit comments

Comments
 (0)