@ons/design-system 72.1.0 → 72.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/components/accordion/_macro.spec.js +2 -2
- package/components/address-input/_macro.spec.js +245 -322
- package/components/address-input/autosuggest.address.spec.js +16 -14
- package/components/address-output/_macro.spec.js +121 -74
- package/components/address-output/_test_examples.js +8 -0
- package/components/autosuggest/_macro.spec.js +373 -184
- package/components/back-to-top/back-to-top.dom.js +4 -4
- package/components/back-to-top/back-to-top.js +1 -1
- package/components/browser-banner/_macro.spec.js +11 -11
- package/components/button/_button.scss +1 -1
- package/components/button/_macro.njk +1 -1
- package/components/button/_macro.spec.js +405 -351
- package/components/button/example-button-group.njk +1 -0
- package/components/checkboxes/_checkbox.scss +3 -3
- package/components/description-list/_description-list.scss +40 -9
- package/components/description-list/_macro.njk +20 -12
- package/components/description-list/_macro.spec.js +11 -1
- package/components/description-list/example-inline-description-list.njk +58 -0
- package/components/details/_details.scss +1 -2
- package/components/details/example-details-open.njk +10 -0
- package/components/external-link/_macro.spec.js +66 -69
- package/components/external-link/_test_examples.js +4 -0
- package/components/feedback/_macro.spec.js +109 -80
- package/components/feedback/_test_examples.js +17 -0
- package/components/field/_macro.spec.js +106 -69
- package/components/header/_macro.njk +92 -90
- package/components/header/_macro.spec.js +10 -0
- package/components/header/example-header-basic.njk +11 -0
- package/components/hero/_hero.scss +239 -2
- package/components/hero/_macro.njk +7 -0
- package/components/hero/_macro.spec.js +5 -0
- package/components/hero/example-hero-navy-blue.njk +14 -0
- package/components/section-navigation/_macro.njk +9 -6
- package/components/table-of-contents/_macro.njk +3 -3
- package/components/table-of-contents/_macro.spec.js +3 -3
- package/components/table-of-contents/{_toc.scss → _table-of-contents.scss} +1 -1
- package/components/table-of-contents/table-of-contents.dom.js +13 -0
- package/components/table-of-contents/{toc.js → table-of-contents.js} +4 -4
- package/components/table-of-contents/{toc.spec.js → table-of-contents.spec.js} +2 -2
- package/components/tabs/_tabs.scss +10 -11
- package/components/tabs/tabs.js +3 -3
- package/components/timeout-modal/timeout-modal.spec.js +1 -1
- package/css/main.css +1 -1
- package/js/main.js +1 -1
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/main.scss +1 -1
- package/scss/utilities/_margin.scss +4 -0
- package/scss/utilities/_padding.scss +4 -0
- package/scss/vars/_colors.scss +2 -0
- package/components/table-of-contents/toc.dom.js +0 -13
|
@@ -107,7 +107,7 @@ $checkbox-padding: 10px;
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
.ons-checkbox__other {
|
|
110
|
-
margin: 0.5rem 0 0.5rem 0.
|
|
110
|
+
margin: 0.5rem 0 0.5rem 0.625rem;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
@@ -170,8 +170,8 @@ $checkbox-padding: 10px;
|
|
|
170
170
|
&__other {
|
|
171
171
|
border-left: 4px solid var(--ons-color-borders-indent);
|
|
172
172
|
display: block;
|
|
173
|
-
margin: 0
|
|
174
|
-
padding: 0 $checkbox-padding $checkbox-padding $checkbox-padding * 2
|
|
173
|
+
margin: 0 1.1875rem 0.5rem;
|
|
174
|
+
padding: 0 $checkbox-padding $checkbox-padding $checkbox-padding * 2;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
&__input:checked + &__label::before {
|
|
@@ -7,25 +7,56 @@
|
|
|
7
7
|
clear: both;
|
|
8
8
|
float: left;
|
|
9
9
|
font-weight: $font-weight-bold;
|
|
10
|
-
|
|
11
|
-
&:not(:first-child) {
|
|
12
|
-
margin-top: 0.5rem;
|
|
13
|
-
}
|
|
14
10
|
}
|
|
15
11
|
|
|
16
12
|
&__value {
|
|
17
13
|
float: right;
|
|
18
14
|
margin-left: 0; /* As normalize adds a 40px left margin */
|
|
15
|
+
}
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
&__item {
|
|
18
|
+
&:not(:first-child) {
|
|
19
|
+
.ons-description-list__term {
|
|
22
20
|
margin-top: 0.5rem;
|
|
23
21
|
}
|
|
22
|
+
|
|
23
|
+
.ons-description-list__value:nth-of-type(1) {
|
|
24
|
+
@include mq(m) {
|
|
25
|
+
margin-top: 0.5rem;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.ons-description-list--inline & {
|
|
30
|
+
.ons-description-list__value:nth-of-type(1),
|
|
31
|
+
.ons-description-list__term {
|
|
32
|
+
@include mq(l) {
|
|
33
|
+
margin-top: 0;
|
|
34
|
+
}
|
|
35
|
+
@include mq(xs, l) {
|
|
36
|
+
margin-top: 0.5rem;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&--inline {
|
|
44
|
+
.ons-description-list__term {
|
|
45
|
+
padding-right: 1rem;
|
|
24
46
|
}
|
|
25
47
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
48
|
+
@include mq(l) {
|
|
49
|
+
display: grid;
|
|
50
|
+
grid-template-columns: repeat(3, 1fr);
|
|
51
|
+
gap: 0.5rem 2.5rem;
|
|
52
|
+
|
|
53
|
+
.ons-description-list__value {
|
|
54
|
+
grid-column-start: 2;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.ons-description-list__item {
|
|
58
|
+
display: grid;
|
|
59
|
+
grid-template-columns: auto 1fr;
|
|
29
60
|
}
|
|
30
61
|
}
|
|
31
62
|
}
|
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
{% macro onsDescriptionList(params) %}
|
|
2
2
|
<dl
|
|
3
|
-
class="ons-description-list ons-description-list__items ons-grid ons-grid--gutterless ons-u-cf{{
|
|
4
|
-
{% if params.id %}id="{{ params.id }}"{% endif %}
|
|
3
|
+
class="ons-description-list ons-description-list__items ons-grid ons-grid--gutterless{{ ' ons-description-list--inline' if params.variant == 'inline' else ' ons-u-cf' }}{{ ' ' + params.classes if params.classes else '' }}"
|
|
4
|
+
{% if params.id %}id="{{ params.id }}"{% endif %}
|
|
5
|
+
{% if params.descriptionListLabel %}
|
|
5
6
|
title="{{ params.descriptionListLabel }}" aria-label="{{ params.descriptionListLabel }}"
|
|
6
7
|
{% endif %}
|
|
7
8
|
>
|
|
8
9
|
{% for item in params.itemsList %}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
{% if descriptionItem.description | length %}
|
|
14
|
-
<dd
|
|
15
|
-
{% if descriptionItem.id %}id="{{ descriptionItem.id }}"{% endif %}class="ons-description-list__value ons-grid__col ons-col-{{ params.descriptionCol }}@m"
|
|
10
|
+
<div class="ons-description-list__item">
|
|
11
|
+
{% if item.term | length %}
|
|
12
|
+
<dt
|
|
13
|
+
class="ons-description-list__term ons-grid__col ons-col-{{ params.termCol }}@{{ 'xs@l' if params.variant == 'inline' else 'm' }}"
|
|
16
14
|
>
|
|
17
|
-
{{-
|
|
18
|
-
</
|
|
15
|
+
{{- item.term -}}
|
|
16
|
+
</dt>
|
|
19
17
|
{% endif %}
|
|
20
|
-
|
|
18
|
+
{% for descriptionItem in item.descriptions %}
|
|
19
|
+
{% if descriptionItem.description | length %}
|
|
20
|
+
<dd
|
|
21
|
+
{% if descriptionItem.id %}id="{{ descriptionItem.id }}"{% endif %}
|
|
22
|
+
class="ons-description-list__value ons-grid__col ons-col-{{ params.descriptionCol }}@{{ 'xs@l' if params.variant == 'inline' else 'm' }}"
|
|
23
|
+
>
|
|
24
|
+
{{- descriptionItem.description -}}
|
|
25
|
+
</dd>
|
|
26
|
+
{% endif %}
|
|
27
|
+
{% endfor %}
|
|
28
|
+
</div>
|
|
21
29
|
{% endfor %}
|
|
22
30
|
</dl>
|
|
23
31
|
{% endmacro %}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/** @jest-environment jsdom */
|
|
2
2
|
|
|
3
3
|
import * as cheerio from 'cheerio';
|
|
4
|
-
|
|
5
4
|
import axe from '../../tests/helpers/axe';
|
|
6
5
|
import { renderComponent } from '../../tests/helpers/rendering';
|
|
7
6
|
|
|
@@ -87,6 +86,17 @@ describe('macro: description-list', () => {
|
|
|
87
86
|
expect($('#example-id').length).toBe(1);
|
|
88
87
|
});
|
|
89
88
|
|
|
89
|
+
it('has the provided variant style class when variant is provided', () => {
|
|
90
|
+
const $ = cheerio.load(
|
|
91
|
+
renderComponent('description-list', {
|
|
92
|
+
...EXAMPLE_DESCRIPTION_LIST_MINIMAL,
|
|
93
|
+
variant: 'inline',
|
|
94
|
+
}),
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
expect($('.ons-description-list').hasClass('ons-description-list--inline')).toBe(true);
|
|
98
|
+
});
|
|
99
|
+
|
|
90
100
|
it('has additionally provided style classes', () => {
|
|
91
101
|
const $ = cheerio.load(
|
|
92
102
|
renderComponent('description-list', {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{% from "components/description-list/_macro.njk" import onsDescriptionList %}
|
|
2
|
+
{{
|
|
3
|
+
onsDescriptionList({
|
|
4
|
+
"classes": "ons-u-mb-no",
|
|
5
|
+
"descriptionListLabel": "Information about this business and its survey requirements",
|
|
6
|
+
"variant": 'inline',
|
|
7
|
+
"termCol": "4",
|
|
8
|
+
"descriptionCol": "8",
|
|
9
|
+
"itemsList": [
|
|
10
|
+
{
|
|
11
|
+
"term": "Survey:",
|
|
12
|
+
"descriptions": [
|
|
13
|
+
{
|
|
14
|
+
"description": "Bricks & Blocks"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"term": "RU Refs:",
|
|
20
|
+
"descriptions": [
|
|
21
|
+
{
|
|
22
|
+
"description": "49900000118"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"description": "49300005832"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"term": "Business:",
|
|
31
|
+
"descriptions": [
|
|
32
|
+
{
|
|
33
|
+
"description": "Bolts & Ratchets Ltd."
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"term": "Trading as:",
|
|
39
|
+
"descriptions": [
|
|
40
|
+
{
|
|
41
|
+
"description": "Bolts & Ratchets"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"term": "To:",
|
|
47
|
+
"descriptions": [
|
|
48
|
+
{
|
|
49
|
+
"description": "Jacky Turner"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"description": "Louise Goodland"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
})
|
|
58
|
+
}}
|
|
@@ -68,7 +68,6 @@ $details-caret-width: 1.75rem;
|
|
|
68
68
|
|
|
69
69
|
&--open & {
|
|
70
70
|
&__icon {
|
|
71
|
-
left: -0.1rem;
|
|
72
71
|
top: 0.2rem;
|
|
73
72
|
transform: rotate(90deg);
|
|
74
73
|
}
|
|
@@ -76,7 +75,7 @@ $details-caret-width: 1.75rem;
|
|
|
76
75
|
&__content {
|
|
77
76
|
border-left: 4px solid var(--ons-color-borders-indent);
|
|
78
77
|
display: block;
|
|
79
|
-
margin: 1rem 0 0;
|
|
78
|
+
margin: 1rem 0 0 0.5rem;
|
|
80
79
|
padding: 0 0 0 1.5rem;
|
|
81
80
|
}
|
|
82
81
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{% from "components/details/_macro.njk" import onsDetails %}
|
|
2
|
+
|
|
3
|
+
{{
|
|
4
|
+
onsDetails({
|
|
5
|
+
"id": "details-example",
|
|
6
|
+
"title": "What is a photovoltaic system?",
|
|
7
|
+
"content": "<p>A typical photovoltaic system employs solar panels, each comprising a number of solar cells, which generate electrical power. PV installations may be ground-mounted, rooftop mounted or wall mounted. The mount may be fixed, or use a solar tracker to follow the sun across the sky.</p>",
|
|
8
|
+
"open": true
|
|
9
|
+
})
|
|
10
|
+
}}
|
|
@@ -4,79 +4,76 @@ import * as cheerio from 'cheerio';
|
|
|
4
4
|
|
|
5
5
|
import axe from '../../tests/helpers/axe';
|
|
6
6
|
import { renderComponent, templateFaker } from '../../tests/helpers/rendering';
|
|
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
|
-
const $ = cheerio.load(renderComponent('external-link', EXAMPLE_EXTERNAL_LINK));
|
|
42
|
-
|
|
43
|
-
expect($('a').attr('target')).toBe('_blank');
|
|
44
|
-
expect($('a').attr('rel')).toBe('noopener');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('has the expected link text', async () => {
|
|
48
|
-
const $ = cheerio.load(renderComponent('external-link', EXAMPLE_EXTERNAL_LINK));
|
|
49
|
-
|
|
50
|
-
const $hyperlink = $('a.ons-external-link .ons-external-link__text');
|
|
51
|
-
expect($hyperlink.text().trim()).toBe('Example link');
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('has a default new window description', async () => {
|
|
55
|
-
const $ = cheerio.load(renderComponent('external-link', EXAMPLE_EXTERNAL_LINK));
|
|
56
|
-
|
|
57
|
-
expect($('.ons-external-link__new-window-description').text()).toBe('(opens in a new tab)');
|
|
7
|
+
import { EXAMPLE_EXTERNAL_LINK } from './_test_examples';
|
|
8
|
+
|
|
9
|
+
describe('FOR: Macro: External-link', () => {
|
|
10
|
+
describe('GIVEN: Params: required', () => {
|
|
11
|
+
describe('WHEN: all required params are provided', () => {
|
|
12
|
+
const $ = cheerio.load(renderComponent('external-link', EXAMPLE_EXTERNAL_LINK));
|
|
13
|
+
test('THEN: jest-axe checks pass', async () => {
|
|
14
|
+
const results = await axe($.html());
|
|
15
|
+
expect(results).toHaveNoViolations();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('THEN: the link points to the expected URL', async () => {
|
|
19
|
+
const $hyperlink = $('a.ons-external-link');
|
|
20
|
+
expect($hyperlink.attr('href')).toBe('http://example.com');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('THEN: the link has the expected link text', async () => {
|
|
24
|
+
const $hyperlink = $('a.ons-external-link .ons-external-link__text');
|
|
25
|
+
expect($hyperlink.text().trim()).toBe('Example link');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('THEN: the link has a default new window description', async () => {
|
|
29
|
+
expect($('.ons-external-link__new-window-description').text()).toBe('(opens in a new tab)');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('THEN: the link has the external-link icon', async () => {
|
|
33
|
+
const faker = templateFaker();
|
|
34
|
+
const iconsSpy = faker.spy('icon');
|
|
35
|
+
faker.renderComponent('external-link', {
|
|
36
|
+
...EXAMPLE_EXTERNAL_LINK,
|
|
37
|
+
});
|
|
38
|
+
expect(iconsSpy.occurrences[0].iconType).toBe('external-link');
|
|
39
|
+
});
|
|
40
|
+
});
|
|
58
41
|
});
|
|
59
42
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
43
|
+
describe('GIVEN: Params: classes', () => {
|
|
44
|
+
describe('WHEN: additional style classes are provided with the classes param', () => {
|
|
45
|
+
const $ = cheerio.load(
|
|
46
|
+
renderComponent('external-link', {
|
|
47
|
+
...EXAMPLE_EXTERNAL_LINK,
|
|
48
|
+
classes: 'extra-class another-extra-class',
|
|
49
|
+
}),
|
|
50
|
+
);
|
|
51
|
+
test('THEN: renders with provided classes', () => {
|
|
52
|
+
expect($('.ons-external-link').hasClass('extra-class')).toBe(true);
|
|
53
|
+
expect($('.ons-external-link').hasClass('another-extra-class')).toBe(true);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
69
56
|
});
|
|
70
57
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
58
|
+
describe('GIVEN: Params: newWindowDescription', () => {
|
|
59
|
+
describe('WHEN: newWindowDescription param is provided', () => {
|
|
60
|
+
const $ = cheerio.load(
|
|
61
|
+
renderComponent('external-link', {
|
|
62
|
+
...EXAMPLE_EXTERNAL_LINK,
|
|
63
|
+
newWindowDescription: 'custom opens in a new tab text',
|
|
64
|
+
}),
|
|
65
|
+
);
|
|
66
|
+
test('THEN: has the expected new window description', () => {
|
|
67
|
+
expect($('.ons-external-link__new-window-description').text()).toBe('(custom opens in a new tab text)');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('THEN: the target attribute is set to _blank so that the link opens in a new window', () => {
|
|
71
|
+
expect($('a').attr('target')).toBe('_blank');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('THEN: the rel attribute is set to noopener', () => {
|
|
75
|
+
expect($('a').attr('rel')).toBe('noopener');
|
|
76
|
+
});
|
|
78
77
|
});
|
|
79
|
-
|
|
80
|
-
expect(iconsSpy.occurrences[0].iconType).toBe('external-link');
|
|
81
78
|
});
|
|
82
79
|
});
|
|
@@ -4,103 +4,132 @@ import * as cheerio from 'cheerio';
|
|
|
4
4
|
|
|
5
5
|
import axe from '../../tests/helpers/axe';
|
|
6
6
|
import { renderComponent } from '../../tests/helpers/rendering';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
linkUrl: 'http://example.com',
|
|
23
|
-
linkText: 'Feedback link text',
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
describe('macro: feedback', () => {
|
|
27
|
-
it('passes jest-axe checks with minimum parameters', async () => {
|
|
28
|
-
const $ = cheerio.load(renderComponent('feedback', EXAMPLE_FEEDBACK_MINIMAL));
|
|
29
|
-
|
|
30
|
-
const results = await axe($.html());
|
|
31
|
-
expect(results).toHaveNoViolations();
|
|
7
|
+
import { EXAMPLE_FEEDBACK, EXAMPLE_FEEDBACK_ALL_PARAMS } from './_test_examples';
|
|
8
|
+
|
|
9
|
+
describe('FOR: Macro: Feedback', () => {
|
|
10
|
+
describe('GIVEN: Params: required', () => {
|
|
11
|
+
describe('WHEN: all required params are provided', () => {
|
|
12
|
+
const $ = cheerio.load(renderComponent('feedback', EXAMPLE_FEEDBACK));
|
|
13
|
+
test('THEN: jest-axe checks pass', async () => {
|
|
14
|
+
const results = await axe($.html());
|
|
15
|
+
expect(results).toHaveNoViolations();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('THEN: the title has a default headingLevel of 2', () => {
|
|
19
|
+
expect($(`h2.ons-feedback__heading`).text().trim()).toBe('Feedback heading');
|
|
20
|
+
});
|
|
21
|
+
});
|
|
32
22
|
});
|
|
33
23
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
describe('GIVEN: Params: all', () => {
|
|
25
|
+
describe('WHEN: all params are provided', () => {
|
|
26
|
+
const $ = cheerio.load(renderComponent('feedback', EXAMPLE_FEEDBACK_ALL_PARAMS));
|
|
27
|
+
test('THEN: jest-axe checks pass', async () => {
|
|
28
|
+
const results = await axe($.html());
|
|
29
|
+
expect(results).toHaveNoViolations();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
39
32
|
});
|
|
40
33
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
34
|
+
describe('GIVEN: Params: id', () => {
|
|
35
|
+
describe('WHEN: id is provided', () => {
|
|
36
|
+
const $ = cheerio.load(
|
|
37
|
+
renderComponent('feedback', {
|
|
38
|
+
...EXAMPLE_FEEDBACK,
|
|
39
|
+
id: 'example-id',
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
test('THEN: renders with provided id', () => {
|
|
43
|
+
expect($('#example-id').length).toBe(1);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
49
46
|
});
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
describe('GIVEN: Params: classes', () => {
|
|
49
|
+
describe('WHEN: additional style classes are provided', () => {
|
|
50
|
+
const $ = cheerio.load(
|
|
51
|
+
renderComponent('feedback', {
|
|
52
|
+
...EXAMPLE_FEEDBACK,
|
|
53
|
+
classes: 'extra-class another-extra-class',
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
test('THEN: renders with provided classes', () => {
|
|
57
|
+
expect($('.ons-feedback').hasClass('extra-class')).toBe(true);
|
|
58
|
+
expect($('.ons-feedback').hasClass('another-extra-class')).toBe(true);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
60
61
|
});
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
expect($(`${expectedTitleTag}.ons-feedback__heading`).text().trim()).toBe('Feedback heading');
|
|
63
|
+
describe('GIVEN: Params: heading', () => {
|
|
64
|
+
describe('WHEN: heading is provided', () => {
|
|
65
|
+
const $ = cheerio.load(
|
|
66
|
+
renderComponent('feedback', {
|
|
67
|
+
...EXAMPLE_FEEDBACK,
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
70
|
+
test('THEN: renders with provided heading text', () => {
|
|
71
|
+
expect($('.ons-feedback__heading').text().trim()).toBe('Feedback heading');
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
describe('GIVEN: Params: headingLevel', () => {
|
|
77
|
+
describe('WHEN: headingLevel is provided', () => {
|
|
78
|
+
test.each([
|
|
79
|
+
[1, 'h1'],
|
|
80
|
+
[4, 'h4'],
|
|
81
|
+
])('THEN: has the correct heading element type for the provided headingLevel (%i -> %s)', (headingLevel, expectedTitleTag) => {
|
|
82
|
+
const $ = cheerio.load(
|
|
83
|
+
renderComponent('feedback', {
|
|
84
|
+
...EXAMPLE_FEEDBACK,
|
|
85
|
+
headingLevel,
|
|
86
|
+
}),
|
|
87
|
+
);
|
|
88
|
+
const titleTag = $(`${expectedTitleTag}.ons-feedback__heading`)[0].tagName;
|
|
89
|
+
expect(titleTag).toBe(expectedTitleTag);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
80
92
|
});
|
|
81
93
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
94
|
+
describe('GIVEN: Params: headingClasses', () => {
|
|
95
|
+
describe('WHEN: additional heading style classes are provided', () => {
|
|
96
|
+
const $ = cheerio.load(
|
|
97
|
+
renderComponent('feedback', {
|
|
98
|
+
...EXAMPLE_FEEDBACK,
|
|
99
|
+
headingClasses: 'extra-heading-class another-extra-heading-class',
|
|
100
|
+
}),
|
|
101
|
+
);
|
|
102
|
+
test('THEN: renders with provided classes', () => {
|
|
103
|
+
expect($('.ons-feedback__heading').hasClass('extra-heading-class')).toBe(true);
|
|
104
|
+
expect($('.ons-feedback__heading').hasClass('another-extra-heading-class')).toBe(true);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
87
107
|
});
|
|
88
108
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
109
|
+
describe('GIVEN: Params: content', () => {
|
|
110
|
+
describe('WHEN: content is provided', () => {
|
|
111
|
+
const $ = cheerio.load(renderComponent('feedback', EXAMPLE_FEEDBACK));
|
|
112
|
+
test('THEN: renders paragraph with the provided content', () => {
|
|
113
|
+
expect($('p').text().trim()).toBe('Feedback content...');
|
|
114
|
+
});
|
|
115
|
+
});
|
|
93
116
|
});
|
|
94
117
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
118
|
+
describe('GIVEN: Params: linkUrl', () => {
|
|
119
|
+
describe('WHEN: linkUrl is provided', () => {
|
|
120
|
+
const $ = cheerio.load(renderComponent('feedback', EXAMPLE_FEEDBACK));
|
|
121
|
+
test('THEN: renders a link with the provided linkUrl', () => {
|
|
122
|
+
expect($('.ons-feedback__link').attr('href')).toBe('http://example.com');
|
|
123
|
+
});
|
|
124
|
+
});
|
|
99
125
|
});
|
|
100
126
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
127
|
+
describe('GIVEN: Params: linkText', () => {
|
|
128
|
+
describe('WHEN: linkText is provided', () => {
|
|
129
|
+
const $ = cheerio.load(renderComponent('feedback', EXAMPLE_FEEDBACK));
|
|
130
|
+
test('THEN: renders a link with the provided linkText', () => {
|
|
131
|
+
expect($('.ons-feedback__link').text().trim()).toBe('Feedback link text');
|
|
132
|
+
});
|
|
133
|
+
});
|
|
105
134
|
});
|
|
106
135
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const EXAMPLE_FEEDBACK = {
|
|
2
|
+
heading: 'Feedback heading',
|
|
3
|
+
content: 'Feedback content...',
|
|
4
|
+
linkUrl: 'http://example.com',
|
|
5
|
+
linkText: 'Feedback link text',
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const EXAMPLE_FEEDBACK_ALL_PARAMS = {
|
|
9
|
+
id: 'example-feedback',
|
|
10
|
+
classes: 'extra-class',
|
|
11
|
+
heading: 'Feedback heading',
|
|
12
|
+
headingLevel: 5,
|
|
13
|
+
headingClasses: 'extra-heading-class another-extra-heading-class',
|
|
14
|
+
content: 'Feedback content...',
|
|
15
|
+
linkUrl: 'http://example.com',
|
|
16
|
+
linkText: 'Feedback link text',
|
|
17
|
+
};
|