@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
package/src/components/{hide-this-page/hide-this-page.test.tsx → HideThisPage/HideThisPage.test.tsx}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render, screen, within } from '@testing-library/react';
|
|
3
|
-
import HideThisPage from './
|
|
3
|
+
import HideThisPage from './HideThisPage';
|
|
4
4
|
|
|
5
5
|
test('hide this page renders correctly', () => {
|
|
6
6
|
render(
|
|
@@ -39,16 +39,16 @@ test('hide this page renders correctly', () => {
|
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
test('custom escape URL', () => {
|
|
42
|
-
const
|
|
42
|
+
const ESCAPE_URL = 'https://www.mygov.scot';
|
|
43
43
|
|
|
44
44
|
render(
|
|
45
|
-
<HideThisPage data-testid="htp" escapeUrl={
|
|
45
|
+
<HideThisPage data-testid="htp" escapeUrl={ESCAPE_URL} />
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
const hideThisPageElement = screen.getByTestId('htp');
|
|
49
49
|
const link = within(hideThisPageElement).getByRole('link');
|
|
50
50
|
|
|
51
|
-
expect(link).toHaveAttribute('href',
|
|
51
|
+
expect(link).toHaveAttribute('href', ESCAPE_URL);
|
|
52
52
|
})
|
|
53
53
|
|
|
54
54
|
test('passing additional props', () => {
|
|
@@ -13,10 +13,10 @@ const HideThisPage: React.FC<SGDS.Component.HideThisPage> = ({
|
|
|
13
13
|
if (ref.current) {
|
|
14
14
|
new DSHideThisPage().init();
|
|
15
15
|
|
|
16
|
-
const
|
|
17
|
-
if (!document.getElementById(
|
|
16
|
+
const HIDE_THIS_PAGE_DIV_ID = 'hide-this-page-instruction';
|
|
17
|
+
if (!document.getElementById(HIDE_THIS_PAGE_DIV_ID)) {
|
|
18
18
|
const htpDiv = document.createElement('div');
|
|
19
|
-
htpDiv.id =
|
|
19
|
+
htpDiv.id = HIDE_THIS_PAGE_DIV_ID;
|
|
20
20
|
htpDiv.classList.add('visually-hidden');
|
|
21
21
|
htpDiv.classList.add('ds_hide-page');
|
|
22
22
|
htpDiv.innerHTML = '<p>To leave the page quickly, press the escape key.</p>';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
|
-
import InsetText from './
|
|
3
|
+
import InsetText from './InsetText';
|
|
4
4
|
|
|
5
5
|
const text = `You may be able to apply for free school meals at the same
|
|
6
6
|
time as you apply for the clothing grant.`;
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
import { test, expect } from 'vitest';
|
|
7
7
|
import { render, screen, within } from '@testing-library/react';
|
|
8
|
-
import NotificationBanner from './
|
|
8
|
+
import NotificationBanner from './NotificationBanner';
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const BANNER_TEXT = 'We need to tell you about something';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* NotificationBanner has the ds_reversed class
|
|
@@ -15,7 +15,7 @@ const text = 'We need to tell you about something';
|
|
|
15
15
|
test('notification banner renders correctly', () => {
|
|
16
16
|
render(
|
|
17
17
|
<NotificationBanner>
|
|
18
|
-
{
|
|
18
|
+
{BANNER_TEXT}
|
|
19
19
|
</NotificationBanner>
|
|
20
20
|
);
|
|
21
21
|
|
|
@@ -30,7 +30,7 @@ test('notification banner renders correctly', () => {
|
|
|
30
30
|
test('notification banner with icon', () => {
|
|
31
31
|
render(
|
|
32
32
|
<NotificationBanner icon>
|
|
33
|
-
{
|
|
33
|
+
{BANNER_TEXT}
|
|
34
34
|
</NotificationBanner>
|
|
35
35
|
);
|
|
36
36
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
|
-
import AbstractNotificationBanner from '../../common/
|
|
2
|
+
import AbstractNotificationBanner from '../../common/AbstractNotificationBanner';
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
import DSNotificationBanner from '@scottish-government/design-system/src/components/notification-banner/notification-banner';
|
|
5
5
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import NotificationPanel from './
|
|
3
|
+
import NotificationPanel from './NotificationPanel';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const HEADING_TEXT = 'Thank you';
|
|
6
|
+
const TEXT = 'Your Saltire Scholarship Application form has been successfully submitted.';
|
|
7
7
|
|
|
8
8
|
test('notification banner renders correctly', () => {
|
|
9
9
|
render(
|
|
10
|
-
<NotificationPanel title={
|
|
11
|
-
{
|
|
10
|
+
<NotificationPanel title={HEADING_TEXT}>
|
|
11
|
+
{TEXT}
|
|
12
12
|
</NotificationPanel>
|
|
13
13
|
);
|
|
14
14
|
|
|
@@ -18,56 +18,57 @@ test('notification banner renders correctly', () => {
|
|
|
18
18
|
|
|
19
19
|
expect(notificationPanel).toHaveClass('ds_notification-panel');
|
|
20
20
|
expect(notificationPanelHeading).toHaveClass('ds_notification-panel__title');
|
|
21
|
-
expect(notificationPanelHeading.textContent).toEqual(
|
|
21
|
+
expect(notificationPanelHeading.textContent).toEqual(HEADING_TEXT);
|
|
22
22
|
expect(notificationPanelHeading.tagName).toEqual('H1');
|
|
23
23
|
expect(notificationPanelContent).toHaveClass('ds_notification-panel__content');
|
|
24
|
-
expect(notificationPanelContent?.textContent).toEqual(
|
|
24
|
+
expect(notificationPanelContent?.textContent).toEqual(TEXT);
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
test('notification banner with custom heading level', () => {
|
|
28
|
-
const
|
|
28
|
+
const HEADING_LEVEL = 'h2';
|
|
29
29
|
|
|
30
30
|
render(
|
|
31
|
-
<NotificationPanel
|
|
32
|
-
{
|
|
31
|
+
<NotificationPanel headingLevel={HEADING_LEVEL} title={HEADING_TEXT}>
|
|
32
|
+
{TEXT}
|
|
33
33
|
</NotificationPanel>
|
|
34
34
|
);
|
|
35
35
|
|
|
36
36
|
const notificationPanelHeading = screen.getByRole('heading');
|
|
37
|
-
expect(notificationPanelHeading.tagName).toEqual(
|
|
37
|
+
expect(notificationPanelHeading.tagName).toEqual(HEADING_LEVEL.toUpperCase());
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
test('notification banner with aria-live', () => {
|
|
41
|
-
const
|
|
41
|
+
const ARIA_LIVE = 'polite';
|
|
42
42
|
|
|
43
43
|
render(
|
|
44
|
-
<NotificationPanel ariaLive={
|
|
45
|
-
{
|
|
44
|
+
<NotificationPanel ariaLive={ARIA_LIVE} title={HEADING_TEXT}>
|
|
45
|
+
{TEXT}
|
|
46
46
|
</NotificationPanel>
|
|
47
47
|
);
|
|
48
48
|
|
|
49
49
|
const notificationPanelHeading = screen.getByRole('heading');
|
|
50
50
|
const notificationPanel = notificationPanelHeading.parentElement;
|
|
51
51
|
|
|
52
|
-
expect(notificationPanel).toHaveAttribute('aria-live',
|
|
52
|
+
expect(notificationPanel).toHaveAttribute('aria-live', ARIA_LIVE);
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
test('notification banner with nonsense heading level reverts to H1', () => {
|
|
56
|
-
const
|
|
56
|
+
const HEADING_LEVEL = 'h2';
|
|
57
|
+
|
|
57
58
|
render(
|
|
58
|
-
<NotificationPanel
|
|
59
|
-
{
|
|
59
|
+
<NotificationPanel headingLevel={HEADING_LEVEL} title={HEADING_TEXT}>
|
|
60
|
+
{TEXT}
|
|
60
61
|
</NotificationPanel>
|
|
61
62
|
);
|
|
62
63
|
|
|
63
64
|
const notificationPanelHeading = screen.getByRole('heading');
|
|
64
|
-
expect(notificationPanelHeading.tagName).toEqual(
|
|
65
|
+
expect(notificationPanelHeading.tagName).toEqual(HEADING_LEVEL.toUpperCase());
|
|
65
66
|
});
|
|
66
67
|
|
|
67
68
|
test('passing additional props', () => {
|
|
68
69
|
render(
|
|
69
|
-
<NotificationPanel title={
|
|
70
|
-
{
|
|
70
|
+
<NotificationPanel title={HEADING_TEXT} data-test="foo">
|
|
71
|
+
{TEXT}
|
|
71
72
|
</NotificationPanel>
|
|
72
73
|
)
|
|
73
74
|
|
|
@@ -78,8 +79,8 @@ test('passing additional props', () => {
|
|
|
78
79
|
|
|
79
80
|
test('passing additional CSS classes', () => {
|
|
80
81
|
render(
|
|
81
|
-
<NotificationPanel title={
|
|
82
|
-
{
|
|
82
|
+
<NotificationPanel title={HEADING_TEXT} className="foo">
|
|
83
|
+
{TEXT}
|
|
83
84
|
</NotificationPanel>
|
|
84
85
|
)
|
|
85
86
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import WrapperTag from '../../common/
|
|
1
|
+
import WrapperTag from '../../common/WrapperTag';
|
|
2
2
|
|
|
3
3
|
const NotificationPanel: React.FC<SGDS.Component.NotificationPanel> = function ({
|
|
4
4
|
ariaLive,
|
|
5
5
|
children,
|
|
6
6
|
className,
|
|
7
|
-
|
|
7
|
+
headingLevel = 'h1',
|
|
8
8
|
title,
|
|
9
9
|
...props
|
|
10
10
|
}) {
|
|
@@ -19,7 +19,7 @@ const NotificationPanel: React.FC<SGDS.Component.NotificationPanel> = function (
|
|
|
19
19
|
>
|
|
20
20
|
<WrapperTag
|
|
21
21
|
className="ds_notification-panel__title"
|
|
22
|
-
tagName={
|
|
22
|
+
tagName={headingLevel}
|
|
23
23
|
>
|
|
24
24
|
{title}
|
|
25
25
|
</WrapperTag>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render, screen, within } from '@testing-library/react';
|
|
3
|
-
import PageHeader from './
|
|
3
|
+
import PageHeader from './PageHeader';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const LABEL_TEXT = 'Guide';
|
|
6
|
+
const TITLE_TEXT = 'Apply for or renew a disabled parking permit';
|
|
7
7
|
|
|
8
8
|
test('notification banner renders correctly', () => {
|
|
9
9
|
render(
|
|
10
|
-
<PageHeader label={
|
|
10
|
+
<PageHeader label={LABEL_TEXT} title={TITLE_TEXT}/>
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
const header = screen.getByRole('banner');
|
|
@@ -18,17 +18,17 @@ test('notification banner renders correctly', () => {
|
|
|
18
18
|
expect(header.tagName).toEqual('HEADER');
|
|
19
19
|
|
|
20
20
|
expect(label).toHaveClass('ds_page-header__label', 'ds_content-label');
|
|
21
|
-
expect(label?.textContent).toEqual(
|
|
21
|
+
expect(label?.textContent).toEqual(LABEL_TEXT);
|
|
22
22
|
expect(label?.tagName).toEqual('SPAN');
|
|
23
23
|
|
|
24
24
|
expect(title).toHaveClass('ds_page-header__title');
|
|
25
|
-
expect(title.textContent).toEqual(
|
|
25
|
+
expect(title.textContent).toEqual(TITLE_TEXT);
|
|
26
26
|
expect(title.tagName).toEqual('H1');
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
test('header with no label', () => {
|
|
30
30
|
render(
|
|
31
|
-
<PageHeader title={
|
|
31
|
+
<PageHeader title={TITLE_TEXT}/>
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
const header = screen.getByRole('banner');
|
|
@@ -40,7 +40,7 @@ test('header with no label', () => {
|
|
|
40
40
|
|
|
41
41
|
test('passing additional props', () => {
|
|
42
42
|
render(
|
|
43
|
-
<PageHeader data-test="foo" label={
|
|
43
|
+
<PageHeader data-test="foo" label={LABEL_TEXT} title={TITLE_TEXT}/>
|
|
44
44
|
)
|
|
45
45
|
|
|
46
46
|
const header = screen.getByRole('banner');
|
|
@@ -49,7 +49,7 @@ test('passing additional props', () => {
|
|
|
49
49
|
|
|
50
50
|
test('passing additional CSS classes', () => {
|
|
51
51
|
render(
|
|
52
|
-
<PageHeader className="foo" label={
|
|
52
|
+
<PageHeader className="foo" label={LABEL_TEXT} title={TITLE_TEXT}/>
|
|
53
53
|
)
|
|
54
54
|
|
|
55
55
|
const header = screen.getByRole('banner');
|
package/src/components/{page-metadata/page-metadata.test.tsx → PageMetadata/PageMetadata.test.tsx}
RENAMED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import Metadata from './
|
|
3
|
+
import Metadata from './PageMetadata';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const NAME = 'Directorate';
|
|
6
|
+
const VALUE = 'Equality, Inclusion and Human Rights Directorate';
|
|
7
7
|
|
|
8
8
|
test('metadata renders correctly', () => {
|
|
9
9
|
render(
|
|
10
10
|
<Metadata>
|
|
11
|
-
<Metadata.Item name={
|
|
12
|
-
{
|
|
11
|
+
<Metadata.Item name={NAME}>
|
|
12
|
+
{VALUE}
|
|
13
13
|
</Metadata.Item>
|
|
14
14
|
</Metadata>
|
|
15
15
|
);
|
|
@@ -22,16 +22,16 @@ test('metadata renders correctly', () => {
|
|
|
22
22
|
expect(metadata).toBeInTheDocument();
|
|
23
23
|
expect(metadataItem).toBeInTheDocument();
|
|
24
24
|
expect(metadataItemKey).toHaveClass('ds_metadata__key');
|
|
25
|
-
expect(metadataItemKey.textContent).toEqual(
|
|
25
|
+
expect(metadataItemKey.textContent).toEqual(NAME);
|
|
26
26
|
expect(metadataItemValue).toHaveClass('ds_metadata__value');
|
|
27
|
-
expect(metadataItemValue.textContent).toEqual(
|
|
27
|
+
expect(metadataItemValue.textContent).toEqual(VALUE);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
test('inline metadata', () => {
|
|
31
31
|
render(
|
|
32
32
|
<Metadata inline>
|
|
33
|
-
<Metadata.Item name={
|
|
34
|
-
{
|
|
33
|
+
<Metadata.Item name={NAME}>
|
|
34
|
+
{VALUE}
|
|
35
35
|
</Metadata.Item>
|
|
36
36
|
</Metadata>
|
|
37
37
|
);
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import { test, expect, vi } from 'vitest';
|
|
2
2
|
import { render, screen, within, fireEvent } from '@testing-library/react';
|
|
3
|
-
import Pagination, { Page, Ellipsis } from './
|
|
3
|
+
import Pagination, { Page, Ellipsis } from './Pagination';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
5
|
+
const PAGE_ARIA_LABEL = 'Page 1';
|
|
6
|
+
const PAGE_HREF = '#foo';
|
|
7
|
+
const PAGE_TEXT = '1';
|
|
8
|
+
const CURRENT_PAGE = 10;
|
|
9
|
+
const TOTAL_PAGES = 21;
|
|
10
10
|
|
|
11
11
|
test('pagination page renders correctly', () => {
|
|
12
12
|
render(
|
|
13
13
|
<Page
|
|
14
|
-
ariaLabel={
|
|
15
|
-
href={
|
|
16
|
-
text={
|
|
14
|
+
ariaLabel={PAGE_ARIA_LABEL}
|
|
15
|
+
href={PAGE_HREF}
|
|
16
|
+
text={PAGE_TEXT}
|
|
17
17
|
/>
|
|
18
18
|
);
|
|
19
19
|
|
|
20
20
|
const item = screen.getByRole('listitem');
|
|
21
21
|
const link = within(item).getByRole('link');
|
|
22
|
-
const span = within(link).getByText(
|
|
22
|
+
const span = within(link).getByText(PAGE_TEXT);
|
|
23
23
|
|
|
24
24
|
expect(item).toHaveClass('ds_pagination__item');
|
|
25
25
|
expect(link).toHaveClass('ds_pagination__link');
|
|
26
|
-
expect(link).toHaveAttribute('aria-label',
|
|
27
|
-
expect(link).toHaveAttribute('href',
|
|
26
|
+
expect(link).toHaveAttribute('aria-label', PAGE_ARIA_LABEL);
|
|
27
|
+
expect(link).toHaveAttribute('href', PAGE_HREF);
|
|
28
28
|
expect(span).toHaveClass('ds_pagination__link-label');
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
test('current pagination page', () => {
|
|
32
32
|
render(
|
|
33
33
|
<Page
|
|
34
|
-
ariaLabel={
|
|
35
|
-
href={
|
|
36
|
-
text={
|
|
34
|
+
ariaLabel={PAGE_ARIA_LABEL}
|
|
35
|
+
href={PAGE_HREF}
|
|
36
|
+
text={PAGE_TEXT}
|
|
37
37
|
current
|
|
38
38
|
/>
|
|
39
39
|
);
|
|
@@ -46,14 +46,14 @@ test('current pagination page', () => {
|
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
test('pagination page with click event', () => {
|
|
49
|
-
const
|
|
49
|
+
const ONCLICK_FUNCTION = vi.fn();
|
|
50
50
|
|
|
51
51
|
render(
|
|
52
52
|
<Page
|
|
53
|
-
ariaLabel={
|
|
54
|
-
href={
|
|
55
|
-
text={
|
|
56
|
-
onClick={
|
|
53
|
+
ariaLabel={PAGE_ARIA_LABEL}
|
|
54
|
+
href={PAGE_HREF}
|
|
55
|
+
text={PAGE_TEXT}
|
|
56
|
+
onClick={ONCLICK_FUNCTION}
|
|
57
57
|
/>
|
|
58
58
|
);
|
|
59
59
|
|
|
@@ -62,7 +62,7 @@ test('pagination page with click event', () => {
|
|
|
62
62
|
|
|
63
63
|
fireEvent.click(link);
|
|
64
64
|
|
|
65
|
-
expect(
|
|
65
|
+
expect(ONCLICK_FUNCTION).toHaveBeenCalled();
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
test('Ellipsis item renders correctly', () => {
|
|
@@ -79,11 +79,11 @@ test('Ellipsis item renders correctly', () => {
|
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
test('pagination renders correctly', () => {
|
|
82
|
-
const
|
|
83
|
-
const
|
|
82
|
+
const CURRENT_PAGE = 10;
|
|
83
|
+
const TOTAL_PAGES = 21;
|
|
84
84
|
|
|
85
85
|
render(
|
|
86
|
-
<Pagination page={
|
|
86
|
+
<Pagination page={CURRENT_PAGE} totalPages={TOTAL_PAGES} />
|
|
87
87
|
);
|
|
88
88
|
|
|
89
89
|
const paginationNav = screen.getByRole('navigation');
|
|
@@ -100,7 +100,7 @@ test('pagination renders correctly', () => {
|
|
|
100
100
|
const firstPageLabel = within(paginationList).getByText('1');
|
|
101
101
|
const firstPageLink = firstPageLabel.parentElement;
|
|
102
102
|
const firstPageItem = firstPageLink?.parentElement;
|
|
103
|
-
const lastPageLabel = within(paginationList).getByText(
|
|
103
|
+
const lastPageLabel = within(paginationList).getByText(TOTAL_PAGES);
|
|
104
104
|
const lastPageLink = lastPageLabel.parentElement;
|
|
105
105
|
const lastPageItem = lastPageLink?.parentElement;
|
|
106
106
|
|
|
@@ -125,7 +125,7 @@ test('pagination renders correctly', () => {
|
|
|
125
125
|
expect(prevItem?.parentElement).toEqual(paginationList);
|
|
126
126
|
expect(prevLink).toHaveClass('ds_pagination__link', 'ds_pagination__link--text', 'ds_pagination__link--icon')
|
|
127
127
|
expect(prevLink).toHaveAttribute('aria-label', 'Previous page');
|
|
128
|
-
expect(prevLink).toHaveAttribute('href', `/search?page=${
|
|
128
|
+
expect(prevLink).toHaveAttribute('href', `/search?page=${CURRENT_PAGE - 1}`);
|
|
129
129
|
expect(prevLink?.tagName).toEqual('A');
|
|
130
130
|
expect(prevIcon).toHaveClass('ds_icon');
|
|
131
131
|
expect(prevIcon).toHaveAttribute('aria-hidden', 'true')
|
|
@@ -138,7 +138,7 @@ test('pagination renders correctly', () => {
|
|
|
138
138
|
expect(nextItem?.parentElement).toEqual(paginationList);
|
|
139
139
|
expect(nextLink).toHaveClass('ds_pagination__link', 'ds_pagination__link--text', 'ds_pagination__link--icon')
|
|
140
140
|
expect(nextLink).toHaveAttribute('aria-label', 'Next page');
|
|
141
|
-
expect(nextLink).toHaveAttribute('href', `/search?page=${
|
|
141
|
+
expect(nextLink).toHaveAttribute('href', `/search?page=${CURRENT_PAGE + 1}`);
|
|
142
142
|
expect(nextLink?.tagName).toEqual('A');
|
|
143
143
|
expect(nextIcon).toHaveClass('ds_icon');
|
|
144
144
|
expect(nextIcon).toHaveAttribute('aria-hidden', 'true')
|
|
@@ -160,8 +160,8 @@ test('pagination renders correctly', () => {
|
|
|
160
160
|
expect(lastPageItem?.tagName).toEqual('LI');
|
|
161
161
|
expect(lastPageItem?.parentElement).toEqual(paginationList);
|
|
162
162
|
expect(lastPageLink).toHaveClass('ds_pagination__link')
|
|
163
|
-
expect(lastPageLink).toHaveAttribute('aria-label', `Page ${
|
|
164
|
-
expect(lastPageLink).toHaveAttribute('href', `/search?page=${
|
|
163
|
+
expect(lastPageLink).toHaveAttribute('aria-label', `Page ${TOTAL_PAGES}`);
|
|
164
|
+
expect(lastPageLink).toHaveAttribute('href', `/search?page=${TOTAL_PAGES}`);
|
|
165
165
|
expect(lastPageLink?.tagName).toEqual('A');
|
|
166
166
|
expect(lastPageLabel).toHaveClass('ds_pagination__link-label');
|
|
167
167
|
expect(lastPageLabel?.tagName).toEqual('SPAN');
|
|
@@ -184,7 +184,7 @@ test('pagination renders correctly', () => {
|
|
|
184
184
|
|
|
185
185
|
expect(currentPageItem).toHaveClass('ds_pagination__item');
|
|
186
186
|
expect(currentPageLink).toHaveClass('ds_pagination__link', 'ds_current');
|
|
187
|
-
expect(currentPageLink?.textContent).toEqual(
|
|
187
|
+
expect(currentPageLink?.textContent).toEqual(CURRENT_PAGE.toString());
|
|
188
188
|
|
|
189
189
|
// expect one link either side of the current (default padding)
|
|
190
190
|
expect(currentPageItem?.previousElementSibling?.querySelector('a')).toHaveAttribute('aria-label', 'Page 9');
|
|
@@ -198,13 +198,13 @@ test('pagination renders correctly', () => {
|
|
|
198
198
|
});
|
|
199
199
|
|
|
200
200
|
test('pagination with 2 padding', () => {
|
|
201
|
-
const
|
|
201
|
+
const PADDING = 2;
|
|
202
202
|
|
|
203
203
|
render(
|
|
204
204
|
<Pagination
|
|
205
|
-
page={
|
|
206
|
-
totalPages={
|
|
207
|
-
padding={
|
|
205
|
+
page={CURRENT_PAGE}
|
|
206
|
+
totalPages={TOTAL_PAGES}
|
|
207
|
+
padding={PADDING}
|
|
208
208
|
/>
|
|
209
209
|
);
|
|
210
210
|
|
|
@@ -217,29 +217,29 @@ test('pagination with 2 padding', () => {
|
|
|
217
217
|
});
|
|
218
218
|
|
|
219
219
|
test('pagination with custom aria label', () => {
|
|
220
|
-
const
|
|
220
|
+
const ARIA_LABEL = 'My label';
|
|
221
221
|
|
|
222
222
|
render(
|
|
223
223
|
<Pagination
|
|
224
|
-
page={
|
|
225
|
-
totalPages={
|
|
226
|
-
ariaLabel={
|
|
224
|
+
page={CURRENT_PAGE}
|
|
225
|
+
totalPages={TOTAL_PAGES}
|
|
226
|
+
ariaLabel={ARIA_LABEL}
|
|
227
227
|
/>
|
|
228
228
|
);
|
|
229
229
|
|
|
230
230
|
const paginationNav = screen.getByRole('navigation');
|
|
231
231
|
|
|
232
|
-
expect(paginationNav).toHaveAttribute('aria-label',
|
|
232
|
+
expect(paginationNav).toHaveAttribute('aria-label', ARIA_LABEL);
|
|
233
233
|
});
|
|
234
234
|
|
|
235
235
|
test('pagination passes onclick event to child links', () => {
|
|
236
|
-
const
|
|
236
|
+
const ONCLICK_FUNCTION = vi.fn();
|
|
237
237
|
|
|
238
238
|
render(
|
|
239
239
|
<Pagination
|
|
240
|
-
page={
|
|
241
|
-
totalPages={
|
|
242
|
-
onClick={
|
|
240
|
+
page={CURRENT_PAGE}
|
|
241
|
+
totalPages={TOTAL_PAGES}
|
|
242
|
+
onClick={ONCLICK_FUNCTION}
|
|
243
243
|
/>
|
|
244
244
|
);
|
|
245
245
|
|
|
@@ -249,14 +249,14 @@ test('pagination passes onclick event to child links', () => {
|
|
|
249
249
|
|
|
250
250
|
fireEvent.click(link);
|
|
251
251
|
|
|
252
|
-
expect(
|
|
252
|
+
expect(ONCLICK_FUNCTION).toHaveBeenCalled();
|
|
253
253
|
});
|
|
254
254
|
|
|
255
255
|
test('pagination modifies an input pattern for its link format', () => {
|
|
256
256
|
render(
|
|
257
257
|
<Pagination
|
|
258
|
-
page={
|
|
259
|
-
totalPages={
|
|
258
|
+
page={CURRENT_PAGE}
|
|
259
|
+
totalPages={TOTAL_PAGES}
|
|
260
260
|
pattern='My/Link/Format?Page=$1#foo'
|
|
261
261
|
/>
|
|
262
262
|
);
|
|
@@ -271,7 +271,7 @@ test('pagination at an early link in the list', () => {
|
|
|
271
271
|
render(
|
|
272
272
|
<Pagination
|
|
273
273
|
page="1"
|
|
274
|
-
totalPages={
|
|
274
|
+
totalPages={TOTAL_PAGES}
|
|
275
275
|
/>
|
|
276
276
|
);
|
|
277
277
|
|
|
@@ -289,7 +289,7 @@ test('pagination at an early link in the list, increased padding', () => {
|
|
|
289
289
|
<Pagination
|
|
290
290
|
padding={2}
|
|
291
291
|
page="1"
|
|
292
|
-
totalPages={
|
|
292
|
+
totalPages={TOTAL_PAGES}
|
|
293
293
|
/>
|
|
294
294
|
);
|
|
295
295
|
|
|
@@ -305,8 +305,8 @@ test('pagination at an early link in the list, increased padding', () => {
|
|
|
305
305
|
test('pagination at late link in the list', () => {
|
|
306
306
|
render(
|
|
307
307
|
<Pagination
|
|
308
|
-
page={
|
|
309
|
-
totalPages={
|
|
308
|
+
page={TOTAL_PAGES}
|
|
309
|
+
totalPages={TOTAL_PAGES}
|
|
310
310
|
/>
|
|
311
311
|
);
|
|
312
312
|
|
|
@@ -323,8 +323,8 @@ test('pagination at late link in the list, increased padding', () => {
|
|
|
323
323
|
render(
|
|
324
324
|
<Pagination
|
|
325
325
|
padding={2}
|
|
326
|
-
page={
|
|
327
|
-
totalPages={
|
|
326
|
+
page={TOTAL_PAGES}
|
|
327
|
+
totalPages={TOTAL_PAGES}
|
|
328
328
|
/>
|
|
329
329
|
);
|
|
330
330
|
|
|
@@ -340,8 +340,8 @@ test('pagination at late link in the list, increased padding', () => {
|
|
|
340
340
|
test('passing additional props', () => {
|
|
341
341
|
render(
|
|
342
342
|
<Pagination
|
|
343
|
-
page={
|
|
344
|
-
totalPages={
|
|
343
|
+
page={CURRENT_PAGE}
|
|
344
|
+
totalPages={TOTAL_PAGES}
|
|
345
345
|
data-test="foo"
|
|
346
346
|
/>
|
|
347
347
|
);
|
|
@@ -353,8 +353,8 @@ test('passing additional props', () => {
|
|
|
353
353
|
test('passing additional CSS classes', () => {
|
|
354
354
|
render(
|
|
355
355
|
<Pagination
|
|
356
|
-
page={
|
|
357
|
-
totalPages={
|
|
356
|
+
page={CURRENT_PAGE}
|
|
357
|
+
totalPages={TOTAL_PAGES}
|
|
358
358
|
className="foo"
|
|
359
359
|
/>
|
|
360
360
|
)
|
package/src/components/{phase-banner/phase-banner.test.tsx → PhaseBanner/PhaseBanner.test.tsx}
RENAMED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
|
-
import PhaseBanner from './
|
|
3
|
+
import PhaseBanner from './PhaseBanner';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const BANNER_TEXT = 'This is a new service. Your feedback will help us to improve it.';
|
|
6
|
+
const DEFAULT_TEXT = 'This is a new service';
|
|
7
7
|
|
|
8
8
|
test('phase banner renders correctly', () => {
|
|
9
9
|
render(
|
|
10
10
|
<PhaseBanner>
|
|
11
|
-
{
|
|
11
|
+
{BANNER_TEXT}
|
|
12
12
|
</PhaseBanner>
|
|
13
13
|
);
|
|
14
14
|
|
|
@@ -23,7 +23,7 @@ test('phase banner renders correctly', () => {
|
|
|
23
23
|
expect(phaseBannerWrapper?.tagName).toEqual('DIV');
|
|
24
24
|
expect(phaseBannerContent?.tagName).toEqual('P');
|
|
25
25
|
expect(phaseBannerText?.tagName).toEqual('SPAN');
|
|
26
|
-
expect(phaseBannerText?.textContent).toEqual(
|
|
26
|
+
expect(phaseBannerText?.textContent).toEqual(BANNER_TEXT);
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
test('phase banner with default text', () => {
|
|
@@ -36,14 +36,14 @@ test('phase banner with default text', () => {
|
|
|
36
36
|
const phaseBannerContent = phaseBanner?.querySelector('.ds_phase-banner__content');
|
|
37
37
|
const phaseBannerText = phaseBannerContent?.querySelector('.ds_phase-banner__text');
|
|
38
38
|
|
|
39
|
-
expect(phaseBannerText?.textContent).toEqual(
|
|
39
|
+
expect(phaseBannerText?.textContent).toEqual(DEFAULT_TEXT);
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
test('phase banner with phase tag', () => {
|
|
43
|
-
const
|
|
43
|
+
const PHASE_TEXT = 'Beta';
|
|
44
44
|
|
|
45
45
|
render(
|
|
46
|
-
<PhaseBanner phaseName={
|
|
46
|
+
<PhaseBanner phaseName={PHASE_TEXT}></PhaseBanner>
|
|
47
47
|
);
|
|
48
48
|
|
|
49
49
|
const phaseBanner = document.querySelector('.ds_phase-banner');
|
|
@@ -52,7 +52,7 @@ test('phase banner with phase tag', () => {
|
|
|
52
52
|
expect(phaseBannerTag).toBeInTheDocument();
|
|
53
53
|
expect(phaseBannerTag?.tagName).toEqual('SPAN');
|
|
54
54
|
expect(phaseBannerTag).toHaveClass('ds_tag', 'ds_phase-banner__tag');
|
|
55
|
-
expect(phaseBannerTag?.textContent).toEqual(
|
|
55
|
+
expect(phaseBannerTag?.textContent).toEqual(PHASE_TEXT);
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
test('passing additional props', () => {
|