Skip to content

Commit 24847ba

Browse files
author
p_doub
committed
Add test for time tag/component && remove unnecessary configuration
1 parent 30b2377 commit 24847ba

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

app/concepts/time/cell/time.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ module Time::Cell
22
class Time < Component::Cell::Static
33

44
def setup
5-
@tag_attributes.merge!({ "class": options[:class],
6-
"id": component_id,
5+
@tag_attributes.merge!({
76
"datetime": options[:datetime] ||= nil
87
})
98
end

spec/usage/components/time_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 'Time 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 time tag
13+
pg do
14+
plain 'This should show '
15+
time class: 'my-simple-time' do
16+
plain '12:00'
17+
end
18+
end
19+
20+
# time tag with timestamp
21+
pg id: 'my-parent-paragraph' do
22+
plain 'Today is '
23+
time id: 'example-timestamp', datetime: DateTime.new(2019,2,12,10,38,39,'+02:00') do
24+
plain 'July 7'
25+
end
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+
<p>This should show <time class='my-simple-time'>12:00</time></p>
38+
39+
<p id='my-parent-paragraph'>
40+
Today is <time datetime='2019-02-12T10:38:39+02:00' id='example-timestamp'>July 7</time>
41+
</p>"
42+
HTML
43+
44+
expect(stripped(static_output)).to include(stripped(expected_static_output))
45+
end
46+
47+
end

0 commit comments

Comments
 (0)