Skip to content

Commit 47b7bef

Browse files
author
p_doub
committed
Add br && button specs
1 parent 24847ba commit 47b7bef

File tree

4 files changed

+96
-2
lines changed

4 files changed

+96
-2
lines changed

spec/usage/components/br_spec.rb

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
require_relative '../../support/utils'
2+
include Utils
3+
4+
describe 'Br Component', 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+
# simple br tag
13+
plain 'hello'
14+
br
15+
plain 'world!'
16+
17+
# multiple br tags
18+
plain 'hello'
19+
br times: 5
20+
plain 'world!'
21+
}
22+
end
23+
24+
end
25+
26+
visit "/example"
27+
28+
static_output = page.html
29+
30+
expected_static_output = <<~HTML
31+
hello
32+
<br>
33+
world!
34+
35+
hello
36+
<br>
37+
<br>
38+
<br>
39+
<br>
40+
<br>
41+
world!
42+
HTML
43+
44+
expect(stripped(static_output)).to include(stripped(expected_static_output))
45+
end
46+
47+
end

spec/usage/components/button_spec.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
require_relative '../../support/utils'
2+
include Utils
3+
4+
describe 'Button Component', 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+
# simple button
13+
button text: 'Click me, m8'
14+
15+
# enhanced button
16+
button id: "my-button-id-1", class: "my-button-class", text: "Click me, m8"
17+
18+
# button with block inside
19+
button do
20+
plain 'Click me too, m8'
21+
end
22+
23+
# button with text and block - does render text and neglect block
24+
button text: 'I am prefered' do
25+
plain 'I will not get shown'
26+
end
27+
}
28+
end
29+
30+
end
31+
32+
visit "/example"
33+
34+
static_output = page.html
35+
36+
expected_static_output = <<~HTML
37+
<button>Click me, m8</button>
38+
<button id="my-button-id-1" class="my-button-class">
39+
Click me, m8
40+
</button>
41+
<button>Click me too, m8</button>
42+
<button>I am prefered</button>
43+
HTML
44+
# <!-- <button id='my-button-id-1' class='my-button-class'>Click me, m8</button> -->
45+
46+
expect(stripped(static_output)).to include(stripped(expected_static_output))
47+
end
48+
49+
end

spec/usage/components/div_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def response
2626

2727
visit "/example"
2828

29-
3029
static_output = page.html
3130

3231
expected_static_output = <<~HTML

spec/usage/components/form_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def expect_params(params)
1414

1515
end
1616

17-
1817
describe "Form Component", type: :feature, js: true do
1918

2019
before :all do

0 commit comments

Comments
 (0)