forked from primer/view_components
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfeedback_message_test.rb
More file actions
56 lines (42 loc) · 1.81 KB
/
Copy pathfeedback_message_test.rb
File metadata and controls
56 lines (42 loc) · 1.81 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
52
53
54
55
56
# frozen_string_literal: true
require "components/test_helper"
class PrimerOpenProjectFeedbackMessageTest < Minitest::Test
include Primer::ComponentTestHelpers
def test_renders
render_inline(Primer::OpenProject::FeedbackMessage.new) do |component|
component.with_heading(tag: :h2).with_content("Some title")
component.with_description { "Some description" }
end
assert_selector "h2", text: "Some title"
assert_text "Some description"
# Check for default octicon and color
assert_selector ".octicon-check-circle.blankslate-icon.color-fg-success"
end
def test_does_not_render_if_no_heading_provided
render_inline(Primer::OpenProject::FeedbackMessage.new)
refute_component_rendered
end
def test_custom_icon
render_inline(Primer::OpenProject::FeedbackMessage.new(icon_arguments: { icon: "plus", color: :danger, classes: "test-class" })) do |component|
component.with_heading(tag: :h2).with_content("Some title")
end
assert_selector "h2", text: "Some title"
# Check for default octicon and color
assert_selector ".octicon-plus.blankslate-icon.color-fg-danger.test-class"
end
def test_renders_loading_spinner
render_inline(Primer::OpenProject::FeedbackMessage.new(loading: true)) do |component|
component.with_heading(tag: :h2) { "Ups, something went wrong" }
end
assert_selector("h2", text: "Ups, something went wrong")
assert_selector("svg.blankslate-image")
end
def test_renders_secondary_action
render_inline(Primer::OpenProject::FeedbackMessage.new) do |component|
component.with_heading(tag: :h2) { "Secondary Action" }
component.with_secondary_action(href: "/blubs").with_content("Skip")
end
assert_selector("h2", text: "Secondary Action")
assert_selector("a[href='/blubs']", text: "Skip")
end
end