@ons/design-system 59.1.0 → 60.0.1

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.
Files changed (138) hide show
  1. package/components/footer/_footer.scss +0 -15
  2. package/components/footer/_macro.njk +58 -106
  3. package/components/footer/_macro.spec.js +56 -186
  4. package/components/header/_header.scss +23 -25
  5. package/components/header/_macro.njk +133 -148
  6. package/components/header/_macro.spec.js +39 -73
  7. package/components/hero/_hero.scss +4 -0
  8. package/components/hero/_macro.njk +40 -93
  9. package/components/hero/_macro.spec.js +60 -189
  10. package/components/icons/_macro.njk +0 -499
  11. package/components/icons/_macro.spec.js +0 -14
  12. package/components/navigation/_macro.njk +14 -14
  13. package/components/navigation/_macro.spec.js +3 -5
  14. package/components/navigation/_navigation.scss +3 -3
  15. package/css/main.css +3 -3
  16. package/img/large/placeholder-card.png +0 -0
  17. package/img/large/placeholder-news-medium.png +0 -0
  18. package/img/large/placeholder-news.png +0 -0
  19. package/img/large/placeholder-portrait.png +0 -0
  20. package/img/small/placeholder-card.png +0 -0
  21. package/img/small/placeholder-news-medium.png +0 -0
  22. package/img/small/placeholder-news.png +0 -0
  23. package/img/small/placeholder-portrait.png +0 -0
  24. package/js/main.js +0 -1
  25. package/layout/_template.njk +51 -62
  26. package/package.json +1 -1
  27. package/scripts/main.es5.js +1 -1
  28. package/scripts/main.js +1 -1
  29. package/scss/main.scss +0 -2
  30. package/scss/vars/_colors.scss +9 -4
  31. package/components/find-a-support-centre/_find-a-support-centre.scss +0 -9
  32. package/components/promotional-banner/_macro.njk +0 -49
  33. package/components/promotional-banner/_macro.spec.js +0 -97
  34. package/components/promotional-banner/_promo-banner.scss +0 -72
  35. package/components/select/select.js +0 -19
  36. package/components/select/select.spec.js +0 -56
  37. package/css/census.css +0 -243
  38. package/css/ids.css +0 -243
  39. package/favicons/browserconfig.xml +0 -12
  40. package/favicons/census/cy/android-chrome-192x192.png +0 -0
  41. package/favicons/census/cy/android-chrome-512x512.png +0 -0
  42. package/favicons/census/cy/apple-touch-icon.png +0 -0
  43. package/favicons/census/cy/browserconfig.xml +0 -12
  44. package/favicons/census/cy/favicon-16x16.png +0 -0
  45. package/favicons/census/cy/favicon-32x32.png +0 -0
  46. package/favicons/census/cy/favicon.ico +0 -0
  47. package/favicons/census/cy/manifest.json +0 -20
  48. package/favicons/census/cy/mstitle-150x150.png +0 -0
  49. package/favicons/census/cy/mstitle-310x150.png +0 -0
  50. package/favicons/census/cy/mstitle-310x310.png +0 -0
  51. package/favicons/census/cy/mstitle-70x70.png +0 -0
  52. package/favicons/census/cy/opengraph.png +0 -0
  53. package/favicons/census/cy/safari-pinned-tab.svg +0 -3
  54. package/favicons/census/cy/site.webmanifest +0 -19
  55. package/favicons/census/cy/twitter.png +0 -0
  56. package/favicons/census/en/android-chrome-192x192.png +0 -0
  57. package/favicons/census/en/android-chrome-512x512.png +0 -0
  58. package/favicons/census/en/apple-touch-icon.png +0 -0
  59. package/favicons/census/en/browserconfig.xml +0 -12
  60. package/favicons/census/en/favicon-16x16.png +0 -0
  61. package/favicons/census/en/favicon-32x32.png +0 -0
  62. package/favicons/census/en/favicon.ico +0 -0
  63. package/favicons/census/en/manifest.json +0 -20
  64. package/favicons/census/en/mstitle-150x150.png +0 -0
  65. package/favicons/census/en/mstitle-310x150.png +0 -0
  66. package/favicons/census/en/mstitle-310x310.png +0 -0
  67. package/favicons/census/en/mstitle-70x70.png +0 -0
  68. package/favicons/census/en/opengraph.png +0 -0
  69. package/favicons/census/en/safari-pinned-tab.svg +0 -3
  70. package/favicons/census/en/site.webmanifest +0 -19
  71. package/favicons/census/en/twitter.png +0 -0
  72. package/favicons/census/ni/favicon.ico +0 -0
  73. package/favicons/ids/cy/android-chrome-192x192.png +0 -0
  74. package/favicons/ids/cy/android-chrome-512x512.png +0 -0
  75. package/favicons/ids/cy/apple-touch-icon.png +0 -0
  76. package/favicons/ids/cy/browserconfig.xml +0 -12
  77. package/favicons/ids/cy/favicon-16x16.png +0 -0
  78. package/favicons/ids/cy/favicon-32x32.png +0 -0
  79. package/favicons/ids/cy/favicon.ico +0 -0
  80. package/favicons/ids/cy/manifest.json +0 -20
  81. package/favicons/ids/cy/mstile-150x150.png +0 -0
  82. package/favicons/ids/cy/mstile-310x150.png +0 -0
  83. package/favicons/ids/cy/mstile-310x310.png +0 -0
  84. package/favicons/ids/cy/mstile-70x70.png +0 -0
  85. package/favicons/ids/cy/opengraph.png +0 -0
  86. package/favicons/ids/cy/safari-pinned-tab.svg +0 -27
  87. package/favicons/ids/cy/site.webmanifest +0 -54
  88. package/favicons/ids/cy/twitter.png +0 -0
  89. package/favicons/ids/en/android-chrome-192x192.png +0 -0
  90. package/favicons/ids/en/android-chrome-512x512.png +0 -0
  91. package/favicons/ids/en/apple-touch-icon.png +0 -0
  92. package/favicons/ids/en/browserconfig.xml +0 -12
  93. package/favicons/ids/en/favicon-16x16.png +0 -0
  94. package/favicons/ids/en/favicon-32x32.png +0 -0
  95. package/favicons/ids/en/favicon.ico +0 -0
  96. package/favicons/ids/en/manifest.json +0 -20
  97. package/favicons/ids/en/mstile-150x150.png +0 -0
  98. package/favicons/ids/en/mstile-310x150.png +0 -0
  99. package/favicons/ids/en/mstile-310x310.png +0 -0
  100. package/favicons/ids/en/mstile-70x70.png +0 -0
  101. package/favicons/ids/en/opengraph.png +0 -0
  102. package/favicons/ids/en/safari-pinned-tab.svg +0 -27
  103. package/favicons/ids/en/site.webmanifest +0 -54
  104. package/favicons/ids/en/twitter.png +0 -0
  105. package/favicons/mstitle-150x150.png +0 -0
  106. package/favicons/mstitle-310x150.png +0 -0
  107. package/favicons/mstitle-310x310.png +0 -0
  108. package/favicons/mstitle-70x70.png +0 -0
  109. package/img/UKOpenGovernmentLicence-grey.svg +0 -4
  110. package/img/UKOpenGovernmentLicence.svg +0 -13
  111. package/img/card-placeholder.svg +0 -14
  112. package/img/census-landscape.svg +0 -4514
  113. package/img/census-logo-stacked-pos-billingual.png +0 -0
  114. package/img/census-logo-stacked-pos-cy.png +0 -0
  115. package/img/census-logo-stacked-pos-en.png +0 -0
  116. package/img/census-promo-banner.svg +0 -489
  117. package/img/circle-lines.svg +0 -31
  118. package/img/dummy-brand-logo.svg +0 -6
  119. package/img/icons--check.svg +0 -3
  120. package/img/icons--chevron-down.svg +0 -3
  121. package/img/its-about-us--dark.svg +0 -4
  122. package/img/its-about-us--light.svg +0 -4
  123. package/img/large/hero-man.png +0 -0
  124. package/img/logo.svg +0 -77
  125. package/img/ni-syn-cyfrif--dark.svg +0 -3
  126. package/img/ni-syn-cyfrif--light.svg +0 -3
  127. package/img/nisra-logo-black-en.svg +0 -4
  128. package/img/ogl.svg +0 -10
  129. package/img/ons-logo-black-cy.svg +0 -4
  130. package/img/ons-logo-black-en.svg +0 -4
  131. package/img/people-mob.png +0 -0
  132. package/img/people.png +0 -0
  133. package/img/rehearsal-areas.svg +0 -11
  134. package/img/small/hero-man.png +0 -0
  135. package/scss/census.scss +0 -2
  136. package/scss/ids.scss +0 -2
  137. package/scss/settings/_census.scss +0 -159
  138. package/scss/settings/_ids.scss +0 -52
@@ -1,106 +1,53 @@
1
1
  {% macro onsHero(params) %}
2
2
 
3
- {% from "components/icons/_macro.njk" import onsIcon %}
3
+ {# Set number of columns used for hero content after medium breakpoint #}
4
+ {% set detailsColumns = params.detailsColumns | default ('8') %}
4
5
 
5
- {# style adjustments if dark or light skin #}
6
- {% if params.variants and 'dark' in params.variants %}
7
- {% set skinName = "dark" %}
8
- {% else %}
9
- {% set skinName = "light" %}
10
- {% endif %}
6
+ <section class="ons-hero ons-grid--gutterless{% if params.variants %}{% if params.variants is not string %}{% for variant in params.variants %} ons-hero--{{ variant }}{% endfor %}{% else %} ons-hero--{{ params.variants }}{% endif %}{% endif %}">
11
7
 
12
- {# If hero contains a collapsible, style it differently #}
13
- {% if params.collapsible %}
14
- {% set containerClasses = " ons-hero__container--has-collapsible" %}
15
- {% endif %}
8
+ <div class="ons-hero__container ons-container{{ ' ons-container--wide' if params.wide }}">
16
9
 
17
- {# Set number of columns used for hero content after medium breakpoint #}
18
- {% set detailsColumns = params.detailsColumns | default ('8') %}
10
+ <div class="ons-hero__details ons-grid__col ons-col-{{ detailsColumns }}@m ons-col-10@s@m">
11
+ <header>
12
+ {% if params.title %}
13
+ <h1 class="ons-hero__title ons-u-fs-xxxl">{{ params.title }}</h1>
14
+ {% endif %}
15
+ {% if params.subtitle %}
16
+ <h2 class="ons-hero__subtitle ons-u-fs-r--b">{{ params.subtitle }}</h2>
17
+ {% endif %}
18
+ </header>
19
19
 
20
- <section class="ons-hero ons-grid--gutterless{% if params.variants %}{% if params.variants is not string %}{% for variant in params.variants %} ons-hero--{{ variant }}{% endfor %}{% else %} ons-hero--{{ params.variants }}{% endif %}{% endif %}">
21
-
22
- <div class="ons-hero__container ons-container{{ ' ons-container--wide' if params.wide }}{{ containerClasses }}">
23
-
24
- <div class="ons-hero__details{{ detailsClasses }} ons-grid__col ons-col-{{ detailsColumns }}@m ons-col-10@s@m">
25
-
26
- <header>
27
- {% if params.preTitleImage %}
28
- {% set preTitleImageWithModifier = params.preTitleImage.name ~ "--" ~ skinName ~ ".svg" %}
29
- <img class="ons-hero__pre-title" src="{{ params.placeholderURL }}/img/{{ preTitleImageWithModifier }}" alt="{{ params.preTitleImage.alt }}">
20
+ {% if params.text %}
21
+ <p class="ons-hero__text">{{ params.text | safe }}</p>
30
22
  {% endif %}
31
- {% if params.title %}
32
- <h1 class="ons-hero__title ons-u-fs-xxxl">{{ params.title }}</h1>
33
- {% endif %}
34
- {% if params.subtitle %}
35
- <h2 class="ons-hero__subtitle ons-u-fs-r--b">{{ params.subtitle }}</h2>
36
- {% endif %}
37
- </header>
38
-
39
- {% if params.text %}
40
- <p class="ons-hero__text">{{ params.text | safe }}</p>
41
- {% endif %}
42
23
 
43
- {% if params.button %}
44
- {% from "components/button/_macro.njk" import onsButton %}
45
- {% set btnClasses = params.button.classes if params.button.classes else '' %}
46
- {% if skinName == 'dark' %}
47
- {% set btnClasses = btnClasses + ' ons-btn--ghost' %}
24
+ {% if params.button %}
25
+ {% from "components/button/_macro.njk" import onsButton %}
26
+ {% set btnClasses = params.button.classes if params.button.classes else '' %}
27
+ {% if params.variants and 'dark' in params.variants %}
28
+ {% set btnClasses = btnClasses + ' ons-btn--ghost' %}
29
+ {% endif %}
30
+ {{
31
+ onsButton({
32
+ "classes": btnClasses,
33
+ "type": 'button',
34
+ "text": params.button.text,
35
+ "url": params.button.url
36
+ })
37
+ }}
38
+ {% endif %}
39
+ {% if caller %}
40
+ <div class="ons-hero__additional-content">
41
+ {{- caller() -}}
42
+ </div>
48
43
  {% endif %}
49
- {{
50
- onsButton({
51
- "classes": btnClasses,
52
- "type": 'button',
53
- "text": params.button.text,
54
- "url": params.button.url
55
- })
56
- }}
57
- {% endif %}
58
-
59
- {% if params.collapsible %}
60
- {% from "components/collapsible/_macro.njk" import onsCollapsible %}
61
- {{
62
- onsCollapsible({
63
- "classes": 'ons-u-mb-s ' + params.collapsible.classes,
64
- "id": params.collapsible.id,
65
- "title": params.collapsible.title,
66
- "titleTag": params.collapsible.titleTag,
67
- "content": params.collapsible.content,
68
- "button": {
69
- "close": params.collapsible.closeButtonText | default('Hide this'),
70
- "contextSuffix": params.collapsible.closeButtonContextSuffix | default('content')
71
- }
72
- })
73
- }}
74
- {% endif %}
75
-
76
- {% if params.suffixText %}
77
- <p class="ons-hero__suffixText ons-u-fs-s ons-u-mt-m ons-u-mb-no">{{ params.suffixText | safe }}</p>
78
- {% endif %}
79
-
80
- </div>
81
- {% if params.variants and 'census' in params.variants %}
82
-
83
- {% if params.image %}
84
- <div class="ons-hero__circle-image">
85
- <img height="558" width="558" {% if params.image.largeSrc %}srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x" {% endif %}src="{{ params.image.smallSrc }}" alt="">
86
44
  </div>
45
+ {% if params.html %}
46
+ <div class="ons-hero__additional-html">
47
+ {{- params.html | safe -}}
48
+ </div>
87
49
  {% endif %}
50
+ </div>
88
51
 
89
- {{
90
- onsIcon({
91
- "iconType": 'circle-lined'
92
- })
93
- }}
94
-
95
- <div class="ons-hero__circle-gradient"></div>
96
-
97
- {% if (params.variants and 'census' in params.variants) and ('dark' not in params.variants) %}
98
- <div class="ons-hero__circle"></div>
99
- {% endif %}
100
-
101
- {% endif %}
102
-
103
- </div>
104
-
105
- </section>
52
+ </section>
106
53
  {% endmacro %}
@@ -5,223 +5,94 @@ import * as cheerio from 'cheerio';
5
5
  import axe from '../../tests/helpers/axe';
6
6
  import { renderComponent, templateFaker } from '../../tests/helpers/rendering';
7
7
 
8
- const EXAMPLE_HERO_MINIMAL = {
8
+ const EXAMPLE_HERO = {
9
9
  title: 'Hero title',
10
10
  subtitle: 'Hero subtitle',
11
11
  text: 'Hero text',
12
- suffixText: 'Hero suffix text',
13
- };
14
-
15
- const EXAMPLE_HERO_CENSUS_VARIANT = {
16
- variants: 'census',
17
- ...EXAMPLE_HERO_MINIMAL,
18
- };
19
-
20
- const EXAMPLE_HERO_CENSUS_VARIANT_WITH_IMAGE = {
21
- ...EXAMPLE_HERO_CENSUS_VARIANT,
22
- image: {
23
- smallSrc: 'example-small.png',
24
- largeSrc: 'example-large.png',
25
- },
26
- };
27
-
28
- const EXAMPLE_HERO_WITH_BUTTON = {
29
- ...EXAMPLE_HERO_MINIMAL,
30
12
  button: {
31
13
  url: '#0',
32
14
  text: 'Get started',
33
15
  },
34
16
  };
35
17
 
36
- const EXAMPLE_HERO_WITH_PRETITLE_IMAGE = {
37
- ...EXAMPLE_HERO_MINIMAL,
38
- preTitleImage: {
39
- name: 'example',
40
- alt: 'svg alt text',
41
- },
42
- };
43
-
44
- const EXAMPLE_HERO_WITH_COLLAPSIBLE = {
45
- ...EXAMPLE_HERO_MINIMAL,
46
- collapsible: {
47
- classes: 'ons-u-mt-s',
48
- id: 'collapsible',
49
- title: 'Collapsible title',
50
- titleTag: 'h2',
51
- content: 'Collapsible content',
52
- closeButtonText: 'Hide this',
53
- closeButtonContextSuffix: 'content',
54
- },
55
- };
56
-
57
18
  describe('macro: hero', () => {
58
- describe.each([
59
- ['with text', EXAMPLE_HERO_MINIMAL],
60
- ['with census variant', EXAMPLE_HERO_CENSUS_VARIANT],
61
- ['with census variants and image', EXAMPLE_HERO_CENSUS_VARIANT_WITH_IMAGE],
62
- ['with button', EXAMPLE_HERO_WITH_BUTTON],
63
- ['with pre-title image', EXAMPLE_HERO_WITH_PRETITLE_IMAGE],
64
- ['with collapsible', EXAMPLE_HERO_WITH_COLLAPSIBLE],
65
- ])('mode: %s', (_, params) => {
66
- it('passes jest-axe checks with', async () => {
67
- const $ = cheerio.load(renderComponent('hero', params));
68
-
69
- const results = await axe($.html());
70
- expect(results).toHaveNoViolations();
71
- });
72
-
73
- it('has provided variant style classes', () => {
74
- const $ = cheerio.load(
75
- renderComponent('hero', {
76
- variants: ['variant-a', 'variant-b'],
77
- }),
78
- );
79
-
80
- expect($('.ons-hero--variant-a').length).toBe(1);
81
- expect($('.ons-hero--variant-b').length).toBe(1);
82
- });
83
-
84
- it('has expected `title`', () => {
85
- const $ = cheerio.load(renderComponent('hero', params));
86
-
87
- const title = $('.ons-hero__title')
88
- .html()
89
- .trim();
90
- expect(title).toBe('Hero title');
91
- });
92
-
93
- it('has expected `subtitle`', () => {
94
- const $ = cheerio.load(renderComponent('hero', params));
95
-
96
- const title = $('.ons-hero__subtitle')
97
- .html()
98
- .trim();
99
- expect(title).toBe('Hero subtitle');
100
- });
101
-
102
- it('has expected `text`', () => {
103
- const $ = cheerio.load(renderComponent('hero', params));
104
-
105
- const title = $('.ons-hero__text')
106
- .html()
107
- .trim();
108
- expect(title).toBe('Hero text');
109
- });
110
-
111
- it('has expected `suffixText`', () => {
112
- const $ = cheerio.load(renderComponent('hero', params));
113
-
114
- const title = $('.ons-hero__suffixText')
115
- .html()
116
- .trim();
117
- expect(title).toBe('Hero suffix text');
118
- });
119
-
120
- it('has expected class if `wide`', () => {
121
- const $ = cheerio.load(renderComponent('hero', { wide: true, ...params }));
122
- expect($('.ons-hero__container').hasClass('ons-container--wide')).toBe(true);
123
- });
124
- });
19
+ it('passes jest-axe checks with', async () => {
20
+ const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO));
125
21
 
126
- describe('mode: with census variant and image', () => {
127
- it('has expected `srcset` attribute', () => {
128
- const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO_CENSUS_VARIANT_WITH_IMAGE));
22
+ const results = await axe($.html());
23
+ expect(results).toHaveNoViolations();
24
+ });
129
25
 
130
- const srcset = $('.ons-hero__circle-image img').attr('srcset');
131
- expect(srcset).toBe('example-small.png 1x, example-large.png 2x');
132
- });
26
+ it('has provided variant style classes', () => {
27
+ const $ = cheerio.load(
28
+ renderComponent('hero', {
29
+ variants: ['variant-a', 'variant-b'],
30
+ }),
31
+ );
133
32
 
134
- it('has expected `src` attribute', () => {
135
- const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO_CENSUS_VARIANT_WITH_IMAGE));
33
+ expect($('.ons-hero--variant-a').length).toBe(1);
34
+ expect($('.ons-hero--variant-b').length).toBe(1);
35
+ });
136
36
 
137
- const src = $('.ons-hero__circle-image img').attr('src');
138
- expect(src).toBe('example-small.png');
139
- });
37
+ it('has expected `title`', () => {
38
+ const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO));
140
39
 
141
- it('has a "circle-lined" icon', () => {
142
- const faker = templateFaker();
143
- const iconsSpy = faker.spy('icons');
40
+ const title = $('.ons-hero__title')
41
+ .html()
42
+ .trim();
43
+ expect(title).toBe('Hero title');
44
+ });
144
45
 
145
- faker.renderComponent('hero', EXAMPLE_HERO_CENSUS_VARIANT_WITH_IMAGE);
46
+ it('has expected `subtitle`', () => {
47
+ const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO));
146
48
 
147
- expect(iconsSpy.occurrences[0].iconType).toBe('circle-lined');
148
- });
49
+ const title = $('.ons-hero__subtitle')
50
+ .html()
51
+ .trim();
52
+ expect(title).toBe('Hero subtitle');
149
53
  });
150
54
 
151
- describe('mode: with button', () => {
152
- it('outputs the expected button', () => {
153
- const faker = templateFaker();
154
- const buttonSpy = faker.spy('button');
55
+ it('has expected `text`', () => {
56
+ const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO));
155
57
 
156
- faker.renderComponent('hero', EXAMPLE_HERO_WITH_BUTTON);
58
+ const title = $('.ons-hero__text')
59
+ .html()
60
+ .trim();
61
+ expect(title).toBe('Hero text');
62
+ });
157
63
 
158
- expect(buttonSpy.occurrences[0]).toHaveProperty('text', 'Get started');
159
- expect(buttonSpy.occurrences[0]).toHaveProperty('url', '#0');
160
- });
64
+ it('has expected `html`', () => {
65
+ const $ = cheerio.load(renderComponent('hero', { ...EXAMPLE_HERO, html: '<span class="some-html">some html</span>' }));
161
66
 
162
- it('outputs the correct button class with `dark` theme', () => {
163
- const faker = templateFaker();
164
- const buttonSpy = faker.spy('button');
67
+ const htmlOutput = $('.ons-hero__additional-html').html();
68
+ expect(htmlOutput).toBe('<span class="some-html">some html</span>');
69
+ });
165
70
 
166
- faker.renderComponent('hero', { ...EXAMPLE_HERO_WITH_BUTTON, variants: 'dark' });
71
+ it('outputs the expected button', () => {
72
+ const faker = templateFaker();
73
+ const buttonSpy = faker.spy('button');
167
74
 
168
- expect(buttonSpy.occurrences[0]).toHaveProperty('classes', ' ons-btn--ghost');
169
- });
170
- });
75
+ faker.renderComponent('hero', EXAMPLE_HERO);
171
76
 
172
- describe('mode: with pre-title image', () => {
173
- it('has expected `src` attribute', () => {
174
- const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO_WITH_PRETITLE_IMAGE));
175
-
176
- const src = $('.ons-hero__pre-title').attr('src');
177
- expect(src).toBe('/img/example--light.svg');
178
- });
179
-
180
- it('has expected `src` attribute with dark variant', () => {
181
- const $ = cheerio.load(
182
- renderComponent('hero', {
183
- variants: 'dark',
184
- ...EXAMPLE_HERO_WITH_PRETITLE_IMAGE,
185
- }),
186
- );
187
-
188
- const src = $('.ons-hero__pre-title').attr('src');
189
- expect(src).toBe('/img/example--dark.svg');
190
- });
191
-
192
- it('has expected `alt` attribute', () => {
193
- const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO_WITH_PRETITLE_IMAGE));
194
-
195
- const alt = $('.ons-hero__pre-title').attr('alt');
196
- expect(alt).toBe('svg alt text');
197
- });
198
-
199
- it('has provided `placeholderURL`', () => {
200
- const $ = cheerio.load(
201
- renderComponent('hero', {
202
- placeholderURL: '/some-path',
203
- ...EXAMPLE_HERO_WITH_PRETITLE_IMAGE,
204
- }),
205
- );
206
-
207
- const src = $('.ons-hero__pre-title').attr('src');
208
- expect(src).toBe('/some-path/img/example--light.svg');
209
- });
77
+ expect(buttonSpy.occurrences[0]).toHaveProperty('text', 'Get started');
78
+ expect(buttonSpy.occurrences[0]).toHaveProperty('url', '#0');
210
79
  });
211
80
 
212
- describe('mode: with collapsible', () => {
213
- it('outputs the expected collapsible', () => {
214
- const faker = templateFaker();
215
- const collapsibleSpy = faker.spy('collapsible');
81
+ it('outputs the correct button class with `dark` variant', () => {
82
+ const faker = templateFaker();
83
+ const buttonSpy = faker.spy('button');
84
+
85
+ faker.renderComponent('hero', { ...EXAMPLE_HERO, variants: 'dark' });
86
+
87
+ expect(buttonSpy.occurrences[0]).toHaveProperty('classes', ' ons-btn--ghost');
88
+ });
216
89
 
217
- faker.renderComponent('hero', EXAMPLE_HERO_WITH_COLLAPSIBLE);
90
+ it('calls with content', () => {
91
+ const $ = cheerio.load(renderComponent('hero', { EXAMPLE_HERO }, 'Example content...'));
218
92
 
219
- expect(collapsibleSpy.occurrences[0]).toHaveProperty('classes', 'ons-u-mb-s ons-u-mt-s');
220
- expect(collapsibleSpy.occurrences[0]).toHaveProperty('id', 'collapsible');
221
- expect(collapsibleSpy.occurrences[0]).toHaveProperty('title', 'Collapsible title');
222
- expect(collapsibleSpy.occurrences[0]).toHaveProperty('titleTag', 'h2');
223
- expect(collapsibleSpy.occurrences[0]).toHaveProperty('button.close', 'Hide this');
224
- expect(collapsibleSpy.occurrences[0]).toHaveProperty('button.contextSuffix', 'content');
225
- });
93
+ const content = $('.ons-hero__additional-content')
94
+ .text()
95
+ .trim();
96
+ expect(content).toEqual(expect.stringContaining('Example content...'));
226
97
  });
227
98
  });