@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,6 +1,6 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen, within } from '@testing-library/react';
3
- import Question from './question';
3
+ import Question from './Question';
4
4
 
5
5
  test('question renders correctly (basic q, just a wrapper, invalid example)', () => {
6
6
  render(
@@ -14,39 +14,39 @@ test('question renders correctly (basic q, just a wrapper, invalid example)', ()
14
14
  });
15
15
 
16
16
  test('fieldset question with legend', () => {
17
- const legendText = 'My legend';
17
+ const LEGEND_TEXT = 'My legend';
18
18
 
19
19
  render(
20
- <Question tagName="fieldset" legend={legendText}>
20
+ <Question tagName="fieldset" legend={LEGEND_TEXT}>
21
21
  </Question>
22
22
  );
23
23
 
24
24
  const questionElement = screen.getByRole('group');
25
- const legendElement = within(questionElement).getByText(legendText);
25
+ const legendElement = within(questionElement).getByText(LEGEND_TEXT);
26
26
  expect(questionElement?.tagName).toEqual('FIELDSET');
27
27
  expect(legendElement.tagName).toEqual('LEGEND');
28
28
  });
29
29
 
30
30
  test('question with hint text', () => {
31
- const hintText = 'My hint text';
31
+ const HINT_TEXT = 'My hint text';
32
32
 
33
33
  render(
34
- <Question hintText={hintText}>
34
+ <Question hintText={HINT_TEXT}>
35
35
  </Question>
36
36
  );
37
37
 
38
38
  const hintTextElement = screen.getByRole('paragraph');
39
39
  const firstQuestionChild = document.querySelector('.ds_question')?.childNodes[0]
40
40
  expect(hintTextElement).toHaveClass('ds_hint-text');
41
- expect(hintTextElement.textContent).toEqual(hintText);
41
+ expect(hintTextElement.textContent).toEqual(HINT_TEXT);
42
42
  expect(hintTextElement).toBe(firstQuestionChild);
43
43
  });
44
44
 
45
45
  test('question with error', () => {
46
- const errorMessage = 'My error message';
46
+ const ERROR_MESSAGE_TEXT = 'My error message';
47
47
 
48
48
  render(
49
- <Question error errorMessage={errorMessage}>
49
+ <Question error errorMessage={ERROR_MESSAGE_TEXT}>
50
50
  </Question>
51
51
  );
52
52
 
@@ -55,7 +55,7 @@ test('question with error', () => {
55
55
 
56
56
  expect(questionElement).toHaveClass('ds_question--error');
57
57
  expect(errorMessageElement).toBeInTheDocument();
58
- expect(errorMessageElement?.textContent).toEqual(errorMessage);
58
+ expect(errorMessageElement?.textContent).toEqual(ERROR_MESSAGE_TEXT);
59
59
  });
60
60
 
61
61
  test('passing additional props', () => {
@@ -1,6 +1,6 @@
1
- import ErrorMessage from '../error-message/error-message';
2
- import HintText from '../../common/hint-text';
3
- import WrapperTag from '../../common/wrapper-tag';
1
+ import ErrorMessage from '../ErrorMessage/ErrorMessage';
2
+ import HintText from '../../common/HintText';
3
+ import WrapperTag from '../../common/WrapperTag';
4
4
 
5
5
  const Question: React.FC<SGDS.Component.Question> = function ({
6
6
  children,
@@ -1,9 +1,9 @@
1
1
  import { test, expect, vi } from 'vitest';
2
2
  import { render, screen, fireEvent } from '@testing-library/react';
3
- import RadioGroup, { Radio } from './radio-button';
3
+ import RadioGroup, { Radio } from './RadioButton';
4
4
 
5
5
  test('radio group renders correct children', () => {
6
- const items = [
6
+ const ITEMS = [
7
7
  {
8
8
  id: 'universal-credit',
9
9
  label: 'Universal Credit',
@@ -22,20 +22,20 @@ test('radio group renders correct children', () => {
22
22
  label: 'I do not receive any of these benefits',
23
23
  }
24
24
  ];
25
- const groupName = "foo"
25
+ const GROUP_NAME = "foo"
26
26
 
27
27
  render(
28
- <RadioGroup name={groupName} items={items} />
28
+ <RadioGroup name={GROUP_NAME} items={ITEMS} />
29
29
  );
30
30
 
31
31
  const radios = screen.getAllByRole('radio');
32
32
  const groupContainer = radios[0].parentElement?.parentElement;
33
- expect(radios.length).toEqual(items.length);
33
+ expect(radios.length).toEqual(ITEMS.length);
34
34
  expect(groupContainer).toHaveClass('ds_radios', 'ds_field-group');
35
35
  });
36
36
 
37
37
  test('inline radio group', () => {
38
- const items = [
38
+ const ITEMS = [
39
39
  {
40
40
  id: 'radio-yes',
41
41
  label: 'Yes'
@@ -45,10 +45,10 @@ test('inline radio group', () => {
45
45
  label: 'No'
46
46
  }
47
47
  ];
48
- const groupName = "yesno"
48
+ const GROUP_NAME = "yesno"
49
49
 
50
50
  render(
51
- <RadioGroup inline name={groupName} items={items} />
51
+ <RadioGroup inline name={GROUP_NAME} items={ITEMS} />
52
52
  );
53
53
 
54
54
 
@@ -58,20 +58,20 @@ test('inline radio group', () => {
58
58
  });
59
59
 
60
60
  test('radio group passes all expected item params', () => {
61
- const onBlurFn = vi.fn();
62
- const onChangeFn = vi.fn();
63
- const groupName = "foo"
61
+ const ONBLUR_FUNCTION = vi.fn();
62
+ const ONCHANGE_FUNCTION = vi.fn();
63
+ const GROUP_NAME = "foo"
64
64
 
65
65
  render(
66
- <RadioGroup name={groupName} small items={[
66
+ <RadioGroup name={GROUP_NAME} small items={[
67
67
  {
68
68
  checked: true,
69
69
  exclusive: true,
70
70
  hintText: 'hint text',
71
71
  id: 'myid',
72
72
  label: 'label text',
73
- onBlur: {onBlurFn},
74
- onChange: {onChangeFn},
73
+ onBlur: {ONBLUR_FUNCTION},
74
+ onChange: {ONCHANGE_FUNCTION},
75
75
  small: true
76
76
  }
77
77
  ]}/>
@@ -82,17 +82,17 @@ test('radio group passes all expected item params', () => {
82
82
  const hintText = screen.getByText('hint text');
83
83
 
84
84
  expect(radio).toHaveAttribute('checked');
85
- expect(radio).toHaveAttribute('name', groupName);
85
+ expect(radio).toHaveAttribute('name', GROUP_NAME);
86
86
  expect(radio.id).toEqual('myid');
87
87
  expect(radioContainer).toHaveClass('ds_radio--small');
88
88
  expect(hintText).toBeInTheDocument();
89
89
  expect(radio).toHaveAttribute('aria-describedby', hintText.id);
90
90
 
91
91
  // fireEvent.blur(radio);
92
- // expect(onBlurFn).toHaveBeenCalled();
92
+ // expect(ONBLUR_FUNCTION).toHaveBeenCalled();
93
93
 
94
94
  // fireEvent.click(radio);
95
- // expect(onChangeFn).toHaveBeenCalled();
95
+ // expect(ONCHANGE_FUNCTION).toHaveBeenCalled();
96
96
  });
97
97
 
98
98
  test('individual radio renders correctly', () => {
@@ -126,31 +126,31 @@ test('checked radio', () => {
126
126
  });
127
127
 
128
128
  test('radio with blur fn', () => {
129
- const onBlurFn = vi.fn();
129
+ const ONBLUR_FUNCTION = vi.fn();
130
130
 
131
131
  render(
132
- <Radio onBlur={onBlurFn} name="benefitType" label="Pension Credit" id="pensioncredit" />
132
+ <Radio onBlur={ONBLUR_FUNCTION} name="benefitType" label="Pension Credit" id="pensioncredit" />
133
133
  );
134
134
 
135
135
  const radio = screen.getByRole('radio');
136
136
 
137
137
  fireEvent.blur(radio);
138
138
 
139
- expect(onBlurFn).toHaveBeenCalled();
139
+ expect(ONBLUR_FUNCTION).toHaveBeenCalled();
140
140
  });
141
141
 
142
142
  test('radio with change fn', () => {
143
- const onChangeFn = vi.fn();
143
+ const ONCHANGE_FUNCTION = vi.fn();
144
144
 
145
145
  render(
146
- <Radio onChange={onChangeFn} name="benefitType" label="Pension Credit" id="pensioncredit" />
146
+ <Radio onChange={ONCHANGE_FUNCTION} name="benefitType" label="Pension Credit" id="pensioncredit" />
147
147
  );
148
148
 
149
149
  const radio = screen.getByRole('radio');
150
150
 
151
151
  fireEvent.click(radio);
152
152
 
153
- expect(onChangeFn).toHaveBeenCalled();
153
+ expect(ONCHANGE_FUNCTION).toHaveBeenCalled();
154
154
  });
155
155
 
156
156
  test('radio with hint text', () => {
@@ -1,4 +1,4 @@
1
- import HintText from '../../common/hint-text';
1
+ import HintText from '../../common/HintText';
2
2
 
3
3
  export const Radio: React.FC<SGDS.Component.RadioButton> = ({
4
4
  checked,
@@ -1,10 +1,10 @@
1
1
  import { test, expect, vi } from 'vitest';
2
2
  import { render, screen, fireEvent } from '@testing-library/react';
3
- import Select from './select';
3
+ import Select from './Select';
4
4
 
5
- const id = 'select-component';
6
- const labelText = 'choose a component';
7
- const options = [
5
+ const SELECT_ID = 'select-component';
6
+ const LABEL_TEXT = 'choose a component';
7
+ const OPTIONS = [
8
8
  {
9
9
  text: 'Accordion',
10
10
  value: 'accordion'
@@ -22,9 +22,9 @@ const options = [
22
22
  test('select renders correctly', () => {
23
23
  render(
24
24
  <Select
25
- id={id}
26
- label={labelText}
27
- options={options}
25
+ id={SELECT_ID}
26
+ label={LABEL_TEXT}
27
+ options={OPTIONS}
28
28
  />
29
29
  );
30
30
 
@@ -34,14 +34,14 @@ test('select renders correctly', () => {
34
34
  const selectArrow = select.nextElementSibling;
35
35
 
36
36
  expect(select).toHaveClass('ds_select');
37
- expect(select.id).toEqual(id);
38
- expect(select).toHaveAttribute('name', id);
37
+ expect(select.id).toEqual(SELECT_ID);
38
+ expect(select).toHaveAttribute('name', SELECT_ID);
39
39
 
40
40
  expect(selectWrapper).toHaveClass('ds_select-wrapper');
41
41
  expect(selectWrapper?.tagName).toEqual('DIV');
42
42
 
43
43
  expect(label).toHaveClass('ds_label');
44
- expect(label).toHaveAttribute('for', id);
44
+ expect(label).toHaveAttribute('for', SELECT_ID);
45
45
 
46
46
  expect(selectArrow).toHaveClass('ds_select-arrow');
47
47
  expect(selectArrow).toHaveAttribute('aria-hidden');
@@ -49,34 +49,34 @@ test('select renders correctly', () => {
49
49
  });
50
50
 
51
51
  test('select with width', () => {
52
- const width = 'fixed-10';
52
+ const SELECTWIDTH = 'fixed-10';
53
53
 
54
54
  render(
55
55
  <Select
56
- id={id}
57
- label={labelText}
58
- options={options}
59
- width={width}
56
+ id={SELECT_ID}
57
+ label={LABEL_TEXT}
58
+ options={OPTIONS}
59
+ width={SELECTWIDTH}
60
60
  />
61
61
  );
62
62
 
63
63
  const selectWrapper = screen.getByRole('combobox').parentElement;
64
- expect(selectWrapper).toHaveClass(`ds_input--${width}`);
64
+ expect(selectWrapper).toHaveClass(`ds_input--${SELECTWIDTH}`);
65
65
  });
66
66
 
67
67
  test('select with hint text', () => {
68
- const hintText = 'hint text';
68
+ const HINT_TEXT = 'hint text';
69
69
 
70
70
  render(
71
71
  <Select
72
- id={id}
73
- label={labelText}
74
- options={options}
75
- hintText={hintText}
72
+ id={SELECT_ID}
73
+ label={LABEL_TEXT}
74
+ options={OPTIONS}
75
+ hintText={HINT_TEXT}
76
76
  />
77
77
  );
78
78
 
79
- const hintTextEl = screen.getByText(hintText);
79
+ const hintTextEl = screen.getByText(HINT_TEXT);
80
80
  const select = screen.getByRole('combobox');
81
81
 
82
82
  expect(hintTextEl).toBeInTheDocument();
@@ -84,29 +84,30 @@ test('select with hint text', () => {
84
84
  });
85
85
 
86
86
  test('select with custom name', () => {
87
- const name = 'foo';
87
+ const SELECT_NAME = 'foo';
88
88
 
89
89
  render(
90
90
  <Select
91
- id={id}
92
- label={labelText}
93
- options={options}
94
- name={name}
91
+ id={SELECT_ID}
92
+ label={LABEL_TEXT}
93
+ options={OPTIONS}
94
+ name={SELECT_NAME}
95
95
  />
96
96
  );
97
97
 
98
98
  const select = screen.getByRole('combobox');
99
- expect(select).toHaveAttribute('name', name);
99
+ expect(select).toHaveAttribute('name', SELECT_NAME);
100
100
  });
101
101
 
102
102
  test('select with blur function', () => {
103
- const onBlurFn = vi.fn();
103
+ const ONBLUR_FUNCTION = vi.fn();
104
+
104
105
  render(
105
106
  <Select
106
- id={id}
107
- label={labelText}
108
- options={options}
109
- onBlur={onBlurFn}
107
+ id={SELECT_ID}
108
+ label={LABEL_TEXT}
109
+ options={OPTIONS}
110
+ onBlur={ONBLUR_FUNCTION}
110
111
  />
111
112
  );
112
113
 
@@ -114,17 +115,18 @@ test('select with blur function', () => {
114
115
 
115
116
  fireEvent.blur(select);
116
117
 
117
- expect(onBlurFn).toHaveBeenCalled();
118
+ expect(ONBLUR_FUNCTION).toHaveBeenCalled();
118
119
  });
119
120
 
120
121
  test('select with change function', () => {
121
- const onChangeFn = vi.fn();
122
+ const ONCHANGE_FUNCTION = vi.fn();
123
+
122
124
  render(
123
125
  <Select
124
- id={id}
125
- label={labelText}
126
- options={options}
127
- onChange={onChangeFn}
126
+ id={SELECT_ID}
127
+ label={LABEL_TEXT}
128
+ options={OPTIONS}
129
+ onChange={ONCHANGE_FUNCTION}
128
130
  />
129
131
  );
130
132
 
@@ -132,59 +134,60 @@ test('select with change function', () => {
132
134
 
133
135
  fireEvent.change(select, {target: {value: 'button'}});
134
136
 
135
- expect(onChangeFn).toHaveBeenCalled();
137
+ expect(ONCHANGE_FUNCTION).toHaveBeenCalled();
136
138
  });
137
139
 
138
140
  test('select with placeholder option', () => {
139
- const placeholder = 'foo';
141
+ const PLACEHOLDER_TEXT = 'foo';
140
142
 
141
143
  render(
142
144
  <Select
143
- id={id}
144
- label={labelText}
145
- options={options}
146
- placeholder={placeholder}
145
+ id={SELECT_ID}
146
+ label={LABEL_TEXT}
147
+ options={OPTIONS}
148
+ placeholder={PLACEHOLDER_TEXT}
147
149
  />
148
150
  );
149
151
 
150
152
  const select = screen.getByRole('combobox');
151
153
  const firstOption = select.childNodes[0];
152
- expect(firstOption.textContent).toEqual(placeholder);
154
+ expect(firstOption.textContent).toEqual(PLACEHOLDER_TEXT);
153
155
  expect(firstOption).toHaveAttribute('value', '');
154
156
  });
155
157
 
156
158
  test('select with initial value', () => {
157
- const initialValue = 'button';
159
+ const INITIAL_VALUE = 'button';
158
160
 
159
161
  render(
160
162
  <Select
161
- id={id}
162
- label={labelText}
163
- options={options}
164
- defaultValue={initialValue}
163
+ id={SELECT_ID}
164
+ label={LABEL_TEXT}
165
+ options={OPTIONS}
166
+ defaultValue={INITIAL_VALUE}
165
167
  />
166
168
  );
167
169
 
168
170
  const select = screen.getByRole('combobox');
169
171
  const selectedOption = [].slice.call(select.childNodes).filter(childNode => childNode.selected)[0];
170
- expect(selectedOption).toHaveAttribute('value', initialValue);
172
+ expect(selectedOption).toHaveAttribute('value', INITIAL_VALUE);
171
173
  });
172
174
 
173
175
  test('select with error message', () => {
174
- const errorMessage = 'This is a required field';
176
+ const ERROR_MESSAGE_TEXT = 'This is a required field';
177
+
175
178
  render(
176
179
  <Select
177
- id={id}
178
- label={labelText}
179
- options={options}
180
+ id={SELECT_ID}
181
+ label={LABEL_TEXT}
182
+ options={OPTIONS}
180
183
  error
181
- errorMessage={errorMessage}
184
+ errorMessage={ERROR_MESSAGE_TEXT}
182
185
  />
183
186
  );
184
187
 
185
188
  const select = screen.getByRole('combobox');
186
189
  const selectWrapper = select.parentElement;
187
- const errorMessageElement = screen.getByText(errorMessage);
190
+ const errorMessageElement = screen.getByText(ERROR_MESSAGE_TEXT);
188
191
 
189
192
  expect(selectWrapper).toHaveClass('ds_input--error')
190
193
  expect(select).toHaveAttribute('aria-describedby', errorMessageElement.id);
@@ -196,9 +199,9 @@ test('select with error message', () => {
196
199
  test('passing additional props', () => {
197
200
  render(
198
201
  <Select
199
- id={id}
200
- label={labelText}
201
- options={options}
202
+ id={SELECT_ID}
203
+ label={LABEL_TEXT}
204
+ options={OPTIONS}
202
205
  data-test="foo"
203
206
  />
204
207
  );
@@ -211,9 +214,9 @@ test('passing additional props', () => {
211
214
  test('passing additional CSS classes', () => {
212
215
  render(
213
216
  <Select
214
- id={id}
215
- label={labelText}
216
- options={options}
217
+ id={SELECT_ID}
218
+ label={LABEL_TEXT}
219
+ options={OPTIONS}
217
220
  className="foo"
218
221
  />
219
222
  );
@@ -1,5 +1,5 @@
1
- import ErrorMessage from '../error-message/error-message';
2
- import HintText from '../../common/hint-text';
1
+ import ErrorMessage from '../ErrorMessage/ErrorMessage';
2
+ import HintText from '../../common/HintText';
3
3
 
4
4
  const Option: React.FC<SGDS.Component.Select.Option> = function ({
5
5
  text,
@@ -1,15 +1,15 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen } from '@testing-library/react';
3
- import SequentialNavigation from './sequential-navigation';
3
+ import SequentialNavigation from './SequentialNavigation';
4
4
 
5
- const nextLinkObj = { title: 'Apply for or renew a Blue Badge?', href: '#prev' }
6
- const prevLinkObj = { title: 'Apply for or renew a Blue Badge?', href: '#prev' }
5
+ const NEXT_LINK_OBJECT = { title: 'Apply for or renew a Blue Badge?', href: '#prev' }
6
+ const PREVIOUS_LINK_OBJECT = { title: 'Apply for or renew a Blue Badge?', href: '#prev' }
7
7
 
8
8
  test('sequential navigation renders correctly', () => {
9
9
  render(
10
10
  <SequentialNavigation
11
- next={nextLinkObj}
12
- previous={prevLinkObj}
11
+ next={NEXT_LINK_OBJECT}
12
+ previous={PREVIOUS_LINK_OBJECT}
13
13
  />
14
14
  );
15
15
 
@@ -23,42 +23,42 @@ test('sequential navigation renders correctly', () => {
23
23
  expect(sequentialNavigation).toHaveAttribute('aria-label', 'Article navigation');
24
24
 
25
25
  expect(prevLink).toHaveClass('ds_sequential-nav__button', 'ds_sequential-nav__button--left');
26
- expect(prevLink).toHaveAttribute('href', prevLinkObj.href);
27
- expect(prevLink.textContent).toEqual(prevLinkObj.title);
26
+ expect(prevLink).toHaveAttribute('href', PREVIOUS_LINK_OBJECT.href);
27
+ expect(prevLink.textContent).toEqual(PREVIOUS_LINK_OBJECT.title);
28
28
  expect(prevLinkWrapper).toHaveClass('ds_sequential-nav__item', 'ds_sequential-nav__item--prev');
29
29
  expect(prevLinkWrapper?.tagName).toEqual('DIV');
30
30
  expect(prevLink.childNodes[0]).toHaveAttribute('data-label', 'Previous')
31
31
 
32
32
  expect(nextLink).toHaveClass('ds_sequential-nav__button', 'ds_sequential-nav__button--right');
33
- expect(nextLink).toHaveAttribute('href', nextLinkObj.href);
34
- expect(nextLink.textContent).toEqual(nextLinkObj.title);
33
+ expect(nextLink).toHaveAttribute('href', NEXT_LINK_OBJECT.href);
34
+ expect(nextLink.textContent).toEqual(NEXT_LINK_OBJECT.title);
35
35
  expect(nextLinkWrapper).toHaveClass('ds_sequential-nav__item', 'ds_sequential-nav__item--next');
36
36
  expect(nextLinkWrapper?.tagName).toEqual('DIV');
37
37
  expect(nextLink.childNodes[0]).toHaveAttribute('data-label', 'Next')
38
38
  });
39
39
 
40
40
  test('with custom aria label', () => {
41
- const ariaLabel = 'My label';
41
+ const ARIA_LABEL = 'My label';
42
42
 
43
43
  render(
44
44
  <SequentialNavigation
45
- ariaLabel={ariaLabel}
46
- next={nextLinkObj}
47
- previous={prevLinkObj}
45
+ ariaLabel={ARIA_LABEL}
46
+ next={NEXT_LINK_OBJECT}
47
+ previous={PREVIOUS_LINK_OBJECT}
48
48
  />
49
49
  );
50
50
 
51
51
  const sequentialNavigation = screen.getByRole('navigation');
52
52
 
53
- expect(sequentialNavigation).toHaveAttribute('aria-label', ariaLabel);
53
+ expect(sequentialNavigation).toHaveAttribute('aria-label', ARIA_LABEL);
54
54
  });
55
55
 
56
56
  test('passing additional props', () => {
57
57
  render(
58
58
  <SequentialNavigation
59
59
  data-test="foo"
60
- next={nextLinkObj}
61
- previous={prevLinkObj}
60
+ next={NEXT_LINK_OBJECT}
61
+ previous={PREVIOUS_LINK_OBJECT}
62
62
  />
63
63
  );
64
64
 
@@ -70,8 +70,8 @@ test('passing additional CSS classes', () => {
70
70
  render(
71
71
  <SequentialNavigation
72
72
  className="foo"
73
- next={nextLinkObj}
74
- previous={prevLinkObj}
73
+ next={NEXT_LINK_OBJECT}
74
+ previous={PREVIOUS_LINK_OBJECT}
75
75
  />
76
76
  );
77
77
 
@@ -1,8 +1,8 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen, within } from '@testing-library/react';
3
- import SideNavigation, { List, Link } from './side-navigation';
3
+ import SideNavigation, { List, Link } from './SideNavigation';
4
4
 
5
- const items = [
5
+ const ITEMS = [
6
6
  {
7
7
  title: 'Apples',
8
8
  href: '#apples',
@@ -43,7 +43,7 @@ const items = [
43
43
 
44
44
  test('side navigation renders correctly', () => {
45
45
  render(
46
- <SideNavigation items={items} />
46
+ <SideNavigation items={ITEMS} />
47
47
  );
48
48
 
49
49
  const sideNavigation = screen.getByRole('navigation');
@@ -124,7 +124,7 @@ test('side nav link with children', () => {
124
124
  });
125
125
 
126
126
  test('side nav list renders correctly', () => {
127
- const items = [
127
+ const ITEMS = [
128
128
  {
129
129
  title: 'Bramley',
130
130
  href: '#bramley'
@@ -136,7 +136,7 @@ test('side nav list renders correctly', () => {
136
136
  ];
137
137
 
138
138
  render(
139
- <List items={items}/>
139
+ <List items={ITEMS}/>
140
140
  );
141
141
 
142
142
  const list = screen.getByRole('list');
@@ -146,7 +146,7 @@ test('side nav list renders correctly', () => {
146
146
  expect(list).toHaveClass('ds_side-navigation__list');
147
147
  expect(list.tagName).toEqual('UL');
148
148
 
149
- expect(list.children.length).toEqual(items.length);
149
+ expect(list.children.length).toEqual(ITEMS.length);
150
150
 
151
151
  // check properties of first link
152
152
  expect(item).toHaveClass('ds_side-navigation__item');
@@ -157,7 +157,7 @@ test('side nav list renders correctly', () => {
157
157
 
158
158
  test('passing additional props', () => {
159
159
  render(
160
- <SideNavigation data-test="foo" items={items} />
160
+ <SideNavigation data-test="foo" items={ITEMS} />
161
161
  );
162
162
 
163
163
  const sideNavigation = screen.getByRole('navigation');
@@ -166,7 +166,7 @@ test('passing additional props', () => {
166
166
 
167
167
  test('passing additional CSS classes', () => {
168
168
  render(
169
- <SideNavigation className="foo" items={items} />
169
+ <SideNavigation className="foo" items={ITEMS} />
170
170
  );
171
171
 
172
172
  const sideNavigation = screen.getByRole('navigation');