@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.
Files changed (169) hide show
  1. package/@types/components/Accordion.d.ts +2 -2
  2. package/@types/components/ConfirmationMessage.d.ts +1 -1
  3. package/@types/components/NotificationPanel.d.ts +1 -1
  4. package/@types/components/SummaryCard.d.ts +1 -1
  5. package/@types/components/Tabs.d.ts +1 -1
  6. package/@types/sgds.d.ts +1 -1
  7. package/CHANGELOG.md +81 -0
  8. package/README.md +4 -0
  9. package/dist/common/{abstract-notification-banner.jsx → AbstractNotificationBanner.jsx} +5 -5
  10. package/dist/components/{accordion/accordion.jsx → Accordion/Accordion.jsx} +6 -6
  11. package/dist/components/{back-to-top/back-to-top.jsx → BackToTop/BackToTop.jsx} +2 -2
  12. package/dist/components/{button/button.jsx → Button/Button.jsx} +7 -7
  13. package/dist/components/{checkbox/checkbox.jsx → Checkbox/Checkbox.jsx} +2 -2
  14. package/dist/components/{confirmation-message/confirmation-message.jsx → ConfirmationMessage/ConfirmationMessage.jsx} +6 -6
  15. package/dist/components/{contents-nav/contents-nav.jsx → ContentsNav/ContentsNav.jsx} +3 -3
  16. package/dist/components/{cookie-banner/cookie-banner.jsx → CookieBanner/CookieBanner.jsx} +4 -4
  17. package/dist/components/{date-picker/date-picker.jsx → DatePicker/DatePicker.jsx} +7 -7
  18. package/dist/components/{error-summary/error-summary.jsx → ErrorSummary/ErrorSummary.jsx} +2 -2
  19. package/dist/components/{file-download/file-download.jsx → FileDownload/FileDownload.jsx} +2 -2
  20. package/dist/components/{hide-this-page/hide-this-page.jsx → HideThisPage/HideThisPage.jsx} +3 -3
  21. package/dist/components/{notification-banner/notification-banner.jsx → NotificationBanner/NotificationBanner.jsx} +4 -4
  22. package/dist/components/{notification-panel/notification-panel.jsx → NotificationPanel/NotificationPanel.jsx} +4 -4
  23. package/dist/components/{pagination/pagination.jsx → Pagination/Pagination.jsx} +3 -3
  24. package/dist/components/{phase-banner/phase-banner.jsx → PhaseBanner/PhaseBanner.jsx} +2 -2
  25. package/dist/components/{question/question.jsx → Question/Question.jsx} +7 -7
  26. package/dist/components/{radio-button/radio-button.jsx → RadioButton/RadioButton.jsx} +2 -2
  27. package/dist/components/{select/select.jsx → Select/Select.jsx} +4 -4
  28. package/dist/components/{site-header/site-header.jsx → SiteHeader/SiteHeader.jsx} +13 -13
  29. package/dist/components/{site-search/site-search.jsx → SiteSearch/SiteSearch.jsx} +2 -2
  30. package/dist/components/{summary-card/summary-card.jsx → SummaryCard/SummaryCard.jsx} +6 -6
  31. package/dist/components/{summary-list/summary-list.jsx → SummaryList/SummaryList.jsx} +8 -8
  32. package/dist/components/{tabs/tabs.jsx → Tabs/Tabs.jsx} +4 -4
  33. package/dist/components/{task-list/task-list.jsx → TaskList/TaskList.jsx} +9 -9
  34. package/dist/components/{text-input/text-input.jsx → TextInput/TextInput.jsx} +11 -11
  35. package/dist/components/{textarea/textarea.jsx → Textarea/Textarea.jsx} +7 -7
  36. package/dist/tsconfig.tsbuildinfo +1 -1
  37. package/package.json +1 -1
  38. package/src/common/{abstract-notification-banner.test.tsx → AbstractNotificationBanner.test.tsx} +11 -11
  39. package/src/common/{abstract-notification-banner.tsx → AbstractNotificationBanner.tsx} +2 -2
  40. package/src/common/{conditional-wrapper.test.tsx → ConditionalWrapper.test.tsx} +1 -1
  41. package/src/common/{file-icon.test.tsx → FileIcon.test.tsx} +10 -10
  42. package/src/common/{hint-text.test.tsx → HintText.test.tsx} +12 -12
  43. package/src/common/{icon.test.tsx → Icon.test.tsx} +16 -16
  44. package/src/common/{screen-reader-text.test.tsx → ScreenReaderText.test.tsx} +5 -5
  45. package/src/common/{wrapper-tag.test.tsx → WrapperTag.test.tsx} +5 -5
  46. package/src/components/{accordion/accordion.test.tsx → Accordion/Accordion.test.tsx} +35 -35
  47. package/src/components/{accordion/accordion.tsx → Accordion/Accordion.tsx} +5 -5
  48. package/src/components/{aspect-box/aspect-box.test.tsx → AspectBox/AspectBox.test.tsx} +2 -2
  49. package/src/components/{back-to-top/back-to-top.test.tsx → BackToTop/BackToTop.test.tsx} +1 -1
  50. package/src/components/{back-to-top/back-to-top.tsx → BackToTop/BackToTop.tsx} +1 -1
  51. package/src/components/{breadcrumbs/breadcrumbs.test.tsx → Breadcrumbs/Breadcrumbs.test.tsx} +7 -7
  52. package/src/components/{button/button.test.tsx → Button/Button.test.tsx} +1 -1
  53. package/src/components/{button/button.tsx → Button/Button.tsx} +3 -3
  54. package/src/components/{checkbox/checkbox.test.tsx → Checkbox/Checkbox.test.tsx} +16 -16
  55. package/src/components/{checkbox/checkbox.tsx → Checkbox/Checkbox.tsx} +1 -1
  56. package/src/components/{confirmation-message/confirmation-message.test.tsx → ConfirmationMessage/ConfirmationMessage.test.tsx} +12 -14
  57. package/src/components/{confirmation-message/confirmation-message.tsx → ConfirmationMessage/ConfirmationMessage.tsx} +4 -4
  58. package/src/components/{contents-nav/contents-nav.test.tsx → ContentsNav/ContentsNav.test.tsx} +21 -28
  59. package/src/components/{contents-nav/contents-nav.tsx → ContentsNav/ContentsNav.tsx} +1 -1
  60. package/src/components/{cookie-banner/cookie-banner.test.tsx → CookieBanner/CookieBanner.test.tsx} +3 -3
  61. package/src/components/{cookie-banner/cookie-banner.tsx → CookieBanner/CookieBanner.tsx} +1 -1
  62. package/src/components/{date-picker/date-picker.test.tsx → DatePicker/DatePicker.test.tsx} +76 -66
  63. package/src/components/{date-picker/date-picker.tsx → DatePicker/DatePicker.tsx} +2 -2
  64. package/src/components/{details/details.test.tsx → Details/Details.test.tsx} +10 -10
  65. package/src/components/{error-message/error-message.test.tsx → ErrorMessage/ErrorMessage.test.tsx} +10 -10
  66. package/src/components/{error-summary/error-summary.test.tsx → ErrorSummary/ErrorSummary.test.tsx} +13 -14
  67. package/src/components/{error-summary/error-summary.tsx → ErrorSummary/ErrorSummary.tsx} +1 -1
  68. package/src/components/{file-download/file-download.test.tsx → FileDownload/FileDownload.test.tsx} +21 -21
  69. package/src/components/{file-download/file-download.tsx → FileDownload/FileDownload.tsx} +1 -1
  70. package/src/components/{hide-this-page/hide-this-page.test.tsx → HideThisPage/HideThisPage.test.tsx} +4 -4
  71. package/src/components/{hide-this-page/hide-this-page.tsx → HideThisPage/HideThisPage.tsx} +3 -3
  72. package/src/components/{inset-text/inset-text.test.tsx → InsetText/InsetText.test.tsx} +1 -1
  73. package/src/components/{notification-banner/notification-banner.test.tsx → NotificationBanner/NotificationBanner.test.tsx} +4 -4
  74. package/src/components/{notification-banner/notification-banner.tsx → NotificationBanner/NotificationBanner.tsx} +1 -1
  75. package/src/components/{notification-panel/notification-panel.test.tsx → NotificationPanel/NotificationPanel.test.tsx} +24 -23
  76. package/src/components/{notification-panel/notification-panel.tsx → NotificationPanel/NotificationPanel.tsx} +3 -3
  77. package/src/components/{page-header/page-header.test.tsx → PageHeader/PageHeader.test.tsx} +9 -9
  78. package/src/components/{page-metadata/page-metadata.test.tsx → PageMetadata/PageMetadata.test.tsx} +9 -9
  79. package/src/components/{pagination/pagination.test.tsx → Pagination/Pagination.test.tsx} +56 -56
  80. package/src/components/{pagination/pagination.tsx → Pagination/Pagination.tsx} +1 -1
  81. package/src/components/{phase-banner/phase-banner.test.tsx → PhaseBanner/PhaseBanner.test.tsx} +9 -9
  82. package/src/components/{phase-banner/phase-banner.tsx → PhaseBanner/PhaseBanner.tsx} +1 -1
  83. package/src/components/{question/question.test.tsx → Question/Question.test.tsx} +10 -10
  84. package/src/components/{question/question.tsx → Question/Question.tsx} +3 -3
  85. package/src/components/{radio-button/radio-button.test.tsx → RadioButton/RadioButton.test.tsx} +23 -23
  86. package/src/components/{radio-button/radio-button.tsx → RadioButton/RadioButton.tsx} +1 -1
  87. package/src/components/{select/select.test.tsx → Select/Select.test.tsx} +67 -64
  88. package/src/components/{select/select.tsx → Select/Select.tsx} +2 -2
  89. package/src/components/{sequential-navigation/sequential-navigation.test.tsx → SequentialNavigation/SequentialNavigation.test.tsx} +18 -18
  90. package/src/components/{side-navigation/side-navigation.test.tsx → SideNavigation/SideNavigation.test.tsx} +8 -8
  91. package/src/components/{site-header/site-header.test.tsx → SiteHeader/SiteHeader.test.tsx} +25 -25
  92. package/src/components/{site-header/site-header.tsx → SiteHeader/SiteHeader.tsx} +4 -4
  93. package/src/components/{site-navigation/site-navigation.test.tsx → SiteNavigation/SiteNavigation.test.tsx} +8 -8
  94. package/src/components/{site-search/site-search.test.tsx → SiteSearch/SiteSearch.test.tsx} +16 -16
  95. package/src/components/{site-search/site-search.tsx → SiteSearch/SiteSearch.tsx} +1 -1
  96. package/src/components/{skip-links/skip-links.test.tsx → SkipLinks/SkipLinks.test.tsx} +15 -15
  97. package/src/components/{summary-card/summary-card.test.tsx → SummaryCard/SummaryCard.test.tsx} +28 -28
  98. package/src/components/{summary-card/summary-card.tsx → SummaryCard/SummaryCard.tsx} +4 -4
  99. package/src/components/{summary-list/summary-list.test.tsx → SummaryList/SummaryList.test.tsx} +55 -56
  100. package/src/components/{summary-list/summary-list.tsx → SummaryList/SummaryList.tsx} +2 -2
  101. package/src/components/{table/table.test.tsx → Table/Table.test.tsx} +4 -4
  102. package/src/components/{tabs/tabs.test.tsx → Tabs/Tabs.test.tsx} +22 -42
  103. package/src/components/{tabs/tabs.tsx → Tabs/Tabs.tsx} +3 -3
  104. package/src/components/{tag/tag.test.tsx → Tag/Tag.test.tsx} +10 -10
  105. package/src/components/{task-list/task-list.test.tsx → TaskList/TaskList.test.tsx} +109 -108
  106. package/src/components/{task-list/task-list.tsx → TaskList/TaskList.tsx} +4 -4
  107. package/src/components/{text-input/text-input.test.tsx → TextInput/TextInput.test.tsx} +92 -87
  108. package/src/components/{text-input/text-input.tsx → TextInput/TextInput.tsx} +4 -4
  109. package/src/components/{textarea/textarea.test.tsx → Textarea/Textarea.test.tsx} +71 -67
  110. package/src/components/{textarea/textarea.tsx → Textarea/Textarea.tsx} +3 -3
  111. package/src/components/{warning-text/warning-text.test.tsx → WarningText/WarningText.test.tsx} +1 -1
  112. package/dist/icons/ArrowUpward.jsx +0 -41
  113. package/dist/icons/CalendarToday.jsx +0 -41
  114. package/dist/icons/Cancel.jsx +0 -40
  115. package/dist/icons/CheckCircle.jsx +0 -41
  116. package/dist/icons/ChevronLeft.jsx +0 -41
  117. package/dist/icons/ChevronRight.jsx +0 -41
  118. package/dist/icons/Close.jsx +0 -41
  119. package/dist/icons/Description.jsx +0 -41
  120. package/dist/icons/DoubleChevronLeft.jsx +0 -40
  121. package/dist/icons/DoubleChevronRight.jsx +0 -40
  122. package/dist/icons/Error.jsx +0 -41
  123. package/dist/icons/ExpandLess.jsx +0 -41
  124. package/dist/icons/ExpandMore.jsx +0 -41
  125. package/dist/icons/List.jsx +0 -44
  126. package/dist/icons/Menu.jsx +0 -41
  127. package/dist/icons/PriorityHigh.jsx +0 -42
  128. package/dist/icons/Search.jsx +0 -41
  129. package/dist/icons/index.js +0 -40
  130. /package/dist/common/{conditional-wrapper.jsx → ConditionalWrapper.jsx} +0 -0
  131. /package/dist/common/{file-icon.jsx → FileIcon.jsx} +0 -0
  132. /package/dist/common/{hint-text.jsx → HintText.jsx} +0 -0
  133. /package/dist/common/{icon.jsx → Icon.jsx} +0 -0
  134. /package/dist/common/{screen-reader-text.jsx → ScreenReaderText.jsx} +0 -0
  135. /package/dist/common/{wrapper-tag.jsx → WrapperTag.jsx} +0 -0
  136. /package/dist/components/{aspect-box/aspect-box.jsx → AspectBox/AspectBox.jsx} +0 -0
  137. /package/dist/components/{breadcrumbs/breadcrumbs.jsx → Breadcrumbs/Breadcrumbs.jsx} +0 -0
  138. /package/dist/components/{details/details.jsx → Details/Details.jsx} +0 -0
  139. /package/dist/components/{error-message/error-message.jsx → ErrorMessage/ErrorMessage.jsx} +0 -0
  140. /package/dist/components/{inset-text/inset-text.jsx → InsetText/InsetText.jsx} +0 -0
  141. /package/dist/components/{page-header/page-header.jsx → PageHeader/PageHeader.jsx} +0 -0
  142. /package/dist/components/{page-metadata/page-metadata.jsx → PageMetadata/PageMetadata.jsx} +0 -0
  143. /package/dist/components/{sequential-navigation/sequential-navigation.jsx → SequentialNavigation/SequentialNavigation.jsx} +0 -0
  144. /package/dist/components/{side-navigation/side-navigation.jsx → SideNavigation/SideNavigation.jsx} +0 -0
  145. /package/dist/components/{site-navigation/site-navigation.jsx → SiteNavigation/SiteNavigation.jsx} +0 -0
  146. /package/dist/components/{skip-links/skip-links.jsx → SkipLinks/SkipLinks.jsx} +0 -0
  147. /package/dist/components/{table/table.jsx → Table/Table.jsx} +0 -0
  148. /package/dist/components/{tag/tag.jsx → Tag/Tag.jsx} +0 -0
  149. /package/dist/components/{warning-text/warning-text.jsx → WarningText/WarningText.jsx} +0 -0
  150. /package/src/common/{conditional-wrapper.tsx → ConditionalWrapper.tsx} +0 -0
  151. /package/src/common/{file-icon.tsx → FileIcon.tsx} +0 -0
  152. /package/src/common/{hint-text.tsx → HintText.tsx} +0 -0
  153. /package/src/common/{icon.tsx → Icon.tsx} +0 -0
  154. /package/src/common/{screen-reader-text.tsx → ScreenReaderText.tsx} +0 -0
  155. /package/src/common/{wrapper-tag.tsx → WrapperTag.tsx} +0 -0
  156. /package/src/components/{aspect-box/aspect-box.tsx → AspectBox/AspectBox.tsx} +0 -0
  157. /package/src/components/{breadcrumbs/breadcrumbs.tsx → Breadcrumbs/Breadcrumbs.tsx} +0 -0
  158. /package/src/components/{details/details.tsx → Details/Details.tsx} +0 -0
  159. /package/src/components/{error-message/error-message.tsx → ErrorMessage/ErrorMessage.tsx} +0 -0
  160. /package/src/components/{inset-text/inset-text.tsx → InsetText/InsetText.tsx} +0 -0
  161. /package/src/components/{page-header/page-header.tsx → PageHeader/PageHeader.tsx} +0 -0
  162. /package/src/components/{page-metadata/page-metadata.tsx → PageMetadata/PageMetadata.tsx} +0 -0
  163. /package/src/components/{sequential-navigation/sequential-navigation.tsx → SequentialNavigation/SequentialNavigation.tsx} +0 -0
  164. /package/src/components/{side-navigation/side-navigation.tsx → SideNavigation/SideNavigation.tsx} +0 -0
  165. /package/src/components/{site-navigation/site-navigation.tsx → SiteNavigation/SiteNavigation.tsx} +0 -0
  166. /package/src/components/{skip-links/skip-links.tsx → SkipLinks/SkipLinks.tsx} +0 -0
  167. /package/src/components/{table/table.tsx → Table/Table.tsx} +0 -0
  168. /package/src/components/{tag/tag.tsx → Tag/Tag.tsx} +0 -0
  169. /package/src/components/{warning-text/warning-text.tsx → WarningText/WarningText.tsx} +0 -0
@@ -1,8 +1,8 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen, within } from '@testing-library/react';
3
- import Breadcrumbs from './breadcrumbs';
3
+ import Breadcrumbs from './Breadcrumbs';
4
4
 
5
- const items = [
5
+ const ITEMS = [
6
6
  { href: 'home', title: 'Home' },
7
7
  { href: 'category', title: 'Category' },
8
8
  { title: 'Page' }
@@ -10,7 +10,7 @@ const items = [
10
10
 
11
11
  test('renders correctly', () => {
12
12
  render(
13
- <Breadcrumbs items={items} />
13
+ <Breadcrumbs items={ITEMS} />
14
14
  );
15
15
 
16
16
  const nav = screen.getByRole('navigation');
@@ -25,7 +25,7 @@ test('renders correctly', () => {
25
25
  expect(list).toHaveClass('ds_breadcrumbs');
26
26
 
27
27
  // check items
28
- expect(listItems.length).toEqual(items.length);
28
+ expect(listItems.length).toEqual(ITEMS.length);
29
29
 
30
30
  listItems.forEach((item, index) => {
31
31
  expect(item).toHaveClass('ds_breadcrumbs__item');
@@ -49,7 +49,7 @@ test('renders with last item hidden', () => {
49
49
  render(
50
50
  <Breadcrumbs
51
51
  hideLastItem
52
- items={items}
52
+ items={ITEMS}
53
53
  />
54
54
  );
55
55
 
@@ -67,7 +67,7 @@ test('renders with last item hidden', () => {
67
67
  test('passing additional props', () => {
68
68
  render(
69
69
  <Breadcrumbs
70
- items={items}
70
+ items={ITEMS}
71
71
  data-test="foo"
72
72
  />
73
73
  );
@@ -79,7 +79,7 @@ test('passing additional props', () => {
79
79
  test('passing additional CSS classes', () => {
80
80
  render(
81
81
  <Breadcrumbs
82
- items={items}
82
+ items={ITEMS}
83
83
  className="foo"
84
84
  />
85
85
  );
@@ -1,6 +1,6 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen, within } from '@testing-library/react';
3
- import Button from './button';
3
+ import Button from './Button';
4
4
 
5
5
  test('renders correctly', () => {
6
6
  render(
@@ -1,6 +1,6 @@
1
- import Icon from '../../common/icon';
2
- import ScreenReaderText from '../../common/screen-reader-text';
3
- import WrapperTag from '../../common/wrapper-tag';
1
+ import Icon from '../../common/Icon';
2
+ import ScreenReaderText from '../../common/ScreenReaderText';
3
+ import WrapperTag from '../../common/WrapperTag';
4
4
 
5
5
  const Button: React.FC<SGDS.Component.Button> = ({
6
6
  buttonStyle,
@@ -1,9 +1,9 @@
1
1
  import { test, expect, vi } from 'vitest';
2
2
  import { render, screen, fireEvent } from '@testing-library/react';
3
- import CheckboxGroup, { Checkbox } from './checkbox';
3
+ import CheckboxGroup, { Checkbox } from './Checkbox';
4
4
 
5
5
  test('checkbox group renders correct children', () => {
6
- const items = [
6
+ const ITEMS = [
7
7
  {
8
8
  id: 'universal-credit',
9
9
  label: 'Universal Credit',
@@ -25,18 +25,18 @@ test('checkbox group renders correct children', () => {
25
25
  ];
26
26
 
27
27
  render(
28
- <CheckboxGroup items={items} />
28
+ <CheckboxGroup items={ITEMS} />
29
29
  );
30
30
 
31
31
  const checkboxes = screen.getAllByRole('checkbox');
32
32
  const groupContainer = checkboxes[0].parentElement?.parentElement;
33
- expect(checkboxes.length).toEqual(items.length);
33
+ expect(checkboxes.length).toEqual(ITEMS.length);
34
34
  expect(groupContainer).toHaveClass('ds_checkboxes', 'ds_field-group');
35
35
  });
36
36
 
37
37
  test('checkbox group passes all expected item params', () => {
38
- const onBlurFn = vi.fn();
39
- const onChangeFn = vi.fn();
38
+ const ONBLUR_FUNCTION = vi.fn();
39
+ const ONCHANGE_FUNCTION = vi.fn();
40
40
 
41
41
  render(
42
42
  <CheckboxGroup small items={[
@@ -46,8 +46,8 @@ test('checkbox group passes all expected item params', () => {
46
46
  hintText: 'hint text',
47
47
  id: 'myid',
48
48
  label: 'label text',
49
- onBlur: {onBlurFn},
50
- onChange: {onChangeFn},
49
+ onBlur: {ONBLUR_FUNCTION},
50
+ onChange: {ONCHANGE_FUNCTION},
51
51
  small: true
52
52
  }
53
53
  ]}/>
@@ -65,10 +65,10 @@ test('checkbox group passes all expected item params', () => {
65
65
  expect(checkbox).toHaveAttribute('aria-describedby', hintText.id);
66
66
 
67
67
  // fireEvent.blur(checkbox);
68
- // expect(onBlurFn).toHaveBeenCalled();
68
+ // expect(ONBLUR_FUNCTION).toHaveBeenCalled();
69
69
 
70
70
  // fireEvent.click(checkbox);
71
- // expect(onChangeFn).toHaveBeenCalled();
71
+ // expect(ONCHANGE_FUNCTION).toHaveBeenCalled();
72
72
  });
73
73
 
74
74
  test('individual checkbox renders correctly', () => {
@@ -116,31 +116,31 @@ test('exclusive checkbox', () => {
116
116
  });
117
117
 
118
118
  test('checkbox with blur fn', () => {
119
- const onBlurFn = vi.fn();
119
+ const ONBLUR_FUNCTION = vi.fn();
120
120
 
121
121
  render(
122
- <Checkbox onBlur={onBlurFn} label="Pension Credit" id="pensioncredit" />
122
+ <Checkbox onBlur={ONBLUR_FUNCTION} label="Pension Credit" id="pensioncredit" />
123
123
  );
124
124
 
125
125
  const checkbox = screen.getByRole('checkbox');
126
126
 
127
127
  fireEvent.blur(checkbox);
128
128
 
129
- expect(onBlurFn).toHaveBeenCalled();
129
+ expect(ONBLUR_FUNCTION).toHaveBeenCalled();
130
130
  });
131
131
 
132
132
  test('checkbox with change fn', () => {
133
- const onChangeFn = vi.fn();
133
+ const ONCHANGE_FUNCTION = vi.fn();
134
134
 
135
135
  render(
136
- <Checkbox onChange={onChangeFn} label="Pension Credit" id="pensioncredit" />
136
+ <Checkbox onChange={ONCHANGE_FUNCTION} label="Pension Credit" id="pensioncredit" />
137
137
  );
138
138
 
139
139
  const checkbox = screen.getByRole('checkbox');
140
140
 
141
141
  fireEvent.click(checkbox);
142
142
 
143
- expect(onChangeFn).toHaveBeenCalled();
143
+ expect(ONCHANGE_FUNCTION).toHaveBeenCalled();
144
144
  });
145
145
 
146
146
  test('checkbox with hint text', () => {
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useRef } from 'react';
2
2
  // @ts-ignore
3
3
  import DSCheckboxes from '@scottish-government/design-system/src/forms/checkbox/checkboxes'
4
- import HintText from '../../common/hint-text';
4
+ import HintText from '../../common/HintText';
5
5
 
6
6
  export const Checkbox: React.FC<SGDS.Component.Checkbox> = ({
7
7
  checked,
@@ -1,27 +1,27 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen } from '@testing-library/react';
3
- import ConfirmationMessage from './confirmation-message';
3
+ import ConfirmationMessage from './ConfirmationMessage';
4
4
 
5
- const titleString = 'Landlord added successfully';
5
+ const TITLE_TEXT = 'Landlord added successfully';
6
6
 
7
7
  test('renders correctly with icon, title and message', () => {
8
8
  render(
9
- <ConfirmationMessage title={titleString}>
9
+ <ConfirmationMessage title={TITLE_TEXT}>
10
10
  <p>You have added the landlord <strong>John Smith</strong> to the application.</p>
11
11
  </ConfirmationMessage>
12
12
  );
13
13
 
14
14
  const container = document.querySelector('.ds_confirmation-message');
15
- const header = screen.getByRole('heading');
15
+ const heading = screen.getByRole('heading');
16
16
 
17
17
  expect(container?.ariaLive).toEqual('polite');
18
18
 
19
- expect(header.tagName).toEqual('H3');
20
- expect(header.textContent).toEqual(titleString)
19
+ expect(heading.tagName).toEqual('H3');
20
+ expect(heading.textContent).toEqual(TITLE_TEXT)
21
21
  });
22
22
 
23
23
  test("does not render body when no children specified", () => {
24
- const { container } = render(<ConfirmationMessage title={titleString} />);
24
+ const { container } = render(<ConfirmationMessage title={TITLE_TEXT} />);
25
25
 
26
26
  expect(
27
27
  container.querySelector(".ds_confirmation-message__body"),
@@ -29,25 +29,23 @@ test("does not render body when no children specified", () => {
29
29
  });
30
30
 
31
31
  test('renders confirmation message with custom aria live and custom heaer level', () => {
32
- const titleString = 'Landlord added successfully';
33
-
34
32
  render(
35
- <ConfirmationMessage headerLevel="h2" ariaLive="alert" title={titleString}>
33
+ <ConfirmationMessage headingLevel="h2" ariaLive="alert" title={TITLE_TEXT}>
36
34
  <p>You have added the landlord <strong>John Smith</strong> to the application.</p>
37
35
  </ConfirmationMessage>
38
36
  );
39
37
 
40
38
  const container = document.querySelector('.ds_confirmation-message');
41
- const header = screen.getByRole('heading');
39
+ const heading = screen.getByRole('heading');
42
40
 
43
41
  expect(container?.ariaLive).toEqual('alert');
44
42
 
45
- expect(header.tagName).toEqual('H2');
43
+ expect(heading.tagName).toEqual('H2');
46
44
  });
47
45
 
48
46
  test('passing additional props', () => {
49
47
  render(
50
- <ConfirmationMessage data-test="foo" title={titleString}>
48
+ <ConfirmationMessage data-test="foo" title={TITLE_TEXT}>
51
49
  <p>You have added the landlord <strong>John Smith</strong> to the application.</p>
52
50
  </ConfirmationMessage>
53
51
  );
@@ -58,7 +56,7 @@ test('passing additional props', () => {
58
56
 
59
57
  test('passing additional CSS classes', () => {
60
58
  render(
61
- <ConfirmationMessage className="foo" title={titleString}>
59
+ <ConfirmationMessage className="foo" title={TITLE_TEXT}>
62
60
  <p>You have added the landlord <strong>John Smith</strong> to the application.</p>
63
61
  </ConfirmationMessage>
64
62
  );
@@ -1,11 +1,11 @@
1
- import Icon from '../../common/icon';
2
- import WrapperTag from '../../common/wrapper-tag';
1
+ import Icon from '../../common/Icon';
2
+ import WrapperTag from '../../common/WrapperTag';
3
3
 
4
4
  const ConfirmationMessage: React.FC<SGDS.Component.ConfirmationMessage> = ({
5
5
  ariaLive = 'polite',
6
6
  children,
7
7
  className,
8
- headerLevel = 'h3',
8
+ headingLevel = 'h3',
9
9
  title,
10
10
  ...props
11
11
  }) => {
@@ -22,7 +22,7 @@ const ConfirmationMessage: React.FC<SGDS.Component.ConfirmationMessage> = ({
22
22
 
23
23
  <WrapperTag
24
24
  className="ds_confirmation-message__title"
25
- tagName={headerLevel}
25
+ tagName={headingLevel}
26
26
  >
27
27
  {title}
28
28
  </WrapperTag>
@@ -1,9 +1,12 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen, within } from '@testing-library/react';
3
- import ContentsNav, {Link} from './contents-nav';
3
+ import ContentsNav, {Link} from './ContentsNav';
4
+
5
+ const ITEM_HREF = '#foo';
6
+ const ITEM_TITLE = 'My content';
4
7
 
5
8
  test('contents nav renders correctly', () => {
6
- const items = [
9
+ const ITEMS = [
7
10
  {
8
11
  title: 'Apply for Blue Badge',
9
12
  current: true
@@ -26,10 +29,10 @@ test('contents nav renders correctly', () => {
26
29
  }
27
30
  ];
28
31
 
29
- const label = 'Pages in this guide';
32
+ const LABEL_TEXT = 'Pages in this guide';
30
33
 
31
34
  render(
32
- <ContentsNav label={label} items={items} />
35
+ <ContentsNav label={LABEL_TEXT} items={ITEMS} />
33
36
  )
34
37
 
35
38
  const contentsNav = screen.getByRole('navigation');
@@ -37,33 +40,30 @@ test('contents nav renders correctly', () => {
37
40
  const contentsNavList = within(contentsNav).getByRole('list');
38
41
 
39
42
  expect(contentsNav).toHaveClass('ds_contents-nav');
40
- expect(contentsNav.ariaLabel).toEqual(label);
43
+ expect(contentsNav.ariaLabel).toEqual(LABEL_TEXT);
41
44
  expect(contentsNav.tagName).toEqual('NAV');
42
45
  expect(contentsNavTitle).toHaveClass('ds_contents-nav__title');
43
46
  expect(contentsNavTitle.textContent).toEqual('Contents');
44
47
  expect(contentsNavList).toHaveClass('ds_contents-nav__list');
45
48
  expect(contentsNavList.tagName).toEqual('UL');
46
- expect(contentsNavList.children.length).toEqual(items.length);
49
+ expect(contentsNavList.children.length).toEqual(ITEMS.length);
47
50
  });
48
51
 
49
52
  test('contents nav with custom title', () => {
50
- const title = 'My title';
53
+ const TITLE_TEXT = 'My title';
51
54
 
52
55
  render(
53
- <ContentsNav title={title} items={[]} />
56
+ <ContentsNav title={TITLE_TEXT} items={[]} />
54
57
  );
55
58
 
56
59
  const contentsNav = screen.getByRole('navigation');
57
60
  const contentsNavTitle = within(contentsNav).getByRole('heading');
58
- expect(contentsNavTitle.textContent).toEqual(title);
61
+ expect(contentsNavTitle.textContent).toEqual(TITLE_TEXT);
59
62
  });
60
63
 
61
64
  test('contents nav item', () => {
62
- const href = '#foo';
63
- const content = 'My content';
64
-
65
65
  render(
66
- <Link href={href} title={content} />
66
+ <Link href={ITEM_HREF} title={ITEM_TITLE} />
67
67
  );
68
68
 
69
69
  const listItem = screen.getByRole('listitem');
@@ -73,20 +73,17 @@ test('contents nav item', () => {
73
73
  expect(listItem.tagName).toEqual('LI');
74
74
  expect(link).toHaveClass('ds_contents-nav__link');
75
75
  expect(link.tagName).toEqual('A');
76
- expect(link.textContent).toEqual(content);
77
- expect(link).toHaveAttribute('href', href);
76
+ expect(link.textContent).toEqual(ITEM_TITLE);
77
+ expect(link).toHaveAttribute('href', ITEM_HREF);
78
78
  });
79
79
 
80
80
  test('contents nav current item with href', () => {
81
- const href = '#foo';
82
- const content = 'My content';
83
-
84
81
  render(
85
- <Link current href={href} title={content} />
82
+ <Link current href={ITEM_HREF} title={ITEM_TITLE} />
86
83
  );
87
84
 
88
85
  const listItem = screen.getByRole('listitem');
89
- const link = within(listItem).getByText(content);
86
+ const link = within(listItem).getByText(ITEM_TITLE);
90
87
 
91
88
  expect(listItem.ariaCurrent).toEqual('page');
92
89
  expect(link.tagName).toEqual('SPAN');
@@ -94,14 +91,12 @@ test('contents nav current item with href', () => {
94
91
  });
95
92
 
96
93
  test('contents nav current item without href', () => {
97
- const content = 'My content';
98
-
99
94
  render(
100
- <Link current title={content} />
95
+ <Link current title={ITEM_TITLE} />
101
96
  );
102
97
 
103
98
  const listItem = screen.getByRole('listitem');
104
- const link = within(listItem).getByText(content);
99
+ const link = within(listItem).getByText(ITEM_TITLE);
105
100
 
106
101
  expect(listItem.ariaCurrent).toEqual('page');
107
102
  expect(link.tagName).toEqual('SPAN');
@@ -109,14 +104,12 @@ test('contents nav current item without href', () => {
109
104
  });
110
105
 
111
106
  test('contents nav item without href', () => {
112
- const content = 'My content';
113
-
114
107
  render(
115
- <Link title={content} />
108
+ <Link title={ITEM_TITLE} />
116
109
  );
117
110
 
118
111
  const listItem = screen.getByRole('listitem');
119
- const link = within(listItem).getByText(content);
112
+ const link = within(listItem).getByText(ITEM_TITLE);
120
113
 
121
114
  expect(link.tagName).toEqual('SPAN');
122
115
  expect(link).not.toHaveClass('ds_current');
@@ -1,4 +1,4 @@
1
- import WrapperTag from '../../common/wrapper-tag';
1
+ import WrapperTag from '../../common/WrapperTag';
2
2
 
3
3
  export const Link: React.FC<SGDS.Component.ContentsNav.Link> = ({
4
4
  current,
@@ -5,9 +5,9 @@
5
5
 
6
6
  import { test, expect } from 'vitest';
7
7
  import { render } from '@testing-library/react';
8
- import CookieBanner from './cookie-banner';
8
+ import CookieBanner from './CookieBanner';
9
9
 
10
- const text = 'We need to tell you about something';
10
+ const BANNER_TEXT = 'We need to tell you about something';
11
11
 
12
12
  /**
13
13
  * CookieBanner has additional classNames
@@ -15,7 +15,7 @@ const text = 'We need to tell you about something';
15
15
  test('cookie banner renders correctly', () => {
16
16
  render(
17
17
  <CookieBanner>
18
- {text}
18
+ {BANNER_TEXT}
19
19
  </CookieBanner>
20
20
  );
21
21
 
@@ -1,5 +1,5 @@
1
1
 
2
- import AbstractNotificationBanner from '../../common/abstract-notification-banner';
2
+ import AbstractNotificationBanner from '../../common/AbstractNotificationBanner';
3
3
  // @ts-ignore
4
4
  import DSCookieBanner from '@scottish-government/design-system/src/components/cookie-notification/cookie-notification.js';
5
5