@eeacms/volto-eea-design-system 1.16.0 → 1.18.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 (63) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/docker-compose.yml +5 -1
  3. package/locales/en/LC_MESSAGES/volto.po +14 -0
  4. package/package.json +1 -1
  5. package/src/helpers/index.js +4 -4
  6. package/src/helpers/useClickOutside.test.js +63 -0
  7. package/src/helpers/useFirstVisited.test.js +54 -0
  8. package/src/ui/Accordion/Accordion.stories.js +3 -1
  9. package/src/ui/Accordion/Accordion.stories.test.js +45 -0
  10. package/src/ui/Banner/Banner.test.jsx +292 -0
  11. package/src/ui/CallToAction/CallToAction.stories.test.jsx +69 -0
  12. package/src/ui/Card/Card.stories.test.jsx +78 -0
  13. package/src/ui/Card/IconCard/IconCard.stories.test.jsx +64 -0
  14. package/src/ui/Card/RelatedContent/RelatedContent.jsx +1 -1
  15. package/src/ui/Card/RelatedContent/RelatedContent.stories.jsx +2 -2
  16. package/src/ui/Card/RelatedContent/RelatedContent.stories.test.jsx +65 -0
  17. package/src/ui/Confirm/Confirm.stories.test.js +27 -0
  18. package/src/ui/ContextNavigation/ContextNavigation.stories.test.jsx +170 -0
  19. package/src/ui/Divider/Divider.stories.test.jsx +44 -0
  20. package/src/ui/DownloadLabeledIcon/DownloadLabeledIcon.stories.test.jsx +24 -0
  21. package/src/ui/Footer/Description.test.jsx +11 -0
  22. package/src/ui/Footer/Footer.stories.test.js +131 -0
  23. package/src/ui/Footer/Social.test.jsx +11 -0
  24. package/src/ui/Form/Button/Button.stories.test.jsx +55 -0
  25. package/src/ui/Form/Checkbox.stories.test.js +79 -0
  26. package/src/ui/Form/Dropdown.stories.test.js +24 -0
  27. package/src/ui/Form/Radio.stories.test.js +55 -0
  28. package/src/ui/Form/Textarea.stories.test.js +41 -0
  29. package/src/ui/Form/input.stories.test.js +52 -0
  30. package/src/ui/Grid/ComponentGrid.stories.test.js +21 -0
  31. package/src/ui/Header/Header.stories.test.js +158 -0
  32. package/src/ui/Header/Header.test.jsx +293 -0
  33. package/src/ui/Header/HeaderMenuPopUp.js +12 -4
  34. package/src/ui/Header/HeaderSearchPopUp.test.js +114 -0
  35. package/src/ui/Hero/Hero.stories.test.jsx +67 -0
  36. package/src/ui/InpageNavigation/InpageNavigation.stories.test.jsx +10 -0
  37. package/src/ui/InpageNavigation/InpageNavigation.test.jsx +87 -0
  38. package/src/ui/Item/Item.stories.test.js +39 -0
  39. package/src/ui/Item/ItemGroupWithIcons.stories.test.js +119 -0
  40. package/src/ui/Label/Label.stories.test.js +76 -0
  41. package/src/ui/LabeledIconGroup/LabeledIconGroup.stories.test.jsx +19 -0
  42. package/src/ui/LanguageLabeledIcon/LanguageLabeledIcon.jsx +3 -2
  43. package/src/ui/LanguageLabeledIcon/LanguangeLabeledIcon.test.jsx +60 -0
  44. package/src/ui/Loader/Loader.stories.test.jsx +30 -0
  45. package/src/ui/Logo/Logo.stories.test.jsx +81 -0
  46. package/src/ui/Media/Image.stories.test.js +35 -0
  47. package/src/ui/Message/Message.stories.test.js +44 -0
  48. package/src/ui/Modal/Modal.stories.test.js +45 -0
  49. package/src/ui/Popup/Popup.jsx +24 -17
  50. package/src/ui/Popup/Popup.test.jsx +60 -0
  51. package/src/ui/Progress/Progress.stories.test.js +30 -0
  52. package/src/ui/Quote/Testimonial/Testimonial.stories.test.jsx +18 -0
  53. package/src/ui/Statistic/Statistic.stories.test.js +93 -0
  54. package/src/ui/Table/Table.stories.js +8 -0
  55. package/src/ui/Table/Table.stories.test.js +54 -0
  56. package/src/ui/Timeline/Timeline.stories.test.jsx +43 -0
  57. package/src/ui/index.js +21 -41
  58. package/theme/themes/eea/assets/images/Footer/Extras/footer-visual.svg +1 -2065
  59. package/theme/themes/eea/extras/banner.less +3 -3
  60. package/theme/themes/eea/modules/accordion.overrides +36 -11
  61. package/theme/themes/eea/modules/accordion.variables +2 -0
  62. package/theme/themes/eea/views/item.overrides +21 -0
  63. package/src/i18n.js +0 -180
@@ -0,0 +1,78 @@
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 = ['Economy and resources', 'Health', 'Nature'];
22
+ cardTitles.forEach((titleElement, index) => {
23
+ expect(titleElement.textContent).toBe(expectedTitles[index]);
24
+ });
25
+ });
26
+ });
27
+
28
+ describe('CarouselCards component', () => {
29
+ it('renders the carousel with correct number of cards', () => {
30
+ const { container } = render(<CarouselCards {...CarouselCards.args} />);
31
+ const carouselCards = container.querySelectorAll(
32
+ '.cards-carousel .slick-slide:not(.slick-cloned) .content .header',
33
+ );
34
+ expect(carouselCards.length).toBe(5);
35
+ });
36
+
37
+ it('calls the slickPrev function when the previous arrow is clicked', () => {
38
+ const { getByLabelText } = render(
39
+ <CarouselCards {...CarouselCards.args} />,
40
+ );
41
+ const prevArrowButton = getByLabelText('Previous slide');
42
+ fireEvent.click(prevArrowButton);
43
+
44
+ const nextArrowButton = getByLabelText('Next slide');
45
+ fireEvent.click(nextArrowButton);
46
+ });
47
+ });
48
+
49
+ describe('FluidGrid component', () => {
50
+ it('renders fluid grid with correct number of cards', () => {
51
+ const { container } = render(<FluidGrid {...FluidGrid.args} />);
52
+ const fluidGridCards = container.querySelectorAll(
53
+ '.fluid-card-row .fluid.card .header',
54
+ );
55
+
56
+ expect(fluidGridCards.length).toBe(3);
57
+ });
58
+ });
59
+
60
+ describe('CardGrid component', () => {
61
+ it('renders the card grid with correct number of cards', () => {
62
+ const { container } = render(<CardGrid {...CardGrid.args} />);
63
+ const cardGridCards = container.querySelectorAll(
64
+ '.ui.fluid.card .content .header',
65
+ );
66
+ expect(cardGridCards.length).toBe(5);
67
+ });
68
+ });
69
+
70
+ describe('Default component', () => {
71
+ it('renders the default with correct number of cards', () => {
72
+ const { container } = render(<Default {...Default.args} />);
73
+ const defaultCards = container.querySelectorAll(
74
+ '.ui.card.default .content .header',
75
+ );
76
+ expect(defaultCards.length).toBe(1);
77
+ });
78
+ });
@@ -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
+ });
@@ -0,0 +1,170 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import { Default } from './ContextNavigation.stories';
4
+ import '@testing-library/jest-dom/extend-expect';
5
+
6
+ const sidenavItems = [
7
+ {
8
+ '@id': 'Gravida',
9
+ items: [
10
+ {
11
+ '@id': 'Lorem-ipsum-0',
12
+ description: '',
13
+ items: [],
14
+ review_state: null,
15
+ title: 'Item 1',
16
+ url: '/#',
17
+ is_current: true,
18
+ },
19
+ {
20
+ '@id': 'item-2',
21
+ description: '',
22
+ items: [],
23
+ review_state: null,
24
+ title: 'Item 2',
25
+ url: '/#',
26
+ },
27
+ {
28
+ '@id': 'item-3',
29
+ description: '',
30
+ items: [],
31
+ review_state: null,
32
+ title: 'Item 3',
33
+ url: '/#',
34
+ },
35
+ ],
36
+ review_state: null,
37
+ title: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
38
+ url: '/#',
39
+ },
40
+ {
41
+ '@id': 'Signals-2021',
42
+ description: '',
43
+ items: [],
44
+ review_state: null,
45
+ title: 'Signals 2021',
46
+ url: '/#',
47
+ },
48
+ {
49
+ '@id': 'Articles',
50
+ description: '',
51
+ items: [],
52
+ review_state: null,
53
+ title: 'Articles',
54
+ url: '/#',
55
+ },
56
+ {
57
+ '@id': 'Infographics',
58
+ items: [
59
+ {
60
+ '@id': 'Lorem-ipsum-1',
61
+ description: '',
62
+ items: [],
63
+ review_state: null,
64
+ title: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
65
+ url: '/#',
66
+ },
67
+ {
68
+ '@id': 'Signals-2021-infographics',
69
+ description: '',
70
+ items: [],
71
+ review_state: null,
72
+ title: 'Signals 2021',
73
+ url: '/#',
74
+ },
75
+ {
76
+ '@id': 'Articles',
77
+ description: '',
78
+ items: [
79
+ {
80
+ '@id': 'article-1',
81
+ description: '',
82
+ items: [],
83
+ review_state: null,
84
+ title: 'Summer 2022: Living in a state of multiple crises',
85
+ url: '/#',
86
+ is_current: true,
87
+ },
88
+ {
89
+ '@id': 'article-2',
90
+ description: '',
91
+ items: [],
92
+ review_state: null,
93
+ title:
94
+ 'Interview — Prosumers and the energy crisis: citizens contributing to Europe’s energy transition',
95
+ url: '/#',
96
+ },
97
+ ],
98
+ review_state: null,
99
+ title: 'Articles',
100
+ url: '/#',
101
+ is_in_path: true,
102
+ },
103
+ {
104
+ '@id': 'Infographics-overview',
105
+ description: '',
106
+ items: [],
107
+ review_state: null,
108
+ title: 'Infographics',
109
+ url: '/#',
110
+ },
111
+ ],
112
+ review_state: null,
113
+ title: 'Infographics',
114
+ url: '/#',
115
+ is_in_path: true,
116
+ },
117
+ {
118
+ '@id': 'About',
119
+ review_state: null,
120
+ title: 'About',
121
+ items: [],
122
+ url: '/#',
123
+ is_in_path: true,
124
+ is_current: true,
125
+ },
126
+ ];
127
+
128
+ describe('Default component', () => {
129
+ it('renders corectly', () => {
130
+ const { container, getByText } = render(<Default {...Default.args} />);
131
+
132
+ expect(getByText('Navigation')).toBeInTheDocument();
133
+ expect(getByText('Navigation')).toHaveClass('context-navigation-header');
134
+
135
+ Default.args.sidenavItems.forEach((item) => {
136
+ expect(container.querySelector(`#${item['@id']}`).textContent).toMatch(
137
+ item.title,
138
+ );
139
+ item.items.forEach((subitem) => {
140
+ expect(
141
+ container.querySelector(`#${subitem['@id']}`).textContent,
142
+ ).toMatch(subitem.title);
143
+ });
144
+ });
145
+ });
146
+
147
+ it('renders corectly', () => {
148
+ const { container, getByText, queryByText } = render(
149
+ <Default
150
+ {...Default.args}
151
+ sidenavItems={sidenavItems}
152
+ header={'Test Header'}
153
+ />,
154
+ );
155
+
156
+ expect(queryByText('Navigation')).toBeNull();
157
+ expect(getByText('Test Header')).toBeInTheDocument();
158
+
159
+ Default.args.sidenavItems.forEach((item) => {
160
+ expect(container.querySelector(`#${item['@id']}`).textContent).toMatch(
161
+ item.title,
162
+ );
163
+ item.items.forEach((subitem) => {
164
+ expect(
165
+ container.querySelector(`#${subitem['@id']}`).textContent,
166
+ ).toMatch(subitem.title);
167
+ });
168
+ });
169
+ });
170
+ });
@@ -0,0 +1,44 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import { DividerWithContent, Default } from './Divider.stories';
4
+ import '@testing-library/jest-dom/extend-expect';
5
+
6
+ describe('DividerWithContent component', () => {
7
+ it('renders correctly', () => {
8
+ const { container, getByText } = render(
9
+ <DividerWithContent {...DividerWithContent.args} />,
10
+ );
11
+
12
+ expect(getByText('Divider Content')).toBeInTheDocument();
13
+ expect(container.querySelector('.ui.container p')).toBeInTheDocument();
14
+ expect(container.querySelector('.ui.divider')).toBeInTheDocument();
15
+ });
16
+
17
+ it('renders correctly with className', () => {
18
+ const { container, getByText } = render(
19
+ <DividerWithContent {...DividerWithContent.args} theme={'primary'} />,
20
+ );
21
+
22
+ expect(getByText('Divider Content')).toBeInTheDocument();
23
+ expect(container.querySelector('.ui.container p')).toBeInTheDocument();
24
+ expect(container.querySelector('.ui.divider.primary')).toBeInTheDocument();
25
+ });
26
+ });
27
+
28
+ describe('Default component', () => {
29
+ it('renders correctly', () => {
30
+ const { container } = render(<Default {...Default.args} />);
31
+
32
+ expect(container.querySelector('.ui.container p')).toBeInTheDocument();
33
+ expect(container.querySelector('.ui.divider')).toBeInTheDocument();
34
+ });
35
+
36
+ it('renders correctly', () => {
37
+ const { container } = render(
38
+ <Default {...Default.args} theme={'primary'} short={true} />,
39
+ );
40
+
41
+ expect(container.querySelector('.ui.container p')).toBeInTheDocument();
42
+ expect(container.querySelector('.ui.divider')).toBeInTheDocument();
43
+ });
44
+ });
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import { Default } from './DownloadLabeledIcon.stories';
4
+ import DownloadLabeledIcon from './DownloadLabeledIcon';
5
+ import '@testing-library/jest-dom/extend-expect';
6
+
7
+ describe('Default component', () => {
8
+ it('renders correctly', () => {
9
+ const { getByText } = render(<Default {...Default.args} />);
10
+ expect(getByText('Download')).toBeInTheDocument();
11
+ });
12
+
13
+ it('renders correctly', () => {
14
+ const { container, getByText } = render(
15
+ <DownloadLabeledIcon.Dropdown {...Default.args} />,
16
+ );
17
+ Default.args.links.forEach((item) => {
18
+ expect(getByText(item.linkName)).toBeInTheDocument();
19
+ });
20
+ expect(
21
+ container.querySelectorAll(`.${Default.args.downloadIcon}`),
22
+ ).toHaveLength(3);
23
+ });
24
+ });
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import Description from './Description';
4
+ import '@testing-library/jest-dom/extend-expect';
5
+
6
+ describe('Description component', () => {
7
+ it('renders corectly with children', () => {
8
+ const { getByText } = render(<Description>Description Test</Description>);
9
+ expect(getByText('Description Test')).toBeInTheDocument();
10
+ });
11
+ });
@@ -0,0 +1,131 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import { createMemoryHistory } from 'history';
4
+ import { Router } from 'react-router-dom';
5
+ import { Default } from './Footer.stories';
6
+ import Footer from './Footer';
7
+ import '@testing-library/jest-dom/extend-expect';
8
+
9
+ jest.mock('react-lazy-load-image-component', () => {
10
+ return {
11
+ LazyLoadComponent: ({ children }) => <>{children}</>,
12
+ };
13
+ });
14
+
15
+ describe('Default', () => {
16
+ let history;
17
+ let observe;
18
+ let unobserve;
19
+
20
+ beforeEach(() => {
21
+ history = createMemoryHistory();
22
+ observe = jest.fn();
23
+ unobserve = jest.fn();
24
+
25
+ window.IntersectionObserver = jest.fn(function () {
26
+ this.observe = observe;
27
+ this.unobserve = unobserve;
28
+ });
29
+ });
30
+
31
+ it('renders correctly', () => {
32
+ const { container, getByText } = render(
33
+ <Router history={history}>
34
+ <Default {...Default.args} />
35
+ </Router>,
36
+ );
37
+
38
+ expect(container.querySelector('#footer')).toBeInTheDocument();
39
+ expect(container.querySelector('.footer-wrapper-nobg')).toBeInTheDocument();
40
+
41
+ expect(container.querySelector('.subfooter')).toBeInTheDocument();
42
+ expect(container.querySelector('.site.logo')).toBeInTheDocument();
43
+ expect(container.querySelector('.contact')).toBeInTheDocument();
44
+ expect(container.querySelector('.social')).toBeInTheDocument();
45
+
46
+ expect(container.querySelector('.actions')).toBeInTheDocument();
47
+ expect(container.querySelector('a[href="/privacy"]')).toBeInTheDocument();
48
+ expect(container.querySelector('a[href="/sitemap"]')).toBeInTheDocument();
49
+ expect(
50
+ container.querySelector('a[href="https://www.eea.europa.eu/en/login"]'),
51
+ ).toBeInTheDocument();
52
+ expect(container.querySelector('.actions')).toBeInTheDocument();
53
+
54
+ expect(container.querySelector('.footer-header')).toBeInTheDocument();
55
+ expect(getByText('Environmental information systems')).toBeInTheDocument();
56
+
57
+ expect(container.querySelector('.theme-sites')).toBeInTheDocument();
58
+ Default.args.sites.map((site) =>
59
+ expect(
60
+ container.querySelector(`a[href="${site.url}"] img[src="${site.src}"]`),
61
+ ).toBeInTheDocument(),
62
+ );
63
+ });
64
+
65
+ it('renders correctly', () => {
66
+ const { container, getByText } = render(
67
+ <Router history={history}>
68
+ <Footer>
69
+ <Footer.SubFooter {...Default.args}>
70
+ <div>SubFooter test</div>
71
+ </Footer.SubFooter>
72
+ <Footer.Header>{Default.args.header}</Footer.Header>
73
+ <Footer.Sites sites={Default.args.sites}>
74
+ <div>Sites test</div>
75
+ </Footer.Sites>
76
+ <Footer.Actions
77
+ actions={Default.args.actions}
78
+ copyright={Default.args.copyright}
79
+ />
80
+ </Footer>
81
+ </Router>,
82
+ );
83
+
84
+ expect(container.querySelector('#footer')).toBeInTheDocument();
85
+ expect(container.querySelector('.footer-wrapper-nobg')).toBeInTheDocument();
86
+
87
+ expect(container.querySelector('.actions')).toBeInTheDocument();
88
+ expect(container.querySelector('a[href="/privacy"]')).toBeInTheDocument();
89
+ expect(container.querySelector('a[href="/sitemap"]')).toBeInTheDocument();
90
+ expect(
91
+ container.querySelector('a[href="https://www.eea.europa.eu/en/login"]'),
92
+ ).toBeInTheDocument();
93
+ expect(container.querySelector('.actions')).toBeInTheDocument();
94
+
95
+ expect(container.querySelector('.footer-header')).toBeInTheDocument();
96
+ expect(getByText('Environmental information systems')).toBeInTheDocument();
97
+
98
+ expect(getByText('Sites test')).toBeInTheDocument();
99
+ expect(getByText('SubFooter test')).toBeInTheDocument();
100
+ });
101
+
102
+ it('renders correctly', () => {
103
+ const { container, getByText } = render(
104
+ <Router history={history}>
105
+ <Footer>
106
+ <Footer.SubFooter
107
+ {...Default.args}
108
+ description={'test description'}
109
+ social={undefined}
110
+ />
111
+ <Footer.Header>{Default.args.header}</Footer.Header>
112
+ <Footer.Sites sites={Default.args.sites} />
113
+ <Footer.Actions
114
+ actions={Default.args.actions}
115
+ copyright={Default.args.copyright}
116
+ >
117
+ <div>Actions test</div>
118
+ </Footer.Actions>
119
+ </Footer>
120
+ </Router>,
121
+ );
122
+
123
+ expect(container.querySelector('#footer')).toBeInTheDocument();
124
+ expect(container.querySelector('.footer-wrapper-nobg')).toBeInTheDocument();
125
+
126
+ expect(container.querySelector('.footer-header')).toBeInTheDocument();
127
+ expect(getByText('Environmental information systems')).toBeInTheDocument();
128
+
129
+ expect(getByText('Actions test')).toBeInTheDocument();
130
+ });
131
+ });
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import Social from './Social';
4
+ import '@testing-library/jest-dom/extend-expect';
5
+
6
+ describe('Social component', () => {
7
+ it('renders corectly with children', () => {
8
+ const { getByText } = render(<Social>Social Test</Social>);
9
+ expect(getByText('Social Test')).toBeInTheDocument();
10
+ });
11
+ });