-
Notifications
You must be signed in to change notification settings - Fork 20
/
organisation_logo_spec.rb
74 lines (60 loc) · 2.78 KB
/
organisation_logo_spec.rb
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require "rails_helper"
describe "Organisation logo", type: :view do
def component_name
"organisation_logo"
end
it "error if no parameters passed in" do
assert_raises do
render_component({})
end
end
it "shows an organisation name" do
render_component(organisation: { name: "Organisation name" })
assert_select ".gem-c-organisation-logo .gem-c-organisation-logo__container", text: "Organisation name"
end
it "adds branding to the wrapping container" do
render_component(organisation: { name: "Branded", brand: "department-for-business-and-trade" })
assert_select ".gem-c-organisation-logo.brand--department-for-business-and-trade", text: "Branded"
end
it "includes a link when a URL is provided" do
render_component(organisation: { name: "Linked", url: "/somewhere" })
assert_select ".gem-c-organisation-logo a.gem-c-organisation-logo__container.gem-c-organisation-logo__link[href='/somewhere']", text: "Linked"
end
it "doesn't include a link when a URL is not provided" do
render_component(organisation: { name: "Not linked" })
assert_select "a.gem-c-organisation-logo__container.gem-c-organisation-logo__link[href='/somewhere']", false
assert_select ".gem-c-organisation-logo__container"
end
it "adds a crest class when specified" do
render_component(organisation: { name: "Crested", crest: "single-identity" })
assert_select ".gem-c-organisation-logo__container.gem-c-organisation-logo__crest.gem-c-organisation-logo__crest--single-identity"
end
it "renders an image when specified" do
render_component(organisation: { name: "Custom image", image: { url: "/url", alt_text: "alt" } })
assert_select ".gem-c-organisation-logo__container img[src='/url'][alt='alt']"
end
it "uses a div by default" do
render_component(organisation: { name: "Name" })
assert_select "div.gem-c-organisation-logo"
end
it "uses a heading when specified" do
render_component(organisation: { name: "Name" }, heading_level: 3)
assert_select "h3.gem-c-organisation-logo"
end
it "uses a div when a inappropriate heading level is used" do
render_component(organisation: { name: "Name" }, heading_level: 7)
assert_select "div.gem-c-organisation-logo"
end
it "uses a div when a inappropriate parameter is passed" do
render_component(organisation: { name: "Name" }, heading_level: "m")
assert_select "div.gem-c-organisation-logo"
end
it "renders a inline container when set" do
render_component(organisation: { name: "Name" }, inline: true)
assert_select "div.gem-c-organisation-logo__container--inline"
end
it "renders inline link when set" do
render_component(organisation: { name: "Name", url: "/some-link" }, inline: true)
assert_select "a.gem-c-organisation-logo__container--inline"
end
end