govuk-design-system-rails 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/helpers/govuk_design_system/accordion_helper.rb +7 -0
- data/app/helpers/govuk_design_system/back_link_helper.rb +13 -0
- data/app/helpers/govuk_design_system/breadcrumbs_helper.rb +7 -0
- data/app/helpers/govuk_design_system/button_helper.rb +71 -0
- data/app/helpers/govuk_design_system/checkboxes_helper.rb +8 -0
- data/app/helpers/govuk_design_system/components_helper.rb +13 -0
- data/app/helpers/govuk_design_system/cookie_banner_helper.rb +7 -0
- data/app/helpers/govuk_design_system/date_input_helper.rb +8 -0
- data/app/helpers/govuk_design_system/details_helper.rb +32 -0
- data/app/helpers/govuk_design_system/error_message_helper.rb +7 -0
- data/app/helpers/govuk_design_system/error_summary_helper.rb +20 -0
- data/app/helpers/govuk_design_system/fieldset_helper.rb +9 -0
- data/app/helpers/govuk_design_system/file_upload_helper.rb +59 -0
- data/app/helpers/govuk_design_system/header_helper.rb +7 -0
- data/app/helpers/govuk_design_system/hint_helper.rb +7 -0
- data/app/helpers/govuk_design_system/hmcts_badge_helper.rb +7 -0
- data/app/helpers/govuk_design_system/hmcts_banner_helper.rb +7 -0
- data/app/helpers/govuk_design_system/input_helper.rb +8 -0
- data/app/helpers/govuk_design_system/inset_text_helper.rb +9 -0
- data/app/helpers/govuk_design_system/label_helper.rb +7 -0
- data/app/helpers/govuk_design_system/notification_banner_helper.rb +8 -0
- data/app/helpers/govuk_design_system/phase_banner_helper.rb +21 -0
- data/app/helpers/govuk_design_system/radios_helper.rb +8 -0
- data/app/helpers/govuk_design_system/select_helper.rb +8 -0
- data/app/helpers/govuk_design_system/skip_link_helper.rb +13 -0
- data/app/helpers/govuk_design_system/summary_list_helper.rb +7 -0
- data/app/helpers/govuk_design_system/tabs_helper.rb +7 -0
- data/app/helpers/govuk_design_system/tag_helper.rb +8 -0
- data/app/helpers/govuk_design_system/textarea_helper.rb +8 -0
- data/app/helpers/govuk_design_system/warning_text_helper.rb +20 -0
- data/app/views/components/_govuk_accordion.html.erb +44 -0
- data/app/views/components/_govuk_action_link.html.erb +12 -0
- data/app/views/components/_govuk_breadcrumbs.html.erb +25 -0
- data/app/views/components/_govuk_checkboxes.html.erb +125 -0
- data/app/views/components/_govuk_cookie_banner.html.erb +75 -0
- data/app/views/components/_govuk_date_input.html.erb +94 -0
- data/app/views/components/_govuk_error_message.html.erb +13 -0
- data/app/views/components/_govuk_error_summary.html.erb +32 -0
- data/app/views/components/_govuk_fieldset.html.erb +21 -0
- data/app/views/components/_govuk_header.html.erb +64 -0
- data/app/views/components/_govuk_hint.html.erb +7 -0
- data/app/views/components/_govuk_hr.html.erb +1 -0
- data/app/views/components/_govuk_input.html.erb +97 -0
- data/app/views/components/_govuk_inset_text.html.erb +10 -0
- data/app/views/components/_govuk_label.html.erb +18 -0
- data/app/views/components/_govuk_notification_banner.html.erb +68 -0
- data/app/views/components/_govuk_radios.html.erb +141 -0
- data/app/views/components/_govuk_select.html.erb +105 -0
- data/app/views/components/_govuk_summary_list.html.erb +39 -0
- data/app/views/components/_govuk_tabs.html.erb +46 -0
- data/app/views/components/_govuk_textarea.html.erb +70 -0
- data/app/views/components/_hmcts_banner.html.erb +33 -0
- data/app/views/form_components/_govuk_checkboxes.html.erb +21 -0
- data/app/views/form_components/_govuk_date_input.html.erb +32 -0
- data/app/views/form_components/_govuk_input.html.erb +11 -0
- data/app/views/form_components/_govuk_radios.html.erb +24 -0
- data/app/views/form_components/_govuk_select.html.erb +25 -0
- data/app/views/form_components/_govuk_textarea.html.erb +11 -0
- data/lib/govuk-design-system-rails.rb +1 -0
- data/lib/govuk_design_system/engine.rb +50 -0
- data/lib/govuk_design_system.rb +4 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/javascript/packs/application.js +15 -0
- data/spec/dummy/app/jobs/application_job.rb +7 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +33 -0
- data/spec/dummy/config/application.rb +38 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +76 -0
- data/spec/dummy/config/environments/production.rb +120 -0
- data/spec/dummy/config/environments/test.rb +59 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +12 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +8 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/permissions_policy.rb +11 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +43 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/config.ru +6 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/development_secret.txt +1 -0
- data/spec/helpers/govuk_design_system/accordion_helper_spec.rb +353 -0
- data/spec/helpers/govuk_design_system/breadcrumbs_helper_spec.rb +90 -0
- data/spec/helpers/govuk_design_system/button_helper_spec.rb +34 -0
- data/spec/helpers/govuk_design_system/checkboxes_helper_spec.rb +146 -0
- data/spec/helpers/govuk_design_system/cookie_banner_helper_spec.rb +65 -0
- data/spec/helpers/govuk_design_system/date_input_helper_spec.rb +63 -0
- data/spec/helpers/govuk_design_system/details_helper_spec.rb +42 -0
- data/spec/helpers/govuk_design_system/error_message_helper_spec.rb +18 -0
- data/spec/helpers/govuk_design_system/error_summary_helper_spec.rb +39 -0
- data/spec/helpers/govuk_design_system/header_helper_spec.rb +138 -0
- data/spec/helpers/govuk_design_system/hint_helper_spec.rb +20 -0
- data/spec/helpers/govuk_design_system/hmcts_badge_helper_spec.rb +16 -0
- data/spec/helpers/govuk_design_system/hmcts_banner_helper_spec.rb +59 -0
- data/spec/helpers/govuk_design_system/input_helper_spec.rb +157 -0
- data/spec/helpers/govuk_design_system/inset_text_helper_spec.rb +58 -0
- data/spec/helpers/govuk_design_system/label_helper_spec.rb +21 -0
- data/spec/helpers/govuk_design_system/notification_banner_helper_spec.rb +98 -0
- data/spec/helpers/govuk_design_system/radios_helper_spec.rb +270 -0
- data/spec/helpers/govuk_design_system/select_helper_spec.rb +85 -0
- data/spec/helpers/govuk_design_system/summary_list_helper_spec.rb +138 -0
- data/spec/helpers/govuk_design_system/tabs_helper_spec.rb +129 -0
- data/spec/helpers/govuk_design_system/tag_helper_spec.rb +17 -0
- data/spec/helpers/govuk_design_system/textarea_helper_spec.rb +67 -0
- data/spec/rails_helper.rb +64 -0
- data/spec/spec_helper.rb +116 -0
- metadata +401 -0
@@ -0,0 +1,270 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe GovukDesignSystem::RadiosHelper, type: :helper do
|
4
|
+
describe "#govukRadios" do
|
5
|
+
it "returns the correct HTML when there is a hint" do
|
6
|
+
html = helper.govukRadios({
|
7
|
+
classes: "govuk-radios--inline",
|
8
|
+
idPrefix: "changed-name",
|
9
|
+
name: "changed-name",
|
10
|
+
fieldset: {
|
11
|
+
legend: {
|
12
|
+
text: "Have you changed your name?",
|
13
|
+
isPageHeading: true,
|
14
|
+
classes: "govuk-fieldset__legend--l"
|
15
|
+
}
|
16
|
+
},
|
17
|
+
hint: {
|
18
|
+
text: "This includes changing your last name or spelling your name differently."
|
19
|
+
},
|
20
|
+
items: [
|
21
|
+
{
|
22
|
+
value: "yes",
|
23
|
+
text: "Yes"
|
24
|
+
},
|
25
|
+
{
|
26
|
+
value: "no",
|
27
|
+
text: "No"
|
28
|
+
}
|
29
|
+
]
|
30
|
+
})
|
31
|
+
|
32
|
+
expect(html).to match_html(<<~HTML)
|
33
|
+
<div class="govuk-form-group">
|
34
|
+
<fieldset class="govuk-fieldset" aria-describedby="changed-name-hint">
|
35
|
+
<legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
|
36
|
+
<h1 class="govuk-fieldset__heading">
|
37
|
+
Have you changed your name?
|
38
|
+
</h1>
|
39
|
+
</legend>
|
40
|
+
<div id="changed-name-hint" class="govuk-hint">
|
41
|
+
This includes changing your last name or spelling your name differently.
|
42
|
+
</div>
|
43
|
+
<div class="govuk-radios govuk-radios--inline" data-module="govuk-radios">
|
44
|
+
<div class="govuk-radios__item">
|
45
|
+
<input class="govuk-radios__input" id="changed-name-1" name="changed-name" type="radio" value="yes">
|
46
|
+
<label class="govuk-label govuk-radios__label" for="changed-name-1">
|
47
|
+
Yes
|
48
|
+
</label>
|
49
|
+
</div>
|
50
|
+
<div class="govuk-radios__item">
|
51
|
+
<input class="govuk-radios__input" id="changed-name-2" name="changed-name" type="radio" value="no">
|
52
|
+
<label class="govuk-label govuk-radios__label" for="changed-name-2">
|
53
|
+
No
|
54
|
+
</label>
|
55
|
+
</div>
|
56
|
+
</div>
|
57
|
+
</fieldset>
|
58
|
+
</div>
|
59
|
+
HTML
|
60
|
+
end
|
61
|
+
|
62
|
+
it "returns the correct HTML when there is an error message" do
|
63
|
+
html = helper.govukRadios({
|
64
|
+
idPrefix: "where-do-you-live",
|
65
|
+
name: "where-do-you-live",
|
66
|
+
fieldset: {
|
67
|
+
legend: {
|
68
|
+
text: "Where do you live?",
|
69
|
+
isPageHeading: true,
|
70
|
+
classes: "govuk-fieldset__legend--l"
|
71
|
+
}
|
72
|
+
},
|
73
|
+
items: [
|
74
|
+
{
|
75
|
+
value: "england",
|
76
|
+
text: "England"
|
77
|
+
},
|
78
|
+
{
|
79
|
+
value: "scotland",
|
80
|
+
text: "Scotland"
|
81
|
+
},
|
82
|
+
{
|
83
|
+
value: "wales",
|
84
|
+
text: "Wales"
|
85
|
+
},
|
86
|
+
{
|
87
|
+
value: "northern-ireland",
|
88
|
+
text: "Northern Ireland"
|
89
|
+
}
|
90
|
+
],
|
91
|
+
errorMessage: {
|
92
|
+
text: "Select the country where you live"
|
93
|
+
}
|
94
|
+
})
|
95
|
+
|
96
|
+
expect(html).to match_html(<<~HTML)
|
97
|
+
<div class="govuk-form-group govuk-form-group--error">
|
98
|
+
<fieldset class="govuk-fieldset" aria-describedby="where-do-you-live-error">
|
99
|
+
<legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
|
100
|
+
<h1 class="govuk-fieldset__heading">
|
101
|
+
Where do you live?
|
102
|
+
</h1>
|
103
|
+
</legend>
|
104
|
+
<p id="where-do-you-live-error" class="govuk-error-message">
|
105
|
+
<span class="govuk-visually-hidden">Error:</span> Select the country where you live
|
106
|
+
</p>
|
107
|
+
<div class="govuk-radios" data-module="govuk-radios">
|
108
|
+
<div class="govuk-radios__item">
|
109
|
+
<input class="govuk-radios__input" id="where-do-you-live-1" name="where-do-you-live" type="radio" value="england">
|
110
|
+
<label class="govuk-label govuk-radios__label" for="where-do-you-live-1">
|
111
|
+
England
|
112
|
+
</label>
|
113
|
+
</div>
|
114
|
+
<div class="govuk-radios__item">
|
115
|
+
<input class="govuk-radios__input" id="where-do-you-live-2" name="where-do-you-live" type="radio" value="scotland">
|
116
|
+
<label class="govuk-label govuk-radios__label" for="where-do-you-live-2">
|
117
|
+
Scotland
|
118
|
+
</label>
|
119
|
+
</div>
|
120
|
+
<div class="govuk-radios__item">
|
121
|
+
<input class="govuk-radios__input" id="where-do-you-live-3" name="where-do-you-live" type="radio" value="wales">
|
122
|
+
<label class="govuk-label govuk-radios__label" for="where-do-you-live-3">
|
123
|
+
Wales
|
124
|
+
</label>
|
125
|
+
</div>
|
126
|
+
<div class="govuk-radios__item">
|
127
|
+
<input class="govuk-radios__input" id="where-do-you-live-4" name="where-do-you-live" type="radio" value="northern-ireland">
|
128
|
+
<label class="govuk-label govuk-radios__label" for="where-do-you-live-4">
|
129
|
+
Northern Ireland
|
130
|
+
</label>
|
131
|
+
</div>
|
132
|
+
</div>
|
133
|
+
</fieldset>
|
134
|
+
</div>
|
135
|
+
HTML
|
136
|
+
end
|
137
|
+
|
138
|
+
it "returns the correct HTML when there is a conditional" do
|
139
|
+
email_htmltml = helper.govukInput({
|
140
|
+
id: "contact-by-email",
|
141
|
+
name: "contact-by-email",
|
142
|
+
type: "email",
|
143
|
+
autocomplete: "email",
|
144
|
+
spellcheck: false,
|
145
|
+
classes: "govuk-!-width-one-third",
|
146
|
+
label: {
|
147
|
+
text: "Email address"
|
148
|
+
}
|
149
|
+
})
|
150
|
+
|
151
|
+
phone_html = helper.govukInput({
|
152
|
+
id: "contact-by-phone",
|
153
|
+
name: "contact-by-phone",
|
154
|
+
type: "tel",
|
155
|
+
autocomplete: "tel",
|
156
|
+
classes: "govuk-!-width-one-third",
|
157
|
+
label: {
|
158
|
+
text: "Phone number"
|
159
|
+
}
|
160
|
+
})
|
161
|
+
|
162
|
+
text_html = helper.govukInput({
|
163
|
+
id: "contact-by-text",
|
164
|
+
name: "contact-by-text",
|
165
|
+
type: "tel",
|
166
|
+
autocomplete: "tel",
|
167
|
+
classes: "govuk-!-width-one-third",
|
168
|
+
label: {
|
169
|
+
text: "Mobile phone number"
|
170
|
+
}
|
171
|
+
})
|
172
|
+
|
173
|
+
helper.govukRadios({
|
174
|
+
idPrefix: "contact",
|
175
|
+
name: "contact",
|
176
|
+
fieldset: {
|
177
|
+
legend: {
|
178
|
+
text: "How would you prefer to be contacted?",
|
179
|
+
isPageHeading: true,
|
180
|
+
classes: "govuk-fieldset__legend--l"
|
181
|
+
}
|
182
|
+
},
|
183
|
+
hint: {
|
184
|
+
text: "Select one option."
|
185
|
+
},
|
186
|
+
items: [
|
187
|
+
{
|
188
|
+
value: "email",
|
189
|
+
text: "Email",
|
190
|
+
conditional: {
|
191
|
+
html: email_htmltml
|
192
|
+
}
|
193
|
+
},
|
194
|
+
{
|
195
|
+
value: "phone",
|
196
|
+
text: "Phone",
|
197
|
+
conditional: {
|
198
|
+
html: phone_html
|
199
|
+
}
|
200
|
+
},
|
201
|
+
{
|
202
|
+
value: "text",
|
203
|
+
text: "Text message",
|
204
|
+
conditional: {
|
205
|
+
html: text_html
|
206
|
+
}
|
207
|
+
}
|
208
|
+
]
|
209
|
+
})
|
210
|
+
end
|
211
|
+
|
212
|
+
it "returns the correct HTML when there is a fieldset css class" do
|
213
|
+
html = helper.govukRadios({
|
214
|
+
classes: "govuk-radios--inline",
|
215
|
+
idPrefix: "changed-name",
|
216
|
+
name: "changed-name",
|
217
|
+
fieldset: {
|
218
|
+
classes: "app-grouping",
|
219
|
+
legend: {
|
220
|
+
text: "Have you changed your name?",
|
221
|
+
isPageHeading: true,
|
222
|
+
classes: "govuk-fieldset__legend--l"
|
223
|
+
}
|
224
|
+
},
|
225
|
+
hint: {
|
226
|
+
text: "This includes changing your last name or spelling your name differently."
|
227
|
+
},
|
228
|
+
items: [
|
229
|
+
{
|
230
|
+
value: "yes",
|
231
|
+
text: "Yes"
|
232
|
+
},
|
233
|
+
{
|
234
|
+
value: "no",
|
235
|
+
text: "No"
|
236
|
+
}
|
237
|
+
]
|
238
|
+
})
|
239
|
+
|
240
|
+
expect(html).to match_html(<<~HTML)
|
241
|
+
<div class="govuk-form-group">
|
242
|
+
<fieldset class="govuk-fieldset app-grouping" aria-describedby="changed-name-hint">
|
243
|
+
<legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
|
244
|
+
<h1 class="govuk-fieldset__heading">
|
245
|
+
Have you changed your name?
|
246
|
+
</h1>
|
247
|
+
</legend>
|
248
|
+
<div id="changed-name-hint" class="govuk-hint">
|
249
|
+
This includes changing your last name or spelling your name differently.
|
250
|
+
</div>
|
251
|
+
<div class="govuk-radios govuk-radios--inline" data-module="govuk-radios">
|
252
|
+
<div class="govuk-radios__item">
|
253
|
+
<input class="govuk-radios__input" id="changed-name-1" name="changed-name" type="radio" value="yes">
|
254
|
+
<label class="govuk-label govuk-radios__label" for="changed-name-1">
|
255
|
+
Yes
|
256
|
+
</label>
|
257
|
+
</div>
|
258
|
+
<div class="govuk-radios__item">
|
259
|
+
<input class="govuk-radios__input" id="changed-name-2" name="changed-name" type="radio" value="no">
|
260
|
+
<label class="govuk-label govuk-radios__label" for="changed-name-2">
|
261
|
+
No
|
262
|
+
</label>
|
263
|
+
</div>
|
264
|
+
</div>
|
265
|
+
</fieldset>
|
266
|
+
</div>
|
267
|
+
HTML
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe GovukDesignSystem::SelectHelper, type: :helper do
|
4
|
+
describe "#govukSelect" do
|
5
|
+
it "returns the correct HTML for the default example" do
|
6
|
+
html = helper.govukSelect({
|
7
|
+
id: "sort",
|
8
|
+
name: "sort",
|
9
|
+
label: {
|
10
|
+
text: "Sort by"
|
11
|
+
},
|
12
|
+
items: [
|
13
|
+
{
|
14
|
+
value: "published",
|
15
|
+
text: "Recently published"
|
16
|
+
},
|
17
|
+
{
|
18
|
+
value: "updated",
|
19
|
+
text: "Recently updated",
|
20
|
+
selected: true
|
21
|
+
},
|
22
|
+
{
|
23
|
+
value: "views",
|
24
|
+
text: "Most views"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
value: "comments",
|
28
|
+
text: "Most comments"
|
29
|
+
}
|
30
|
+
]
|
31
|
+
})
|
32
|
+
|
33
|
+
expect(html).to match_html(<<~HTML)
|
34
|
+
<div class="govuk-form-group">
|
35
|
+
<label class="govuk-label" for="sort">
|
36
|
+
Sort by
|
37
|
+
</label>
|
38
|
+
<select class="govuk-select" id="sort" name="sort">
|
39
|
+
<option value="published">Recently published</option>
|
40
|
+
<option value="updated" selected="selected">Recently updated</option>
|
41
|
+
<option value="views">Most views</option>
|
42
|
+
<option value="comments">Most comments</option>
|
43
|
+
</select>
|
44
|
+
</div>
|
45
|
+
HTML
|
46
|
+
end
|
47
|
+
|
48
|
+
it "allows attributes to be passed" do
|
49
|
+
html = helper.govukSelect({
|
50
|
+
id: "sort",
|
51
|
+
name: "sort",
|
52
|
+
label: {
|
53
|
+
text: "Sort by"
|
54
|
+
},
|
55
|
+
items: [
|
56
|
+
{
|
57
|
+
value: "published",
|
58
|
+
text: "Recently published"
|
59
|
+
},
|
60
|
+
{
|
61
|
+
value: "updated",
|
62
|
+
text: "Recently updated",
|
63
|
+
selected: true
|
64
|
+
}
|
65
|
+
],
|
66
|
+
attributes: {
|
67
|
+
disabled: true,
|
68
|
+
data: { test: "testing" }
|
69
|
+
}
|
70
|
+
})
|
71
|
+
|
72
|
+
expect(html).to match_html(<<~HTML)
|
73
|
+
<div class="govuk-form-group">
|
74
|
+
<label class="govuk-label" for="sort">
|
75
|
+
Sort by
|
76
|
+
</label>
|
77
|
+
<select class="govuk-select" id="sort" name="sort" disabled="disabled" data-test="testing">
|
78
|
+
<option value="published">Recently published</option>
|
79
|
+
<option value="updated" selected="selected">Recently updated</option>
|
80
|
+
</select>
|
81
|
+
</div>
|
82
|
+
HTML
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe GovukDesignSystem::SummaryListHelper, type: :helper do
|
4
|
+
describe "#govukSummaryList" do
|
5
|
+
it "returns the correct HTML for the default example" do
|
6
|
+
html = helper.govukSummaryList({
|
7
|
+
rows: [
|
8
|
+
{
|
9
|
+
key: {
|
10
|
+
text: "Name"
|
11
|
+
},
|
12
|
+
value: {
|
13
|
+
text: "Sarah Philips"
|
14
|
+
},
|
15
|
+
actions: {
|
16
|
+
items: [
|
17
|
+
{
|
18
|
+
href: "#",
|
19
|
+
text: "Change",
|
20
|
+
visuallyHiddenText: "name"
|
21
|
+
}
|
22
|
+
]
|
23
|
+
}
|
24
|
+
},
|
25
|
+
{
|
26
|
+
key: {
|
27
|
+
text: "Date of birth"
|
28
|
+
},
|
29
|
+
value: {
|
30
|
+
text: "5 January 1978"
|
31
|
+
},
|
32
|
+
actions: {
|
33
|
+
items: [
|
34
|
+
{
|
35
|
+
href: "#",
|
36
|
+
text: "Change",
|
37
|
+
visuallyHiddenText: "date of birth"
|
38
|
+
}
|
39
|
+
]
|
40
|
+
}
|
41
|
+
},
|
42
|
+
{
|
43
|
+
key: {
|
44
|
+
text: "Address"
|
45
|
+
},
|
46
|
+
value: {
|
47
|
+
html: "72 Guild Street<br>London<br>SE23 6FH".html_safe
|
48
|
+
},
|
49
|
+
actions: {
|
50
|
+
items: [
|
51
|
+
{
|
52
|
+
href: "#",
|
53
|
+
text: "Change",
|
54
|
+
visuallyHiddenText: "address"
|
55
|
+
}
|
56
|
+
]
|
57
|
+
}
|
58
|
+
},
|
59
|
+
{
|
60
|
+
key: {
|
61
|
+
text: "Contact details"
|
62
|
+
},
|
63
|
+
value: {
|
64
|
+
html: '<p class="govuk-body">07700 900457</p><p class="govuk-body">sarah.phillips@example.com</p>'.html_safe
|
65
|
+
},
|
66
|
+
actions: {
|
67
|
+
items: [
|
68
|
+
{
|
69
|
+
href: "#",
|
70
|
+
text: "Change",
|
71
|
+
visuallyHiddenText: "contact details"
|
72
|
+
}
|
73
|
+
]
|
74
|
+
}
|
75
|
+
}
|
76
|
+
]
|
77
|
+
})
|
78
|
+
|
79
|
+
expect(html).to match_html(<<~HTML)
|
80
|
+
<dl class="govuk-summary-list">
|
81
|
+
<div class="govuk-summary-list__row">
|
82
|
+
<dt class="govuk-summary-list__key">
|
83
|
+
Name
|
84
|
+
</dt>
|
85
|
+
<dd class="govuk-summary-list__value">
|
86
|
+
Sarah Philips
|
87
|
+
</dd>
|
88
|
+
<dd class="govuk-summary-list__actions">
|
89
|
+
<a class="govuk-link" href="#">
|
90
|
+
Change<span class="govuk-visually-hidden"> name</span>
|
91
|
+
</a>
|
92
|
+
</dd>
|
93
|
+
</div>
|
94
|
+
<div class="govuk-summary-list__row">
|
95
|
+
<dt class="govuk-summary-list__key">
|
96
|
+
Date of birth
|
97
|
+
</dt>
|
98
|
+
<dd class="govuk-summary-list__value">
|
99
|
+
5 January 1978
|
100
|
+
</dd>
|
101
|
+
<dd class="govuk-summary-list__actions">
|
102
|
+
<a class="govuk-link" href="#">
|
103
|
+
Change<span class="govuk-visually-hidden"> date of birth</span>
|
104
|
+
</a>
|
105
|
+
</dd>
|
106
|
+
</div>
|
107
|
+
<div class="govuk-summary-list__row">
|
108
|
+
<dt class="govuk-summary-list__key">
|
109
|
+
Address
|
110
|
+
</dt>
|
111
|
+
<dd class="govuk-summary-list__value">
|
112
|
+
72 Guild Street<br>London<br>SE23 6FH
|
113
|
+
</dd>
|
114
|
+
<dd class="govuk-summary-list__actions">
|
115
|
+
<a class="govuk-link" href="#">
|
116
|
+
Change<span class="govuk-visually-hidden"> address</span>
|
117
|
+
</a>
|
118
|
+
</dd>
|
119
|
+
</div>
|
120
|
+
<div class="govuk-summary-list__row">
|
121
|
+
<dt class="govuk-summary-list__key">
|
122
|
+
Contact details
|
123
|
+
</dt>
|
124
|
+
<dd class="govuk-summary-list__value">
|
125
|
+
<p class="govuk-body">07700 900457</p>
|
126
|
+
<p class="govuk-body">sarah.phillips@example.com</p>
|
127
|
+
</dd>
|
128
|
+
<dd class="govuk-summary-list__actions">
|
129
|
+
<a class="govuk-link" href="#">
|
130
|
+
Change<span class="govuk-visually-hidden"> contact details</span>
|
131
|
+
</a>
|
132
|
+
</dd>
|
133
|
+
</div>
|
134
|
+
</dl>
|
135
|
+
HTML
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe GovukDesignSystem::TabsHelper, type: :helper do
|
4
|
+
describe "#govukTabs" do
|
5
|
+
it "returns the correct HTML for the default example" do
|
6
|
+
html = helper.govukTabs({
|
7
|
+
items: [
|
8
|
+
{
|
9
|
+
label: "Past day",
|
10
|
+
id: "past-day",
|
11
|
+
panel: {
|
12
|
+
html: "<strong>Past day</strong>".html_safe
|
13
|
+
}
|
14
|
+
},
|
15
|
+
{
|
16
|
+
label: "Past week",
|
17
|
+
id: "past-week",
|
18
|
+
panel: {
|
19
|
+
html: "<strong>Past week</strong>".html_safe
|
20
|
+
}
|
21
|
+
},
|
22
|
+
{
|
23
|
+
label: "Past month",
|
24
|
+
id: "past-month",
|
25
|
+
panel: {
|
26
|
+
html: "<strong>Past month</strong>".html_safe
|
27
|
+
}
|
28
|
+
},
|
29
|
+
{
|
30
|
+
label: "Past year",
|
31
|
+
id: "past-year",
|
32
|
+
panel: {
|
33
|
+
html: "<strong>Past year</strong>".html_safe
|
34
|
+
}
|
35
|
+
}
|
36
|
+
]
|
37
|
+
})
|
38
|
+
|
39
|
+
expect(html).to match_html(<<~HTML)
|
40
|
+
<div class="govuk-tabs" data-module="govuk-tabs">
|
41
|
+
<h2 class="govuk-tabs__title">
|
42
|
+
Contents
|
43
|
+
</h2>
|
44
|
+
<ul class="govuk-tabs__list">
|
45
|
+
<li class="govuk-tabs__list-item govuk-tabs__list-item--selected">
|
46
|
+
<a class="govuk-tabs__tab" href="#past-day">
|
47
|
+
Past day
|
48
|
+
</a>
|
49
|
+
</li>
|
50
|
+
<li class="govuk-tabs__list-item">
|
51
|
+
<a class="govuk-tabs__tab" href="#past-week">
|
52
|
+
Past week
|
53
|
+
</a>
|
54
|
+
</li>
|
55
|
+
<li class="govuk-tabs__list-item">
|
56
|
+
<a class="govuk-tabs__tab" href="#past-month">
|
57
|
+
Past month
|
58
|
+
</a>
|
59
|
+
</li>
|
60
|
+
<li class="govuk-tabs__list-item">
|
61
|
+
<a class="govuk-tabs__tab" href="#past-year">
|
62
|
+
Past year
|
63
|
+
</a>
|
64
|
+
</li>
|
65
|
+
</ul>
|
66
|
+
<div class="govuk-tabs__panel" id="past-day">
|
67
|
+
<strong>Past day</strong>
|
68
|
+
</div>
|
69
|
+
<div class="govuk-tabs__panel govuk-tabs__panel--hidden" id="past-week">
|
70
|
+
<strong>Past week</strong>
|
71
|
+
</div>
|
72
|
+
<div class="govuk-tabs__panel govuk-tabs__panel--hidden" id="past-month">
|
73
|
+
<strong>Past month</strong>
|
74
|
+
</div>
|
75
|
+
<div class="govuk-tabs__panel govuk-tabs__panel--hidden" id="past-year">
|
76
|
+
<strong>Past year</strong>
|
77
|
+
</div>
|
78
|
+
</div>
|
79
|
+
HTML
|
80
|
+
end
|
81
|
+
|
82
|
+
it "returns the correct HTML for a text panel item" do
|
83
|
+
html = helper.govukTabs({
|
84
|
+
items: [
|
85
|
+
{
|
86
|
+
label: "Past day",
|
87
|
+
id: "past-day",
|
88
|
+
panel: {
|
89
|
+
text: "Past day"
|
90
|
+
}
|
91
|
+
},
|
92
|
+
{
|
93
|
+
label: "Past week",
|
94
|
+
id: "past-week",
|
95
|
+
panel: {
|
96
|
+
html: "<strong>Past week</strong>".html_safe
|
97
|
+
}
|
98
|
+
}
|
99
|
+
]
|
100
|
+
})
|
101
|
+
|
102
|
+
expect(html).to match_html(<<~HTML)
|
103
|
+
<div class="govuk-tabs" data-module="govuk-tabs">
|
104
|
+
<h2 class="govuk-tabs__title">
|
105
|
+
Contents
|
106
|
+
</h2>
|
107
|
+
<ul class="govuk-tabs__list">
|
108
|
+
<li class="govuk-tabs__list-item govuk-tabs__list-item--selected">
|
109
|
+
<a class="govuk-tabs__tab" href="#past-day">
|
110
|
+
Past day
|
111
|
+
</a>
|
112
|
+
</li>
|
113
|
+
<li class="govuk-tabs__list-item">
|
114
|
+
<a class="govuk-tabs__tab" href="#past-week">
|
115
|
+
Past week
|
116
|
+
</a>
|
117
|
+
</li>
|
118
|
+
</ul>
|
119
|
+
<div class="govuk-tabs__panel" id="past-day">
|
120
|
+
<p class="govuk-body">Past day</p>
|
121
|
+
</div>
|
122
|
+
<div class="govuk-tabs__panel govuk-tabs__panel--hidden" id="past-week">
|
123
|
+
<strong>Past week</strong>
|
124
|
+
</div>
|
125
|
+
</div>
|
126
|
+
HTML
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe GovukDesignSystem::TagHelper, type: :helper do
|
4
|
+
describe "#govukTag" do
|
5
|
+
it "returns the correct HTML for the default example" do
|
6
|
+
html = helper.govukTag({
|
7
|
+
text: "completed"
|
8
|
+
})
|
9
|
+
|
10
|
+
expect(html).to match_html(<<~HTML)
|
11
|
+
<strong class="govuk-tag">
|
12
|
+
completed
|
13
|
+
</strong>
|
14
|
+
HTML
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|