@eeacms/volto-eea-design-system 1.15.0 → 1.17.0

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 (85) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/DEVELOP.md +56 -0
  3. package/README.md +18 -0
  4. package/docker-compose.yml +32 -0
  5. package/locales/de/LC_MESSAGES/volto.po +14 -0
  6. package/locales/en/LC_MESSAGES/volto.po +14 -0
  7. package/locales/it/LC_MESSAGES/volto.po +14 -0
  8. package/locales/ro/LC_MESSAGES/volto.po +14 -0
  9. package/locales/volto.pot +16 -0
  10. package/package.json +1 -1
  11. package/src/helpers/index.js +4 -4
  12. package/src/helpers/useClickOutside.test.js +63 -0
  13. package/src/helpers/useFirstVisited.test.js +54 -0
  14. package/src/ui/Accordion/Accordion.stories.js +72 -25
  15. package/src/ui/Accordion/Accordion.stories.test.js +45 -0
  16. package/src/ui/Banner/Banner.jsx +9 -2
  17. package/src/ui/Banner/Banner.test.jsx +292 -0
  18. package/src/ui/CallToAction/CallToAction.stories.test.jsx +69 -0
  19. package/src/ui/Card/Card.stories.jsx +4 -1
  20. package/src/ui/Card/Card.stories.test.jsx +82 -0
  21. package/src/ui/Card/IconCard/IconCard.stories.test.jsx +64 -0
  22. package/src/ui/Card/RelatedContent/RelatedContent.jsx +1 -1
  23. package/src/ui/Card/RelatedContent/RelatedContent.stories.jsx +2 -2
  24. package/src/ui/Card/RelatedContent/RelatedContent.stories.test.jsx +65 -0
  25. package/src/ui/Confirm/Confirm.stories.test.js +27 -0
  26. package/src/ui/ContextNavigation/ContextNavigation.stories.test.jsx +170 -0
  27. package/src/ui/Divider/Divider.stories.test.jsx +44 -0
  28. package/src/ui/DownloadLabeledIcon/DownloadLabeledIcon.stories.test.jsx +24 -0
  29. package/src/ui/Footer/Description.test.jsx +11 -0
  30. package/src/ui/Footer/Footer.stories.test.js +131 -0
  31. package/src/ui/Footer/Social.test.jsx +11 -0
  32. package/src/ui/Form/Button/Button.stories.test.jsx +55 -0
  33. package/src/ui/Form/Checkbox.stories.test.js +79 -0
  34. package/src/ui/Form/Dropdown.stories.test.js +24 -0
  35. package/src/ui/Form/Radio.stories.test.js +55 -0
  36. package/src/ui/Form/Textarea.stories.test.js +41 -0
  37. package/src/ui/Form/input.stories.test.js +52 -0
  38. package/src/ui/Grid/ComponentGrid.stories.test.js +21 -0
  39. package/src/ui/Header/Header.jsx +4 -0
  40. package/src/ui/Header/Header.stories.js +26 -4
  41. package/src/ui/Header/Header.stories.test.js +158 -0
  42. package/src/ui/Header/Header.test.jsx +293 -0
  43. package/src/ui/Header/HeaderMenuPopUp.js +128 -107
  44. package/src/ui/Header/HeaderSearchPopUp.test.js +113 -0
  45. package/src/ui/Hero/Hero.stories.test.jsx +67 -0
  46. package/src/ui/InpageNavigation/InpageNavigation.stories.test.jsx +10 -0
  47. package/src/ui/InpageNavigation/InpageNavigation.test.jsx +87 -0
  48. package/src/ui/Item/Item.stories.test.js +39 -0
  49. package/src/ui/Item/ItemGroupWithIcons.stories.test.js +119 -0
  50. package/src/ui/Label/Label.stories.test.js +76 -0
  51. package/src/ui/LabeledIconGroup/LabeledIconGroup.stories.test.jsx +19 -0
  52. package/src/ui/LanguageLabeledIcon/LanguageLabeledIcon.jsx +3 -2
  53. package/src/ui/LanguageLabeledIcon/LanguangeLabeledIcon.test.jsx +60 -0
  54. package/src/ui/Loader/Loader.stories.test.jsx +30 -0
  55. package/src/ui/Logo/Logo.stories.test.jsx +81 -0
  56. package/src/ui/Media/Image.stories.test.js +35 -0
  57. package/src/ui/Message/Message.stories.test.js +44 -0
  58. package/src/ui/Modal/Modal.stories.test.js +45 -0
  59. package/src/ui/Popup/Popup.jsx +77 -81
  60. package/src/ui/Popup/Popup.stories.jsx +1 -1
  61. package/src/ui/Popup/Popup.test.jsx +60 -0
  62. package/src/ui/Progress/Progress.stories.test.js +30 -0
  63. package/src/ui/Quote/Testimonial/Testimonial.stories.test.jsx +18 -0
  64. package/src/ui/Statistic/Statistic.stories.test.js +69 -0
  65. package/src/ui/Table/Table.stories.js +8 -0
  66. package/src/ui/Table/Table.stories.test.js +54 -0
  67. package/src/ui/Timeline/Timeline.stories.test.jsx +43 -0
  68. package/src/ui/index.js +21 -41
  69. package/theme/plugins.js +182 -0
  70. package/theme/themes/eea/elements/input.overrides +1 -1
  71. package/theme/themes/eea/extras/banner.less +3 -4
  72. package/theme/themes/eea/extras/custom.overrides +5 -0
  73. package/theme/themes/eea/extras/header.less +3 -22
  74. package/theme/themes/eea/extras/header.variables +1 -1
  75. package/theme/themes/eea/extras/tagList.less +1 -1
  76. package/theme/themes/eea/extras/tagList.variables +1 -1
  77. package/theme/themes/eea/globals/site.variables +3 -3
  78. package/theme/themes/eea/globals/utilities.less +9 -0
  79. package/theme/themes/eea/modules/accordion.overrides +44 -42
  80. package/theme/themes/eea/modules/accordion.variables +4 -4
  81. package/theme/themes/eea/modules/popup.overrides +4 -0
  82. package/theme/themes/eea/views/card.overrides +5 -1
  83. package/theme/themes/eea/views/card.variables +1 -0
  84. package/.i18n.babel.config.js +0 -1
  85. package/src/i18n.js +0 -180
@@ -0,0 +1,292 @@
1
+ import React from 'react';
2
+ import { render, fireEvent } from '@testing-library/react';
3
+ import Banner from './Banner';
4
+ import { sharePage } from './Banner';
5
+ import '@testing-library/jest-dom/extend-expect';
6
+
7
+ describe('Banner', () => {
8
+ it('renders without errors', () => {
9
+ const { container } = render(<Banner />);
10
+ expect(container).toBeInTheDocument();
11
+ });
12
+
13
+ it('renders the children when image prop is not provided', () => {
14
+ const image = 'image-url';
15
+ const properties = {};
16
+ const { getByText } = render(
17
+ <Banner image={image} properties={properties}>
18
+ <div>Content</div>
19
+ </Banner>,
20
+ );
21
+ expect(getByText('Content')).toBeInTheDocument();
22
+ });
23
+
24
+ it('renders the image and children when image prop is provided', () => {
25
+ const image = 'image-url';
26
+ const metadata = {
27
+ image: {
28
+ scales: {
29
+ huge: {
30
+ download: 'image-url',
31
+ },
32
+ },
33
+ },
34
+ };
35
+ const { container, getByText } = render(
36
+ <Banner image={image} metadata={metadata}>
37
+ <div>Content</div>
38
+ </Banner>,
39
+ );
40
+ const imageElement = container.querySelector('.eea.banner .image');
41
+ expect(imageElement).toBeInTheDocument();
42
+ expect(imageElement.style.backgroundImage).toBe(`url(${image})`);
43
+ expect(getByText('Content')).toBeInTheDocument();
44
+ });
45
+
46
+ it('calls the onClick function when an action button is clicked', () => {
47
+ const onClick = jest.fn();
48
+ const { getByText } = render(
49
+ <Banner.Action title="Action" icon="icon-name" onClick={onClick} />,
50
+ );
51
+ const actionButton = getByText('Action');
52
+ fireEvent.click(actionButton);
53
+ expect(onClick).toHaveBeenCalled();
54
+ });
55
+
56
+ it('renders only the gradient and children when image prop is not provided', () => {
57
+ const { container, getByText } = render(
58
+ <Banner>
59
+ <div>Content</div>
60
+ </Banner>,
61
+ );
62
+ const imageElement = container.querySelector('.eea.banner .image');
63
+ expect(imageElement).not.toBeInTheDocument();
64
+ const gradientElement = container.querySelector('.eea.banner .gradient');
65
+ expect(gradientElement).toBeInTheDocument();
66
+ expect(getByText('Content')).toBeInTheDocument();
67
+ });
68
+
69
+ it('calls the onClick handler when the action button is clicked', () => {
70
+ const onClick = jest.fn();
71
+ const { getByText } = render(
72
+ <Banner.Action title="Action" icon="icon-name" onClick={onClick} />,
73
+ );
74
+ const actionButton = getByText('Action');
75
+ fireEvent.click(actionButton);
76
+ expect(onClick).toHaveBeenCalledTimes(1);
77
+ });
78
+
79
+ it('renders the content and actions correctly', () => {
80
+ const { getByText } = render(
81
+ <>
82
+ <Banner.Title>Test Banner Title</Banner.Title>
83
+ <Banner.Subtitle>Test Banner Subtitle</Banner.Subtitle>
84
+ <Banner.Metadata>Test Banner Metadata</Banner.Metadata>
85
+ <Banner.MetadataField
86
+ hidden={false}
87
+ label={'Test label'}
88
+ value={'02.03.2023'}
89
+ type={'date'}
90
+ >
91
+ Test Banner MetadataField
92
+ </Banner.MetadataField>
93
+ <Banner.Content actions={<div>Actions</div>}>
94
+ <div>Content</div>
95
+ </Banner.Content>
96
+ </>,
97
+ );
98
+ expect(getByText('Content')).toBeInTheDocument();
99
+ expect(getByText('Actions')).toBeInTheDocument();
100
+ expect(getByText('Test Banner Title')).toBeInTheDocument();
101
+ expect(getByText('Test Banner Subtitle')).toBeInTheDocument();
102
+ expect(getByText('Test Banner Metadata')).toBeInTheDocument();
103
+ });
104
+
105
+ it('renders the content and actions correctly', () => {
106
+ const { getByText } = render(
107
+ <>
108
+ <Banner.Title>Test Banner Title</Banner.Title>
109
+ <Banner.Subtitle>Test Banner Subtitle</Banner.Subtitle>
110
+ <Banner.Metadata>Test Banner Metadata</Banner.Metadata>
111
+ <Banner.MetadataField
112
+ hidden={false}
113
+ label={'Test label'}
114
+ value={'test'}
115
+ type={'text'}
116
+ >
117
+ Test Banner MetadataField
118
+ </Banner.MetadataField>
119
+ <Banner.Content actions={<div>Actions</div>}>
120
+ <div>Content</div>
121
+ </Banner.Content>
122
+ </>,
123
+ );
124
+ expect(getByText('Content')).toBeInTheDocument();
125
+ expect(getByText('Actions')).toBeInTheDocument();
126
+ expect(getByText('Test Banner Title')).toBeInTheDocument();
127
+ expect(getByText('Test Banner Subtitle')).toBeInTheDocument();
128
+ expect(getByText('Test Banner Metadata')).toBeInTheDocument();
129
+ });
130
+
131
+ it('renders the content and actions correctly', () => {
132
+ const { getByText } = render(
133
+ <>
134
+ <Banner.Title>Test Banner Title</Banner.Title>
135
+ <Banner.Subtitle>Test Banner Subtitle</Banner.Subtitle>
136
+ <Banner.Metadata>Test Banner Metadata</Banner.Metadata>
137
+ <Banner.MetadataField
138
+ hidden={true}
139
+ label={'Test label'}
140
+ value={undefined}
141
+ type={undefined}
142
+ >
143
+ Test Banner MetadataField
144
+ </Banner.MetadataField>
145
+ <Banner.Content actions={<div>Actions</div>}>
146
+ <div>Content</div>
147
+ </Banner.Content>
148
+ </>,
149
+ );
150
+ expect(getByText('Content')).toBeInTheDocument();
151
+ expect(getByText('Actions')).toBeInTheDocument();
152
+ expect(getByText('Test Banner Title')).toBeInTheDocument();
153
+ expect(getByText('Test Banner Subtitle')).toBeInTheDocument();
154
+ expect(getByText('Test Banner Metadata')).toBeInTheDocument();
155
+ });
156
+ });
157
+
158
+ describe('sharePage', () => {
159
+ it('should not do anything if an invalid platform is provided', () => {
160
+ document.createElement = jest.fn();
161
+ sharePage('https://example.com', 'invalidPlatform');
162
+ expect(document.createElement).not.toHaveBeenCalled();
163
+ });
164
+
165
+ it('should create an anchor element and click it for a valid platform', () => {
166
+ const url = 'https://example.com';
167
+ const platform = 'facebook';
168
+
169
+ const mockLink = {
170
+ setAttribute: jest.fn(),
171
+ click: jest.fn(),
172
+ };
173
+
174
+ document.createElement = jest.fn(() => mockLink);
175
+
176
+ sharePage(url, platform);
177
+
178
+ expect(document.createElement).toHaveBeenCalledWith('a');
179
+ expect(mockLink.setAttribute).toHaveBeenNthCalledWith(
180
+ 1,
181
+ 'href',
182
+ `https://facebook.com/sharer.php?u=${url}`,
183
+ );
184
+ expect(mockLink.setAttribute).toHaveBeenNthCalledWith(
185
+ 2,
186
+ 'target',
187
+ '_blank',
188
+ );
189
+ expect(mockLink.setAttribute).toHaveBeenNthCalledWith(
190
+ 3,
191
+ 'rel',
192
+ 'noreferrer',
193
+ );
194
+ expect(mockLink.click).toHaveBeenCalled();
195
+ });
196
+
197
+ it('should create an anchor element and click it for a valid platform', () => {
198
+ const url = 'https://example.com';
199
+ const platform = 'twitter';
200
+
201
+ const mockLink = {
202
+ setAttribute: jest.fn(),
203
+ click: jest.fn(),
204
+ };
205
+
206
+ document.createElement = jest.fn(() => mockLink);
207
+
208
+ sharePage(url, platform);
209
+
210
+ expect(document.createElement).toHaveBeenCalledWith('a');
211
+ expect(mockLink.setAttribute).toHaveBeenNthCalledWith(
212
+ 1,
213
+ 'href',
214
+ `https://www.twitter.com/share?url=${url}`,
215
+ );
216
+ expect(mockLink.setAttribute).toHaveBeenNthCalledWith(
217
+ 2,
218
+ 'target',
219
+ '_blank',
220
+ );
221
+ expect(mockLink.setAttribute).toHaveBeenNthCalledWith(
222
+ 3,
223
+ 'rel',
224
+ 'noreferrer',
225
+ );
226
+ expect(mockLink.click).toHaveBeenCalled();
227
+ });
228
+
229
+ it('should create an anchor element and click it for a valid platform', () => {
230
+ const url = 'https://example.com';
231
+ const platform = 'linkedin';
232
+
233
+ const mockLink = {
234
+ setAttribute: jest.fn(),
235
+ click: jest.fn(),
236
+ };
237
+
238
+ document.createElement = jest.fn(() => mockLink);
239
+
240
+ sharePage(url, platform);
241
+
242
+ expect(document.createElement).toHaveBeenCalledWith('a');
243
+ expect(mockLink.setAttribute).toHaveBeenNthCalledWith(
244
+ 1,
245
+ 'href',
246
+ `https://www.linkedin.com/sharing/share-offsite/?url=${url}`,
247
+ );
248
+ expect(mockLink.setAttribute).toHaveBeenNthCalledWith(
249
+ 2,
250
+ 'target',
251
+ '_blank',
252
+ );
253
+ expect(mockLink.setAttribute).toHaveBeenNthCalledWith(
254
+ 3,
255
+ 'rel',
256
+ 'noreferrer',
257
+ );
258
+ expect(mockLink.click).toHaveBeenCalled();
259
+ });
260
+
261
+ it('should create an anchor element and click it for a valid platform', () => {
262
+ const url = 'https://example.com';
263
+ const platform = 'reddit';
264
+
265
+ const mockLink = {
266
+ setAttribute: jest.fn(),
267
+ click: jest.fn(),
268
+ };
269
+
270
+ document.createElement = jest.fn(() => mockLink);
271
+
272
+ sharePage(url, platform);
273
+
274
+ expect(document.createElement).toHaveBeenCalledWith('a');
275
+ expect(mockLink.setAttribute).toHaveBeenNthCalledWith(
276
+ 1,
277
+ 'href',
278
+ `https://reddit.com/submit?url=${url}`,
279
+ );
280
+ expect(mockLink.setAttribute).toHaveBeenNthCalledWith(
281
+ 2,
282
+ 'target',
283
+ '_blank',
284
+ );
285
+ expect(mockLink.setAttribute).toHaveBeenNthCalledWith(
286
+ 3,
287
+ 'rel',
288
+ 'noreferrer',
289
+ );
290
+ expect(mockLink.click).toHaveBeenCalled();
291
+ });
292
+ });
@@ -0,0 +1,69 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import { Default, Inverted, Link, Labeled } from './CallToAction.stories';
4
+ import '@testing-library/jest-dom/extend-expect';
5
+
6
+ describe('Link', () => {
7
+ it('renders correctly', () => {
8
+ const { container } = render(<Link {...Link.args} />);
9
+ expect(
10
+ container.querySelector(`a[href="${Link.args.href}"]`),
11
+ ).toBeInTheDocument();
12
+ });
13
+ });
14
+
15
+ describe('Labeled', () => {
16
+ it('renders correctly', () => {
17
+ const { container, getByText } = render(<Labeled {...Labeled.args} />);
18
+ expect(
19
+ container.querySelector(`a[href="${Labeled.args.href}"]`),
20
+ ).toBeInTheDocument();
21
+ expect(getByText(Labeled.args.label)).toBeInTheDocument();
22
+ });
23
+
24
+ it('renders correctly', () => {
25
+ const { container, getByText } = render(
26
+ <Labeled {...Labeled.args} variant={'default'} />,
27
+ );
28
+ expect(
29
+ container.querySelector(`a[href="${Labeled.args.href}"]`),
30
+ ).toBeInTheDocument();
31
+ expect(getByText(Labeled.args.label)).toBeInTheDocument();
32
+ });
33
+ });
34
+
35
+ describe('Inverted', () => {
36
+ it('renders correctly', () => {
37
+ const { container } = render(<Inverted {...Inverted.args} />);
38
+ expect(
39
+ container.querySelector(`a[href="${Inverted.args.href}"]`),
40
+ ).toBeInTheDocument();
41
+ });
42
+
43
+ it('renders correctly', () => {
44
+ const { container } = render(
45
+ <Inverted {...Inverted.args} variant={'default'} />,
46
+ );
47
+ expect(
48
+ container.querySelector(`a[href="${Inverted.args.href}"]`),
49
+ ).toBeInTheDocument();
50
+ });
51
+ });
52
+
53
+ describe('Default', () => {
54
+ it('renders correctly', () => {
55
+ const { container } = render(<Default {...Default.args} />);
56
+ expect(
57
+ container.querySelector(`a[href="${Default.args.href}"]`),
58
+ ).toBeInTheDocument();
59
+ });
60
+
61
+ it('renders correctly', () => {
62
+ const { container } = render(
63
+ <Default {...Default.args} variant={'default'} />,
64
+ );
65
+ expect(
66
+ container.querySelector(`a[href="${Default.args.href}"]`),
67
+ ).toBeInTheDocument();
68
+ });
69
+ });
@@ -446,7 +446,10 @@ function CarouselCardsContent(args) {
446
446
  dots
447
447
  .querySelectorAll('.slider-dots-button')
448
448
  .forEach(function (el, idx) {
449
- el.setAttribute('aria-current', idx === currentSlide);
449
+ el.setAttribute(
450
+ 'aria-current',
451
+ el.parentElement.className === 'slick-active',
452
+ );
450
453
  });
451
454
  }
452
455
  },
@@ -0,0 +1,82 @@
1
+ import React from 'react';
2
+ import { render, fireEvent } from '@testing-library/react';
3
+ import {
4
+ TeaserCardGrid,
5
+ CarouselCards,
6
+ FluidGrid,
7
+ CardGrid,
8
+ Default,
9
+ } from './Card.stories';
10
+
11
+ describe('TeaserCardGrid component', () => {
12
+ it('renders the teaser card grid with correct number of cards', () => {
13
+ const { container } = render(<TeaserCardGrid {...TeaserCardGrid.args} />);
14
+ const teaserCards = container.querySelectorAll('.column.grid-block-teaser');
15
+ expect(teaserCards.length).toBe(3);
16
+ });
17
+
18
+ it('displays the correct title on each card', () => {
19
+ const { container } = render(<TeaserCardGrid {...TeaserCardGrid.args} />);
20
+ const cardTitles = container.querySelectorAll('.content .header a');
21
+ const expectedTitles = [
22
+ "State of Europe's environment",
23
+ 'Climate',
24
+ 'Economy and resources',
25
+ ];
26
+ cardTitles.forEach((titleElement, index) => {
27
+ expect(titleElement.textContent).toBe(expectedTitles[index]);
28
+ });
29
+ });
30
+ });
31
+
32
+ describe('CarouselCards component', () => {
33
+ it('renders the carousel with correct number of cards', () => {
34
+ const { container } = render(<CarouselCards {...CarouselCards.args} />);
35
+ const carouselCards = container.querySelectorAll(
36
+ '.cards-carousel .slick-slide:not(.slick-cloned) .content .header',
37
+ );
38
+ expect(carouselCards.length).toBe(5);
39
+ });
40
+
41
+ it('calls the slickPrev function when the previous arrow is clicked', () => {
42
+ const { getByLabelText } = render(
43
+ <CarouselCards {...CarouselCards.args} />,
44
+ );
45
+ const prevArrowButton = getByLabelText('Previous slide');
46
+ fireEvent.click(prevArrowButton);
47
+
48
+ const nextArrowButton = getByLabelText('Next slide');
49
+ fireEvent.click(nextArrowButton);
50
+ });
51
+ });
52
+
53
+ describe('FluidGrid component', () => {
54
+ it('renders fluid grid with correct number of cards', () => {
55
+ const { container } = render(<FluidGrid {...FluidGrid.args} />);
56
+ const fluidGridCards = container.querySelectorAll(
57
+ '.fluid-card-row .fluid.card .header',
58
+ );
59
+
60
+ expect(fluidGridCards.length).toBe(3);
61
+ });
62
+ });
63
+
64
+ describe('CardGrid component', () => {
65
+ it('renders the card grid with correct number of cards', () => {
66
+ const { container } = render(<CardGrid {...CardGrid.args} />);
67
+ const cardGridCards = container.querySelectorAll(
68
+ '.ui.fluid.card .content .header',
69
+ );
70
+ expect(cardGridCards.length).toBe(3);
71
+ });
72
+ });
73
+
74
+ describe('Default component', () => {
75
+ it('renders the default with correct number of cards', () => {
76
+ const { container } = render(<Default {...Default.args} />);
77
+ const defaultCards = container.querySelectorAll(
78
+ '.ui.card.default .content .header',
79
+ );
80
+ expect(defaultCards.length).toBe(1);
81
+ });
82
+ });
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import { GridIconCard, Default } from './IconCard.stories';
4
+ import '@testing-library/jest-dom/extend-expect';
5
+
6
+ describe('GridIconCard component', () => {
7
+ it('renders correctly', () => {
8
+ const { container, getByText } = render(
9
+ <GridIconCard {...GridIconCard.args} />,
10
+ );
11
+
12
+ GridIconCard.args.cards.forEach((card) => {
13
+ expect(getByText(card.title)).toBeInTheDocument();
14
+ expect(
15
+ container.querySelector(`.${card.size}.${card.icon}`),
16
+ ).toBeInTheDocument();
17
+ });
18
+ });
19
+
20
+ it('renders correctly', () => {
21
+ const { container, getByText } = render(
22
+ <GridIconCard
23
+ {...GridIconCard.args}
24
+ variant={'primary'}
25
+ inverted={true}
26
+ hasLink={false}
27
+ />,
28
+ );
29
+
30
+ GridIconCard.args.cards.forEach((card) => {
31
+ expect(getByText(card.title)).toBeInTheDocument();
32
+ expect(
33
+ container.querySelector(`.${card.size}.${card.icon}`),
34
+ ).toBeInTheDocument();
35
+ });
36
+ });
37
+ });
38
+
39
+ describe('Default component', () => {
40
+ it('renders correctly', () => {
41
+ const { container, getByText } = render(<Default {...Default.args} />);
42
+
43
+ expect(getByText(Default.args.title)).toBeInTheDocument();
44
+ expect(
45
+ container.querySelector(`.${Default.args.size}.${Default.args.icon}`),
46
+ ).toBeInTheDocument();
47
+ });
48
+
49
+ it('renders correctly', () => {
50
+ const { container, getByText } = render(
51
+ <Default
52
+ {...Default.args}
53
+ variant={'primary'}
54
+ inverted={true}
55
+ hasLink={false}
56
+ />,
57
+ );
58
+
59
+ expect(getByText(Default.args.title)).toBeInTheDocument();
60
+ expect(
61
+ container.querySelector(`.${Default.args.size}.${Default.args.icon}`),
62
+ ).toBeInTheDocument();
63
+ });
64
+ });
@@ -83,7 +83,7 @@ RelatedContent.Grid = ({ children, ...rest }) => {
83
83
  ))}
84
84
 
85
85
  {rest.showButton && rest.publicationCards.length > 4 && (
86
- <Grid.Row className={!rest.showButton ? 'hidden' : null}>
86
+ <Grid.Row>
87
87
  <Grid.Column>
88
88
  <div className="button-wrapper">
89
89
  <Button secondary>{rest.buttonText}</Button>
@@ -42,14 +42,14 @@ DefaultEven.args = {
42
42
  {
43
43
  tag: '#Publication',
44
44
  description:
45
- 'Leo fermentum sollicitudin suspendisse iaculis feugiat. Eget tellus blandit aenean mattis. Leo fermentum sollicitudin suspendisse iaculis feugiat. ',
45
+ 'Leo fermentum sollicitudin suspendisse iaculis feugiat. Eget tellus blandit aenean mattis. Leo fermentum sollicitudin suspendisse iaculis feugiat.',
46
46
  image: imageUrl,
47
47
  href: '/#',
48
48
  },
49
49
  {
50
50
  tag: '#Publication',
51
51
  description:
52
- 'Leo fermentum sollicitudin suspendisse iaculis feugiat. Eget tellus blandit aenean mattis. Leo fermentum sollicitudin suspendisse iaculis feugiat. Eget tellus blandit aenean mattis. Leo fermentum sollicitudin suspendisse iaculis feugiat. Eget tellus blandit aenean mattis. Leo fermentum sollicitudin suspendisse iaculis feugiat. Eget tellus blandit aenean mattis. Leo fermentum sollicitudin suspendisse iaculis feugiat. Eget tellus blandit aenean mattis. ',
52
+ 'Leo fermentum sollicitudin suspendisse iaculis feugiat. Eget tellus blandit aenean mattis. Leo fermentum sollicitudin suspendisse iaculis feugiat. Eget tellus blandit aenean mattis. Leo fermentum sollicitudin suspendisse iaculis feugiat. Eget tellus blandit aenean mattis. Leo fermentum sollicitudin suspendisse iaculis feugiat. Eget tellus blandit aenean mattis. Leo fermentum sollicitudin suspendisse iaculis feugiat. Eget tellus blandit aenean mattis.',
53
53
  image: imageUrl,
54
54
  href: '/#',
55
55
  },
@@ -0,0 +1,65 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import {
4
+ RelatedContentInTab,
5
+ DefaultOdd,
6
+ DefaultEven,
7
+ } from './RelatedContent.stories';
8
+ import '@testing-library/jest-dom/extend-expect';
9
+
10
+ describe('RelatedContentInTab component', () => {
11
+ it('renders corectly', () => {
12
+ const { getByText } = render(
13
+ <RelatedContentInTab {...RelatedContentInTab.args} />,
14
+ );
15
+
16
+ RelatedContentInTab.args.panes.forEach((element) =>
17
+ expect(getByText(element.menuItem)).toBeInTheDocument(),
18
+ );
19
+ });
20
+
21
+ it('renders corectly', () => {
22
+ render(
23
+ <RelatedContentInTab {...RelatedContentInTab.args} panes={undefined} />,
24
+ );
25
+ });
26
+ });
27
+
28
+ describe('DefaultOdd component', () => {
29
+ it('renders corectly', () => {
30
+ const { getByText, getAllByText } = render(
31
+ <DefaultOdd {...DefaultOdd.args} />,
32
+ );
33
+
34
+ expect(getAllByText(DefaultOdd.args.publicationCards[0].tag)).toHaveLength(
35
+ 3,
36
+ );
37
+ expect(
38
+ getByText(DefaultOdd.args.publicationCards[0].description),
39
+ ).toBeInTheDocument();
40
+ });
41
+ });
42
+
43
+ describe('DefaultEven component', () => {
44
+ it('renders corectly', () => {
45
+ const { getByText } = render(<DefaultEven {...DefaultEven.args} />);
46
+
47
+ DefaultEven.args.publicationCards.forEach((element) => {
48
+ expect(getByText(element.description)).toBeInTheDocument();
49
+ });
50
+
51
+ expect(getByText(DefaultEven.args.buttonText)).toBeInTheDocument();
52
+ });
53
+
54
+ it('renders corectly without the button', () => {
55
+ const { getByText, queryByText } = render(
56
+ <DefaultEven {...DefaultEven.args} showButton={false} />,
57
+ );
58
+
59
+ DefaultEven.args.publicationCards.forEach((element) => {
60
+ expect(getByText(element.description)).toBeInTheDocument();
61
+ });
62
+
63
+ expect(queryByText(DefaultEven.args.buttonText)).toBeNull();
64
+ });
65
+ });
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { render, fireEvent } from '@testing-library/react';
3
+ import { Default } from './Confirm.stories';
4
+ import '@testing-library/jest-dom/extend-expect';
5
+
6
+ describe('Default component', () => {
7
+ it('renders correctly', () => {
8
+ const { container, getByText, queryByText } = render(
9
+ <Default {...Default.args} />,
10
+ );
11
+
12
+ expect(getByText('Show Confirmation')).toBeInTheDocument();
13
+ expect(container.querySelector('.ui.primary.button')).toBeInTheDocument();
14
+
15
+ fireEvent.click(container.querySelector('.ui.primary.button'));
16
+ expect(getByText(Default.args.confirmHeader)).toBeInTheDocument();
17
+ expect(getByText(Default.args.content)).toBeInTheDocument();
18
+ expect(getByText(Default.args.cancelButton)).toBeInTheDocument();
19
+ expect(getByText(Default.args.confirmButton)).toBeInTheDocument();
20
+
21
+ fireEvent.click(getByText(Default.args.cancelButton));
22
+ expect(queryByText(Default.args.confirmHeader)).toBeNull();
23
+ expect(queryByText(Default.args.content)).toBeNull();
24
+ expect(queryByText(Default.args.cancelButton)).toBeNull();
25
+ expect(queryByText(Default.args.confirmButton)).toBeNull();
26
+ });
27
+ });