-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcard_test.rb
More file actions
51 lines (36 loc) · 1.8 KB
/
card_test.rb
File metadata and controls
51 lines (36 loc) · 1.8 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
require "test_helper"
class Flowbite::CardTest < Minitest::Test
include ViewComponent::TestHelpers
def test_renders_a_default_card
render_inline(Flowbite::Card.new) { "Card Content" }
assert_selector("div.p-6.bg-white.border.border-gray-200.rounded-lg.shadow-sm")
end
def test_passes_options_to_the_card_as_attributes
render_inline(Flowbite::Card.new(options: {id: "card-1"})) { "Card Content" }
assert_selector("div#card-1")
end
def test_adds_the_classes_to_the_default_classes
render_inline(Flowbite::Card.new(class: "custom-class another")) { "Card Content" }
assert_selector("div.p-6.bg-white.border.border-gray-200.rounded-lg.shadow-sm.custom-class.another")
end
def test_overrides_the_default_classes
render_inline(Flowbite::Card.new(options: {class: "custom-class another"})) { "Card Content" }
assert_no_selector("div.p-6.bg-white.border.border-gray-200.rounded-lg.shadow-sm")
assert_selector("div.custom-class.another")
end
def test_with_title_argument
render_inline(Flowbite::Card.new(title: {content: "Card Title"})) { "Card Content" }
assert_selector("h5.mb-2.text-2xl.font-bold.tracking-tight.text-gray-900.dark\\:text-white", text: "Card Title")
end
def test_passes_title_options_to_the_title
render_inline(Flowbite::Card.new(title: {content: "Card Title", options: {class: "custom-title-class"}})) { "Card Content" }
assert_selector("h5.custom-title-class", text: "Card Title")
end
def test_with_title_slot_when_using_with_title
render_inline(Flowbite::Card.new) do |component|
component.with_title { "<h1>This is the full title</h1>".html_safe }
end
assert_no_selector("h5.mb-2.text-2xl.font-bold.tracking-tight.text-gray-900.dark\\:text-white")
assert_selector("h1", text: "This is the full title")
end
end