@scottish-government/designsystem-react 0.6.0 → 0.7.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.
- package/@types/components/Accordion.d.ts +2 -2
- package/@types/components/ConfirmationMessage.d.ts +1 -1
- package/@types/components/NotificationPanel.d.ts +1 -1
- package/@types/components/SummaryCard.d.ts +1 -1
- package/@types/components/Tabs.d.ts +1 -1
- package/@types/sgds.d.ts +1 -1
- package/CHANGELOG.md +81 -0
- package/README.md +4 -0
- package/dist/common/{abstract-notification-banner.jsx → AbstractNotificationBanner.jsx} +5 -5
- package/dist/components/{accordion/accordion.jsx → Accordion/Accordion.jsx} +6 -6
- package/dist/components/{back-to-top/back-to-top.jsx → BackToTop/BackToTop.jsx} +2 -2
- package/dist/components/{button/button.jsx → Button/Button.jsx} +7 -7
- package/dist/components/{checkbox/checkbox.jsx → Checkbox/Checkbox.jsx} +2 -2
- package/dist/components/{confirmation-message/confirmation-message.jsx → ConfirmationMessage/ConfirmationMessage.jsx} +6 -6
- package/dist/components/{contents-nav/contents-nav.jsx → ContentsNav/ContentsNav.jsx} +3 -3
- package/dist/components/{cookie-banner/cookie-banner.jsx → CookieBanner/CookieBanner.jsx} +4 -4
- package/dist/components/{date-picker/date-picker.jsx → DatePicker/DatePicker.jsx} +7 -7
- package/dist/components/{error-summary/error-summary.jsx → ErrorSummary/ErrorSummary.jsx} +2 -2
- package/dist/components/{file-download/file-download.jsx → FileDownload/FileDownload.jsx} +2 -2
- package/dist/components/{hide-this-page/hide-this-page.jsx → HideThisPage/HideThisPage.jsx} +3 -3
- package/dist/components/{notification-banner/notification-banner.jsx → NotificationBanner/NotificationBanner.jsx} +4 -4
- package/dist/components/{notification-panel/notification-panel.jsx → NotificationPanel/NotificationPanel.jsx} +4 -4
- package/dist/components/{pagination/pagination.jsx → Pagination/Pagination.jsx} +3 -3
- package/dist/components/{phase-banner/phase-banner.jsx → PhaseBanner/PhaseBanner.jsx} +2 -2
- package/dist/components/{question/question.jsx → Question/Question.jsx} +7 -7
- package/dist/components/{radio-button/radio-button.jsx → RadioButton/RadioButton.jsx} +2 -2
- package/dist/components/{select/select.jsx → Select/Select.jsx} +4 -4
- package/dist/components/{site-header/site-header.jsx → SiteHeader/SiteHeader.jsx} +13 -13
- package/dist/components/{site-search/site-search.jsx → SiteSearch/SiteSearch.jsx} +2 -2
- package/dist/components/{summary-card/summary-card.jsx → SummaryCard/SummaryCard.jsx} +6 -6
- package/dist/components/{summary-list/summary-list.jsx → SummaryList/SummaryList.jsx} +8 -8
- package/dist/components/{tabs/tabs.jsx → Tabs/Tabs.jsx} +4 -4
- package/dist/components/{task-list/task-list.jsx → TaskList/TaskList.jsx} +9 -9
- package/dist/components/{text-input/text-input.jsx → TextInput/TextInput.jsx} +11 -11
- package/dist/components/{textarea/textarea.jsx → Textarea/Textarea.jsx} +7 -7
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/common/{abstract-notification-banner.test.tsx → AbstractNotificationBanner.test.tsx} +11 -11
- package/src/common/{abstract-notification-banner.tsx → AbstractNotificationBanner.tsx} +2 -2
- package/src/common/{conditional-wrapper.test.tsx → ConditionalWrapper.test.tsx} +1 -1
- package/src/common/{file-icon.test.tsx → FileIcon.test.tsx} +10 -10
- package/src/common/{hint-text.test.tsx → HintText.test.tsx} +12 -12
- package/src/common/{icon.test.tsx → Icon.test.tsx} +16 -16
- package/src/common/{screen-reader-text.test.tsx → ScreenReaderText.test.tsx} +5 -5
- package/src/common/{wrapper-tag.test.tsx → WrapperTag.test.tsx} +5 -5
- package/src/components/{accordion/accordion.test.tsx → Accordion/Accordion.test.tsx} +35 -35
- package/src/components/{accordion/accordion.tsx → Accordion/Accordion.tsx} +5 -5
- package/src/components/{aspect-box/aspect-box.test.tsx → AspectBox/AspectBox.test.tsx} +2 -2
- package/src/components/{back-to-top/back-to-top.test.tsx → BackToTop/BackToTop.test.tsx} +1 -1
- package/src/components/{back-to-top/back-to-top.tsx → BackToTop/BackToTop.tsx} +1 -1
- package/src/components/{breadcrumbs/breadcrumbs.test.tsx → Breadcrumbs/Breadcrumbs.test.tsx} +7 -7
- package/src/components/{button/button.test.tsx → Button/Button.test.tsx} +1 -1
- package/src/components/{button/button.tsx → Button/Button.tsx} +3 -3
- package/src/components/{checkbox/checkbox.test.tsx → Checkbox/Checkbox.test.tsx} +16 -16
- package/src/components/{checkbox/checkbox.tsx → Checkbox/Checkbox.tsx} +1 -1
- package/src/components/{confirmation-message/confirmation-message.test.tsx → ConfirmationMessage/ConfirmationMessage.test.tsx} +12 -14
- package/src/components/{confirmation-message/confirmation-message.tsx → ConfirmationMessage/ConfirmationMessage.tsx} +4 -4
- package/src/components/{contents-nav/contents-nav.test.tsx → ContentsNav/ContentsNav.test.tsx} +21 -28
- package/src/components/{contents-nav/contents-nav.tsx → ContentsNav/ContentsNav.tsx} +1 -1
- package/src/components/{cookie-banner/cookie-banner.test.tsx → CookieBanner/CookieBanner.test.tsx} +3 -3
- package/src/components/{cookie-banner/cookie-banner.tsx → CookieBanner/CookieBanner.tsx} +1 -1
- package/src/components/{date-picker/date-picker.test.tsx → DatePicker/DatePicker.test.tsx} +76 -66
- package/src/components/{date-picker/date-picker.tsx → DatePicker/DatePicker.tsx} +2 -2
- package/src/components/{details/details.test.tsx → Details/Details.test.tsx} +10 -10
- package/src/components/{error-message/error-message.test.tsx → ErrorMessage/ErrorMessage.test.tsx} +10 -10
- package/src/components/{error-summary/error-summary.test.tsx → ErrorSummary/ErrorSummary.test.tsx} +13 -14
- package/src/components/{error-summary/error-summary.tsx → ErrorSummary/ErrorSummary.tsx} +1 -1
- package/src/components/{file-download/file-download.test.tsx → FileDownload/FileDownload.test.tsx} +21 -21
- package/src/components/{file-download/file-download.tsx → FileDownload/FileDownload.tsx} +1 -1
- package/src/components/{hide-this-page/hide-this-page.test.tsx → HideThisPage/HideThisPage.test.tsx} +4 -4
- package/src/components/{hide-this-page/hide-this-page.tsx → HideThisPage/HideThisPage.tsx} +3 -3
- package/src/components/{inset-text/inset-text.test.tsx → InsetText/InsetText.test.tsx} +1 -1
- package/src/components/{notification-banner/notification-banner.test.tsx → NotificationBanner/NotificationBanner.test.tsx} +4 -4
- package/src/components/{notification-banner/notification-banner.tsx → NotificationBanner/NotificationBanner.tsx} +1 -1
- package/src/components/{notification-panel/notification-panel.test.tsx → NotificationPanel/NotificationPanel.test.tsx} +24 -23
- package/src/components/{notification-panel/notification-panel.tsx → NotificationPanel/NotificationPanel.tsx} +3 -3
- package/src/components/{page-header/page-header.test.tsx → PageHeader/PageHeader.test.tsx} +9 -9
- package/src/components/{page-metadata/page-metadata.test.tsx → PageMetadata/PageMetadata.test.tsx} +9 -9
- package/src/components/{pagination/pagination.test.tsx → Pagination/Pagination.test.tsx} +56 -56
- package/src/components/{pagination/pagination.tsx → Pagination/Pagination.tsx} +1 -1
- package/src/components/{phase-banner/phase-banner.test.tsx → PhaseBanner/PhaseBanner.test.tsx} +9 -9
- package/src/components/{phase-banner/phase-banner.tsx → PhaseBanner/PhaseBanner.tsx} +1 -1
- package/src/components/{question/question.test.tsx → Question/Question.test.tsx} +10 -10
- package/src/components/{question/question.tsx → Question/Question.tsx} +3 -3
- package/src/components/{radio-button/radio-button.test.tsx → RadioButton/RadioButton.test.tsx} +23 -23
- package/src/components/{radio-button/radio-button.tsx → RadioButton/RadioButton.tsx} +1 -1
- package/src/components/{select/select.test.tsx → Select/Select.test.tsx} +67 -64
- package/src/components/{select/select.tsx → Select/Select.tsx} +2 -2
- package/src/components/{sequential-navigation/sequential-navigation.test.tsx → SequentialNavigation/SequentialNavigation.test.tsx} +18 -18
- package/src/components/{side-navigation/side-navigation.test.tsx → SideNavigation/SideNavigation.test.tsx} +8 -8
- package/src/components/{site-header/site-header.test.tsx → SiteHeader/SiteHeader.test.tsx} +25 -25
- package/src/components/{site-header/site-header.tsx → SiteHeader/SiteHeader.tsx} +4 -4
- package/src/components/{site-navigation/site-navigation.test.tsx → SiteNavigation/SiteNavigation.test.tsx} +8 -8
- package/src/components/{site-search/site-search.test.tsx → SiteSearch/SiteSearch.test.tsx} +16 -16
- package/src/components/{site-search/site-search.tsx → SiteSearch/SiteSearch.tsx} +1 -1
- package/src/components/{skip-links/skip-links.test.tsx → SkipLinks/SkipLinks.test.tsx} +15 -15
- package/src/components/{summary-card/summary-card.test.tsx → SummaryCard/SummaryCard.test.tsx} +28 -28
- package/src/components/{summary-card/summary-card.tsx → SummaryCard/SummaryCard.tsx} +4 -4
- package/src/components/{summary-list/summary-list.test.tsx → SummaryList/SummaryList.test.tsx} +55 -56
- package/src/components/{summary-list/summary-list.tsx → SummaryList/SummaryList.tsx} +2 -2
- package/src/components/{table/table.test.tsx → Table/Table.test.tsx} +4 -4
- package/src/components/{tabs/tabs.test.tsx → Tabs/Tabs.test.tsx} +22 -42
- package/src/components/{tabs/tabs.tsx → Tabs/Tabs.tsx} +3 -3
- package/src/components/{tag/tag.test.tsx → Tag/Tag.test.tsx} +10 -10
- package/src/components/{task-list/task-list.test.tsx → TaskList/TaskList.test.tsx} +109 -108
- package/src/components/{task-list/task-list.tsx → TaskList/TaskList.tsx} +4 -4
- package/src/components/{text-input/text-input.test.tsx → TextInput/TextInput.test.tsx} +92 -87
- package/src/components/{text-input/text-input.tsx → TextInput/TextInput.tsx} +4 -4
- package/src/components/{textarea/textarea.test.tsx → Textarea/Textarea.test.tsx} +71 -67
- package/src/components/{textarea/textarea.tsx → Textarea/Textarea.tsx} +3 -3
- package/src/components/{warning-text/warning-text.test.tsx → WarningText/WarningText.test.tsx} +1 -1
- package/dist/icons/ArrowUpward.jsx +0 -41
- package/dist/icons/CalendarToday.jsx +0 -41
- package/dist/icons/Cancel.jsx +0 -40
- package/dist/icons/CheckCircle.jsx +0 -41
- package/dist/icons/ChevronLeft.jsx +0 -41
- package/dist/icons/ChevronRight.jsx +0 -41
- package/dist/icons/Close.jsx +0 -41
- package/dist/icons/Description.jsx +0 -41
- package/dist/icons/DoubleChevronLeft.jsx +0 -40
- package/dist/icons/DoubleChevronRight.jsx +0 -40
- package/dist/icons/Error.jsx +0 -41
- package/dist/icons/ExpandLess.jsx +0 -41
- package/dist/icons/ExpandMore.jsx +0 -41
- package/dist/icons/List.jsx +0 -44
- package/dist/icons/Menu.jsx +0 -41
- package/dist/icons/PriorityHigh.jsx +0 -42
- package/dist/icons/Search.jsx +0 -41
- package/dist/icons/index.js +0 -40
- /package/dist/common/{conditional-wrapper.jsx → ConditionalWrapper.jsx} +0 -0
- /package/dist/common/{file-icon.jsx → FileIcon.jsx} +0 -0
- /package/dist/common/{hint-text.jsx → HintText.jsx} +0 -0
- /package/dist/common/{icon.jsx → Icon.jsx} +0 -0
- /package/dist/common/{screen-reader-text.jsx → ScreenReaderText.jsx} +0 -0
- /package/dist/common/{wrapper-tag.jsx → WrapperTag.jsx} +0 -0
- /package/dist/components/{aspect-box/aspect-box.jsx → AspectBox/AspectBox.jsx} +0 -0
- /package/dist/components/{breadcrumbs/breadcrumbs.jsx → Breadcrumbs/Breadcrumbs.jsx} +0 -0
- /package/dist/components/{details/details.jsx → Details/Details.jsx} +0 -0
- /package/dist/components/{error-message/error-message.jsx → ErrorMessage/ErrorMessage.jsx} +0 -0
- /package/dist/components/{inset-text/inset-text.jsx → InsetText/InsetText.jsx} +0 -0
- /package/dist/components/{page-header/page-header.jsx → PageHeader/PageHeader.jsx} +0 -0
- /package/dist/components/{page-metadata/page-metadata.jsx → PageMetadata/PageMetadata.jsx} +0 -0
- /package/dist/components/{sequential-navigation/sequential-navigation.jsx → SequentialNavigation/SequentialNavigation.jsx} +0 -0
- /package/dist/components/{side-navigation/side-navigation.jsx → SideNavigation/SideNavigation.jsx} +0 -0
- /package/dist/components/{site-navigation/site-navigation.jsx → SiteNavigation/SiteNavigation.jsx} +0 -0
- /package/dist/components/{skip-links/skip-links.jsx → SkipLinks/SkipLinks.jsx} +0 -0
- /package/dist/components/{table/table.jsx → Table/Table.jsx} +0 -0
- /package/dist/components/{tag/tag.jsx → Tag/Tag.jsx} +0 -0
- /package/dist/components/{warning-text/warning-text.jsx → WarningText/WarningText.jsx} +0 -0
- /package/src/common/{conditional-wrapper.tsx → ConditionalWrapper.tsx} +0 -0
- /package/src/common/{file-icon.tsx → FileIcon.tsx} +0 -0
- /package/src/common/{hint-text.tsx → HintText.tsx} +0 -0
- /package/src/common/{icon.tsx → Icon.tsx} +0 -0
- /package/src/common/{screen-reader-text.tsx → ScreenReaderText.tsx} +0 -0
- /package/src/common/{wrapper-tag.tsx → WrapperTag.tsx} +0 -0
- /package/src/components/{aspect-box/aspect-box.tsx → AspectBox/AspectBox.tsx} +0 -0
- /package/src/components/{breadcrumbs/breadcrumbs.tsx → Breadcrumbs/Breadcrumbs.tsx} +0 -0
- /package/src/components/{details/details.tsx → Details/Details.tsx} +0 -0
- /package/src/components/{error-message/error-message.tsx → ErrorMessage/ErrorMessage.tsx} +0 -0
- /package/src/components/{inset-text/inset-text.tsx → InsetText/InsetText.tsx} +0 -0
- /package/src/components/{page-header/page-header.tsx → PageHeader/PageHeader.tsx} +0 -0
- /package/src/components/{page-metadata/page-metadata.tsx → PageMetadata/PageMetadata.tsx} +0 -0
- /package/src/components/{sequential-navigation/sequential-navigation.tsx → SequentialNavigation/SequentialNavigation.tsx} +0 -0
- /package/src/components/{side-navigation/side-navigation.tsx → SideNavigation/SideNavigation.tsx} +0 -0
- /package/src/components/{site-navigation/site-navigation.tsx → SiteNavigation/SiteNavigation.tsx} +0 -0
- /package/src/components/{skip-links/skip-links.tsx → SkipLinks/SkipLinks.tsx} +0 -0
- /package/src/components/{table/table.tsx → Table/Table.tsx} +0 -0
- /package/src/components/{tag/tag.tsx → Tag/Tag.tsx} +0 -0
- /package/src/components/{warning-text/warning-text.tsx → WarningText/WarningText.tsx} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render, screen, within } from '@testing-library/react';
|
|
3
|
-
import SiteHeader from './
|
|
4
|
-
import SiteNavigation from '../
|
|
5
|
-
import SiteSearch from '../
|
|
6
|
-
import PhaseBanner from '../
|
|
3
|
+
import SiteHeader from './SiteHeader';
|
|
4
|
+
import SiteNavigation from '../SiteNavigation/SiteNavigation';
|
|
5
|
+
import SiteSearch from '../SiteSearch/SiteSearch';
|
|
6
|
+
import PhaseBanner from '../PhaseBanner/PhaseBanner';
|
|
7
7
|
|
|
8
8
|
test('site header renders correctly (maximal, testing markup structure)', () => {
|
|
9
9
|
render(
|
|
@@ -67,14 +67,14 @@ test('site header renders correctly (maximal, testing markup structure)', () =>
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
test('site header branding: logo only, default URL', () => {
|
|
70
|
-
const
|
|
70
|
+
const LOGO = {
|
|
71
71
|
alt: 'The Scottish Government',
|
|
72
72
|
src: './scottish-government.svg'
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
render(
|
|
76
76
|
<SiteHeader
|
|
77
|
-
logo={
|
|
77
|
+
logo={LOGO}
|
|
78
78
|
/>
|
|
79
79
|
);
|
|
80
80
|
|
|
@@ -87,24 +87,24 @@ test('site header branding: logo only, default URL', () => {
|
|
|
87
87
|
expect(siteHeaderLogoLink).toHaveAttribute('href', '/');
|
|
88
88
|
|
|
89
89
|
expect(siteHeaderLogoImg).toHaveClass('ds_site-branding__logo-image');
|
|
90
|
-
expect(siteHeaderLogoImg).toHaveAttribute('src',
|
|
91
|
-
expect(siteHeaderLogoImg).toHaveAttribute('alt',
|
|
90
|
+
expect(siteHeaderLogoImg).toHaveAttribute('src', LOGO.src);
|
|
91
|
+
expect(siteHeaderLogoImg).toHaveAttribute('alt', LOGO.alt);
|
|
92
92
|
|
|
93
93
|
expect(siteHeaderLogoImg.parentElement).toEqual(siteHeaderLogoLink);
|
|
94
94
|
expect(siteHeaderLogoLink.parentElement).toEqual(siteHeaderBranding);
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
test('site header branding: logo and site title', () => {
|
|
98
|
-
const
|
|
98
|
+
const LOGO = {
|
|
99
99
|
alt: 'The Scottish Government',
|
|
100
100
|
src: './scottish-government.svg'
|
|
101
101
|
};
|
|
102
|
-
const
|
|
102
|
+
const SITE_TITLE_CONTENT = 'Design System React';
|
|
103
103
|
|
|
104
104
|
render(
|
|
105
105
|
<SiteHeader
|
|
106
|
-
logo={
|
|
107
|
-
siteTitle={
|
|
106
|
+
logo={LOGO}
|
|
107
|
+
siteTitle={SITE_TITLE_CONTENT}
|
|
108
108
|
/>
|
|
109
109
|
);
|
|
110
110
|
|
|
@@ -114,13 +114,13 @@ test('site header branding: logo and site title', () => {
|
|
|
114
114
|
const siteTitle = siteHeader.querySelector('.ds_site-branding__title');
|
|
115
115
|
|
|
116
116
|
expect(siteTitle?.tagName).toEqual('DIV');
|
|
117
|
-
expect(siteTitle?.textContent).toEqual(
|
|
117
|
+
expect(siteTitle?.textContent).toEqual(SITE_TITLE_CONTENT);
|
|
118
118
|
expect(siteTitle?.parentElement).toEqual(siteHeaderBranding);
|
|
119
119
|
expect(siteTitle?.previousElementSibling).toEqual(siteHeaderLogoLink);
|
|
120
120
|
});
|
|
121
121
|
|
|
122
122
|
test('site header branding: custom link URL', () => {
|
|
123
|
-
const
|
|
123
|
+
const LOGO = {
|
|
124
124
|
alt: 'The Scottish Government',
|
|
125
125
|
href: '/home.aspx',
|
|
126
126
|
src: './scottish-government.svg'
|
|
@@ -128,18 +128,18 @@ test('site header branding: custom link URL', () => {
|
|
|
128
128
|
|
|
129
129
|
render(
|
|
130
130
|
<SiteHeader
|
|
131
|
-
logo={
|
|
131
|
+
logo={LOGO}
|
|
132
132
|
/>
|
|
133
133
|
);
|
|
134
134
|
|
|
135
135
|
const siteHeader = screen.getByRole('banner');
|
|
136
136
|
const siteHeaderLogoLink = within(siteHeader).getByRole('link');
|
|
137
137
|
|
|
138
|
-
expect(siteHeaderLogoLink).toHaveAttribute('href',
|
|
138
|
+
expect(siteHeaderLogoLink).toHaveAttribute('href', LOGO.href);
|
|
139
139
|
});
|
|
140
140
|
|
|
141
141
|
test('site header with site search', () => {
|
|
142
|
-
const
|
|
142
|
+
const SEARCH_PROPS = {
|
|
143
143
|
action: 'apple',
|
|
144
144
|
autocompleteEndpoint: 'banana',
|
|
145
145
|
autocompleteSuggestionMappingFunction: 'cucumber',
|
|
@@ -152,8 +152,8 @@ test('site header with site search', () => {
|
|
|
152
152
|
|
|
153
153
|
render(
|
|
154
154
|
<>
|
|
155
|
-
<SiteHeader siteSearch={
|
|
156
|
-
<SiteSearch data-testid="sitesearch" {...
|
|
155
|
+
<SiteHeader siteSearch={SEARCH_PROPS} />
|
|
156
|
+
<SiteSearch data-testid="sitesearch" {...SEARCH_PROPS} />
|
|
157
157
|
</>
|
|
158
158
|
);
|
|
159
159
|
|
|
@@ -165,7 +165,7 @@ test('site header with site search', () => {
|
|
|
165
165
|
});
|
|
166
166
|
|
|
167
167
|
test('site header with site navigation', () => {
|
|
168
|
-
const
|
|
168
|
+
const NAVIGATION_ITEMS = [
|
|
169
169
|
{ title: 'About', href: '#about' },
|
|
170
170
|
{ title: 'Get started', href: '#get-started' },
|
|
171
171
|
{ title: 'Styles', href: '#styles' },
|
|
@@ -176,8 +176,8 @@ test('site header with site navigation', () => {
|
|
|
176
176
|
|
|
177
177
|
render(
|
|
178
178
|
<>
|
|
179
|
-
<SiteHeader navigationItems={
|
|
180
|
-
<SiteNavigation data-testid="sitenavigation" items={
|
|
179
|
+
<SiteHeader navigationItems={NAVIGATION_ITEMS} />
|
|
180
|
+
<SiteNavigation data-testid="sitenavigation" items={NAVIGATION_ITEMS} />
|
|
181
181
|
</>
|
|
182
182
|
);
|
|
183
183
|
|
|
@@ -212,15 +212,15 @@ test('site header with site navigation', () => {
|
|
|
212
212
|
});
|
|
213
213
|
|
|
214
214
|
test('site header with phase banner', () => {
|
|
215
|
-
const
|
|
215
|
+
const PHASE_BANNER_PROPS = {
|
|
216
216
|
content: 'My content',
|
|
217
217
|
phaseName: 'Beta'
|
|
218
218
|
};
|
|
219
219
|
|
|
220
220
|
render(
|
|
221
221
|
<>
|
|
222
|
-
<SiteHeader phaseBanner={
|
|
223
|
-
<PhaseBanner data-testid="phasebanner" {...
|
|
222
|
+
<SiteHeader phaseBanner={PHASE_BANNER_PROPS} />
|
|
223
|
+
<PhaseBanner data-testid="phasebanner" {...PHASE_BANNER_PROPS} />
|
|
224
224
|
</>
|
|
225
225
|
);
|
|
226
226
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import { useEffect, useRef } from 'react';
|
|
4
4
|
|
|
5
|
-
import Icon from '../../common/
|
|
6
|
-
import PhaseBanner from '../
|
|
7
|
-
import SiteNavigation from "../
|
|
8
|
-
import SiteSearch from "../
|
|
5
|
+
import Icon from '../../common/Icon';
|
|
6
|
+
import PhaseBanner from '../PhaseBanner/PhaseBanner';
|
|
7
|
+
import SiteNavigation from "../SiteNavigation/SiteNavigation";
|
|
8
|
+
import SiteSearch from "../SiteSearch/SiteSearch";
|
|
9
9
|
|
|
10
10
|
// @ts-ignore
|
|
11
11
|
import DSMobileMenu from '@scottish-government/design-system/src/components/site-navigation/site-navigation';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render, screen, within } from '@testing-library/react';
|
|
3
|
-
import SiteNavigation from './
|
|
3
|
+
import SiteNavigation from './SiteNavigation';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const ITEMS = [
|
|
6
6
|
{title: 'About', href: '#about'},
|
|
7
7
|
{title: 'Get started', href: '#get-started'},
|
|
8
8
|
{title: 'Styles', href: '#styles'},
|
|
@@ -13,7 +13,7 @@ const items = [
|
|
|
13
13
|
|
|
14
14
|
test('renders correctly', () => {
|
|
15
15
|
render(
|
|
16
|
-
<SiteNavigation items={
|
|
16
|
+
<SiteNavigation items={ITEMS}/>
|
|
17
17
|
);
|
|
18
18
|
|
|
19
19
|
const nav = screen.getByRole('navigation');
|
|
@@ -29,7 +29,7 @@ test('renders correctly', () => {
|
|
|
29
29
|
expect(list).toHaveClass('ds_site-navigation__list');
|
|
30
30
|
|
|
31
31
|
// check items
|
|
32
|
-
expect(listItems.length).toEqual(
|
|
32
|
+
expect(listItems.length).toEqual(ITEMS.length);
|
|
33
33
|
|
|
34
34
|
listItems.forEach((item, index) => {
|
|
35
35
|
expect(item).toHaveClass('ds_site-navigation__item');
|
|
@@ -38,8 +38,8 @@ test('renders correctly', () => {
|
|
|
38
38
|
|
|
39
39
|
expect(link).toHaveClass('ds_site-navigation__link');
|
|
40
40
|
expect(link).not.toHaveClass('ds_current');
|
|
41
|
-
expect(link.textContent).toEqual(
|
|
42
|
-
expect(link).toHaveAttribute('href',
|
|
41
|
+
expect(link.textContent).toEqual(ITEMS[index].title);
|
|
42
|
+
expect(link).toHaveAttribute('href', ITEMS[index].href)
|
|
43
43
|
});
|
|
44
44
|
});
|
|
45
45
|
|
|
@@ -55,7 +55,7 @@ test('highlights current item', () => {
|
|
|
55
55
|
|
|
56
56
|
test('passing additional props', () => {
|
|
57
57
|
render(
|
|
58
|
-
<SiteNavigation data-test="foo" items={
|
|
58
|
+
<SiteNavigation data-test="foo" items={ITEMS}/>
|
|
59
59
|
);
|
|
60
60
|
|
|
61
61
|
const nav = screen.getByRole('navigation');
|
|
@@ -64,7 +64,7 @@ test('passing additional props', () => {
|
|
|
64
64
|
|
|
65
65
|
test('passing additional CSS classes', () => {
|
|
66
66
|
render(
|
|
67
|
-
<SiteNavigation className="foo" items={
|
|
67
|
+
<SiteNavigation className="foo" items={ITEMS}/>
|
|
68
68
|
);
|
|
69
69
|
|
|
70
70
|
const nav = screen.getByRole('navigation');
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { test, expect, vi } from 'vitest';
|
|
2
2
|
import { render, screen, within } from '@testing-library/react';
|
|
3
|
-
import SiteSearch from './
|
|
3
|
+
import SiteSearch from './SiteSearch';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
5
|
+
const SITE_SEARCH_ID = 'site-search';
|
|
6
|
+
const LABEL_TEXT = 'Search';
|
|
7
|
+
const PLACEHOLDER_TEXT = 'Search';
|
|
8
8
|
|
|
9
9
|
test('site search renders correctly', () => {
|
|
10
10
|
render(
|
|
@@ -26,17 +26,17 @@ test('site search renders correctly', () => {
|
|
|
26
26
|
expect(searchForm).toHaveAttribute('method', 'GET');
|
|
27
27
|
expect(searchForm).toHaveAttribute('action', '/search');
|
|
28
28
|
|
|
29
|
-
expect(searchLabel?.textContent).toEqual(
|
|
30
|
-
expect(searchLabel).toHaveAttribute('for',
|
|
31
|
-
expect(searchLabel).toHaveAttribute('id', `${
|
|
29
|
+
expect(searchLabel?.textContent).toEqual(LABEL_TEXT);
|
|
30
|
+
expect(searchLabel).toHaveAttribute('for', SITE_SEARCH_ID);
|
|
31
|
+
expect(searchLabel).toHaveAttribute('id', `${SITE_SEARCH_ID}-label`);
|
|
32
32
|
expect(searchLabel).toHaveClass('ds_label', 'visually-hidden');
|
|
33
33
|
|
|
34
34
|
expect(inputWrapper).toHaveClass('ds_input__wrapper ds_input__wrapper--has-icon');
|
|
35
35
|
expect(inputWrapper?.tagName).toEqual('DIV');
|
|
36
36
|
|
|
37
37
|
expect(searchInput).toHaveClass('ds_input', 'ds_site-search__input');
|
|
38
|
-
expect(searchInput).toHaveAttribute('id',
|
|
39
|
-
expect(searchInput).toHaveAttribute('placeholder',
|
|
38
|
+
expect(searchInput).toHaveAttribute('id', SITE_SEARCH_ID);
|
|
39
|
+
expect(searchInput).toHaveAttribute('placeholder', PLACEHOLDER_TEXT);
|
|
40
40
|
expect(searchInput).toHaveAttribute('required');
|
|
41
41
|
expect(searchInput).toHaveAttribute('spellcheck', 'false');
|
|
42
42
|
expect(searchInput).toHaveAttribute('type', 'search');
|
|
@@ -102,13 +102,13 @@ test('custom placeholder', () => {
|
|
|
102
102
|
});
|
|
103
103
|
|
|
104
104
|
test('autocomplete', () => {
|
|
105
|
-
const
|
|
106
|
-
const
|
|
105
|
+
const AUTOCOMPLETE_SUGGESTION_MAPPING_FUNCTION = vi.fn();
|
|
106
|
+
const SUGGESTIONS_ID = 'autocomplete-suggestions';
|
|
107
107
|
|
|
108
108
|
render(
|
|
109
109
|
<SiteSearch
|
|
110
110
|
autocompleteEndpoint="/endpoint"
|
|
111
|
-
autocompleteSuggestionMappingFunction={
|
|
111
|
+
autocompleteSuggestionMappingFunction={AUTOCOMPLETE_SUGGESTION_MAPPING_FUNCTION}
|
|
112
112
|
/>
|
|
113
113
|
)
|
|
114
114
|
|
|
@@ -120,7 +120,7 @@ test('autocomplete', () => {
|
|
|
120
120
|
const suggestionsList = within(searchForm).getByRole('listbox');
|
|
121
121
|
|
|
122
122
|
expect(searchFormContainer).toHaveClass('ds_autocomplete');
|
|
123
|
-
expect(searchFormContainer).toHaveAttribute('id', `${
|
|
123
|
+
expect(searchFormContainer).toHaveAttribute('id', `${SITE_SEARCH_ID}-autocomplete`);
|
|
124
124
|
|
|
125
125
|
expect(autocompleteStatus).toBeInTheDocument();
|
|
126
126
|
expect(autocompleteStatus).toHaveClass('visually-hidden');
|
|
@@ -129,15 +129,15 @@ test('autocomplete', () => {
|
|
|
129
129
|
expect(autocompleteStatus.tagName).toEqual('DIV');
|
|
130
130
|
|
|
131
131
|
expect(searchInput).toHaveAttribute('aria-autocomplete', 'list');
|
|
132
|
-
expect(searchInput).toHaveAttribute('aria-owns',
|
|
132
|
+
expect(searchInput).toHaveAttribute('aria-owns', SUGGESTIONS_ID);
|
|
133
133
|
expect(searchInput).toHaveAttribute('autocomplete', 'off');
|
|
134
134
|
expect(searchInput).toHaveClass('js-autocomplete-input');
|
|
135
135
|
|
|
136
|
-
expect(suggestionsContainer).toHaveAttribute('id',
|
|
136
|
+
expect(suggestionsContainer).toHaveAttribute('id', SUGGESTIONS_ID);
|
|
137
137
|
expect(suggestionsContainer?.tagName).toEqual('DIV');
|
|
138
138
|
|
|
139
139
|
expect(suggestionsList).toHaveClass('ds_autocomplete__suggestions-list');
|
|
140
|
-
expect(suggestionsList).toHaveAttribute('aria-labelledby', `${
|
|
140
|
+
expect(suggestionsList).toHaveAttribute('aria-labelledby', `${SITE_SEARCH_ID}-label`);
|
|
141
141
|
expect(suggestionsList.tagName).toEqual('OL');
|
|
142
142
|
|
|
143
143
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
2
|
// @ts-ignore
|
|
3
3
|
import DSAutocomplete from '@scottish-government/design-system/src/components/autocomplete/autocomplete';
|
|
4
|
-
import Button from '../
|
|
4
|
+
import Button from '../Button/Button';
|
|
5
5
|
|
|
6
6
|
const SiteSearch: React.FC<SGDS.Component.SiteSearch> = function ({
|
|
7
7
|
action = '/search',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render, screen, within } from '@testing-library/react';
|
|
3
|
-
import SkipLinks from './
|
|
3
|
+
import SkipLinks from './SkipLinks';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const MAIN_CONTENT_ID = 'main-content';
|
|
6
|
+
const LINK_TEXT = 'Skip to main content';
|
|
7
7
|
|
|
8
8
|
test('skip links renders correctly', () => {
|
|
9
9
|
render(
|
|
@@ -24,43 +24,43 @@ test('skip links renders correctly', () => {
|
|
|
24
24
|
expect(skipLinksListItem).toHaveClass('ds_skip-links__item');
|
|
25
25
|
|
|
26
26
|
expect(skipLinksLink).toHaveClass('ds_skip-links__link');
|
|
27
|
-
expect(skipLinksLink).toHaveAttribute('href', `#${
|
|
28
|
-
expect(skipLinksLink.textContent).toEqual(
|
|
27
|
+
expect(skipLinksLink).toHaveAttribute('href', `#${MAIN_CONTENT_ID}`);
|
|
28
|
+
expect(skipLinksLink.textContent).toEqual(LINK_TEXT);
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
test('custom link text', () => {
|
|
32
|
-
const
|
|
32
|
+
const MAIN_LINK_TEXT = 'foo';
|
|
33
33
|
|
|
34
34
|
render(
|
|
35
|
-
<SkipLinks mainLinkText={
|
|
35
|
+
<SkipLinks mainLinkText={MAIN_LINK_TEXT} />
|
|
36
36
|
);
|
|
37
37
|
|
|
38
38
|
const skipLinksList = screen.getByRole('list');
|
|
39
39
|
const skipLinksLink = within(skipLinksList).getByRole('link');
|
|
40
40
|
|
|
41
|
-
expect(skipLinksLink.textContent).toEqual(
|
|
41
|
+
expect(skipLinksLink.textContent).toEqual(MAIN_LINK_TEXT);
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
test('custom link target', () => {
|
|
45
|
-
const
|
|
45
|
+
const CUSTOM_ID = 'bar'
|
|
46
46
|
|
|
47
47
|
render(
|
|
48
|
-
<SkipLinks mainContentId={
|
|
48
|
+
<SkipLinks mainContentId={CUSTOM_ID} />
|
|
49
49
|
);
|
|
50
50
|
|
|
51
51
|
const skipLinksList = screen.getByRole('list');
|
|
52
52
|
const skipLinksLink = within(skipLinksList).getByRole('link');
|
|
53
53
|
|
|
54
|
-
expect(skipLinksLink).toHaveAttribute('href', `#${
|
|
54
|
+
expect(skipLinksLink).toHaveAttribute('href', `#${CUSTOM_ID}`)
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
test('additional links', () => {
|
|
58
|
-
const
|
|
58
|
+
const ITEMS = [
|
|
59
59
|
{ title: 'foo', targetId: 'bar' }
|
|
60
60
|
];
|
|
61
61
|
|
|
62
62
|
render(
|
|
63
|
-
<SkipLinks items={
|
|
63
|
+
<SkipLinks items={ITEMS} />
|
|
64
64
|
);
|
|
65
65
|
|
|
66
66
|
const skipLinksList = screen.getByRole('list');
|
|
@@ -68,8 +68,8 @@ test('additional links', () => {
|
|
|
68
68
|
const skipLinksSecondLink = within(skipLinksList).getAllByRole('link')[1];
|
|
69
69
|
|
|
70
70
|
expect(skipLinksListItems.length).toEqual(2);
|
|
71
|
-
expect(skipLinksSecondLink).toHaveAttribute('href', `#${
|
|
72
|
-
expect(skipLinksSecondLink.textContent).toEqual(
|
|
71
|
+
expect(skipLinksSecondLink).toHaveAttribute('href', `#${ITEMS[0].targetId}`);
|
|
72
|
+
expect(skipLinksSecondLink.textContent).toEqual(ITEMS[0].title);
|
|
73
73
|
})
|
|
74
74
|
|
|
75
75
|
test('passing additional props', () => {
|
package/src/components/{summary-card/summary-card.test.tsx → SummaryCard/SummaryCard.test.tsx}
RENAMED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { test, expect, vi } from 'vitest';
|
|
2
2
|
import { render, screen, within, fireEvent } from '@testing-library/react';
|
|
3
|
-
import SummaryCard from './
|
|
4
|
-
import SummaryList from '../
|
|
3
|
+
import SummaryCard from './SummaryCard';
|
|
4
|
+
import SummaryList from '../SummaryList/SummaryList';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const ONCLICK_FUNCTION = vi.fn();
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const ACTIONS = [
|
|
9
9
|
{
|
|
10
10
|
title: 'Change',
|
|
11
11
|
href: '#foo'
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
title: 'Delete',
|
|
15
|
-
onclick:
|
|
15
|
+
onclick: ONCLICK_FUNCTION
|
|
16
16
|
}
|
|
17
17
|
];
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
const ITEMS = [
|
|
20
20
|
{
|
|
21
21
|
title: 'Phone number',
|
|
22
22
|
value: '0123 456 7890'
|
|
@@ -27,19 +27,21 @@ const items = [
|
|
|
27
27
|
}
|
|
28
28
|
];
|
|
29
29
|
|
|
30
|
-
const
|
|
30
|
+
const TITLE_TEXT = 'Joe Bloggs';
|
|
31
31
|
|
|
32
32
|
test('summary card renders correctly', () => {
|
|
33
|
+
const DESCRIBEDBY_ID = 'summary-card-joe-bloggs';
|
|
34
|
+
|
|
33
35
|
render(
|
|
34
36
|
<>
|
|
35
37
|
<SummaryCard
|
|
36
38
|
data-testid="foo"
|
|
37
|
-
actions={
|
|
38
|
-
items={
|
|
39
|
-
title={
|
|
39
|
+
actions={ACTIONS}
|
|
40
|
+
items={ITEMS}
|
|
41
|
+
title={TITLE_TEXT}
|
|
40
42
|
/>
|
|
41
43
|
|
|
42
|
-
<SummaryList data-testid="bar" items={
|
|
44
|
+
<SummaryList data-testid="bar" items={ITEMS}/>
|
|
43
45
|
</>
|
|
44
46
|
);
|
|
45
47
|
|
|
@@ -52,20 +54,18 @@ test('summary card renders correctly', () => {
|
|
|
52
54
|
const thisList = within(content).getByRole('list');
|
|
53
55
|
const comparisonList = screen.getByTestId('bar');
|
|
54
56
|
|
|
55
|
-
const describedById = 'summary-card-joe-bloggs';
|
|
56
|
-
|
|
57
57
|
expect(summaryCard).toHaveClass('ds_summary-card');
|
|
58
58
|
|
|
59
59
|
expect(header).toHaveClass('ds_summary-card__header');
|
|
60
60
|
expect(header?.tagName).toEqual('DIV');
|
|
61
61
|
|
|
62
62
|
expect(title).toHaveClass('ds_summary-card__header-title');
|
|
63
|
-
expect(title).toHaveAttribute('id',
|
|
63
|
+
expect(title).toHaveAttribute('id', DESCRIBEDBY_ID);
|
|
64
64
|
expect(title?.tagName).toEqual('H3');
|
|
65
|
-
expect(title.textContent).toEqual(
|
|
65
|
+
expect(title.textContent).toEqual(TITLE_TEXT);
|
|
66
66
|
|
|
67
67
|
expect(actionsList?.tagName).toEqual('UL');
|
|
68
|
-
expect(actionsList.children.length).toEqual(
|
|
68
|
+
expect(actionsList.children.length).toEqual(ACTIONS.length);
|
|
69
69
|
expect(actionsList.children[0]).toHaveClass('ds_summary-card__actions-list-item');
|
|
70
70
|
expect(actionsList.children[0].tagName).toEqual('LI');
|
|
71
71
|
expect(actionsList.children[0].innerHTML).toEqual('<a aria-describedby="summary-card-joe-bloggs" class="ds_link" href="#foo">Change</a>');
|
|
@@ -73,7 +73,7 @@ test('summary card renders correctly', () => {
|
|
|
73
73
|
|
|
74
74
|
fireEvent.click(actionsList.children[1].children[0]);
|
|
75
75
|
|
|
76
|
-
expect(
|
|
76
|
+
expect(ONCLICK_FUNCTION).toHaveBeenCalled();
|
|
77
77
|
|
|
78
78
|
expect(content).toHaveClass('ds_summary-card__content');
|
|
79
79
|
expect(content?.tagName).toEqual('DIV');
|
|
@@ -81,14 +81,14 @@ test('summary card renders correctly', () => {
|
|
|
81
81
|
expect(thisList?.innerHTML).toEqual(comparisonList?.innerHTML);
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
-
test('custom
|
|
84
|
+
test('custom heading level', () => {
|
|
85
85
|
render(
|
|
86
86
|
<SummaryCard
|
|
87
87
|
data-testid="foo"
|
|
88
|
-
actions={
|
|
89
|
-
|
|
90
|
-
items={
|
|
91
|
-
title={
|
|
88
|
+
actions={ACTIONS}
|
|
89
|
+
headingLevel="h2"
|
|
90
|
+
items={ITEMS}
|
|
91
|
+
title={TITLE_TEXT}
|
|
92
92
|
/>
|
|
93
93
|
);
|
|
94
94
|
|
|
@@ -102,9 +102,9 @@ test('passing additional props', () => {
|
|
|
102
102
|
render(
|
|
103
103
|
<SummaryCard
|
|
104
104
|
data-testid="foo"
|
|
105
|
-
actions={
|
|
106
|
-
items={
|
|
107
|
-
title={
|
|
105
|
+
actions={ACTIONS}
|
|
106
|
+
items={ITEMS}
|
|
107
|
+
title={TITLE_TEXT}
|
|
108
108
|
data-test="foo"
|
|
109
109
|
/>
|
|
110
110
|
);
|
|
@@ -117,9 +117,9 @@ test('passing additional CSS classes', () => {
|
|
|
117
117
|
render(
|
|
118
118
|
<SummaryCard
|
|
119
119
|
data-testid="foo"
|
|
120
|
-
actions={
|
|
121
|
-
items={
|
|
122
|
-
title={
|
|
120
|
+
actions={ACTIONS}
|
|
121
|
+
items={ITEMS}
|
|
122
|
+
title={TITLE_TEXT}
|
|
123
123
|
className="foo"
|
|
124
124
|
/>
|
|
125
125
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import SummaryList, { Action } from "../
|
|
2
|
-
import WrapperTag from "../../common/
|
|
1
|
+
import SummaryList, { Action } from "../SummaryList/SummaryList";
|
|
2
|
+
import WrapperTag from "../../common/WrapperTag";
|
|
3
3
|
|
|
4
4
|
function convertToSlug(string: string) {
|
|
5
5
|
return string.toLowerCase()
|
|
@@ -10,7 +10,7 @@ function convertToSlug(string: string) {
|
|
|
10
10
|
const SummaryCard: React.FC<SGDS.Component.SummaryCard> = ({
|
|
11
11
|
actions,
|
|
12
12
|
className,
|
|
13
|
-
|
|
13
|
+
headingLevel = 'h3',
|
|
14
14
|
items,
|
|
15
15
|
title,
|
|
16
16
|
...props
|
|
@@ -29,7 +29,7 @@ const SummaryCard: React.FC<SGDS.Component.SummaryCard> = ({
|
|
|
29
29
|
<WrapperTag
|
|
30
30
|
className="ds_summary-card__header-title"
|
|
31
31
|
id={describedById}
|
|
32
|
-
tagName={
|
|
32
|
+
tagName={headingLevel}
|
|
33
33
|
>{title}</WrapperTag>
|
|
34
34
|
|
|
35
35
|
<ul className="ds_summary-card__actions-list">
|