@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,10 +1,10 @@
1
1
  import { test, expect, vi } from 'vitest';
2
2
  import { render, screen, fireEvent } from '@testing-library/react';
3
- import SummaryList, { Item, Action, Answer } from './summary-list';
3
+ import SummaryList, { Item, Action, Answer } from './SummaryList';
4
4
 
5
- const onClickFn = vi.fn();
5
+ const ONCLICK_FUNCTION = vi.fn();
6
6
 
7
- const items = [
7
+ const SUMMARY_ITEMS = [
8
8
  {
9
9
  title: 'Name',
10
10
  value: 'Jane Smith',
@@ -15,7 +15,7 @@ const items = [
15
15
  },
16
16
  {
17
17
  title: 'Delete',
18
- onclick: onClickFn
18
+ onclick: ONCLICK_FUNCTION
19
19
  }
20
20
  ]
21
21
  },
@@ -50,7 +50,7 @@ const items = [
50
50
 
51
51
  test('summary list renders correctly', () => {
52
52
  render(
53
- <SummaryList items={items} />
53
+ <SummaryList items={SUMMARY_ITEMS} />
54
54
  );
55
55
 
56
56
  const summaryList = screen.getAllByRole('list')[0];
@@ -58,12 +58,12 @@ test('summary list renders correctly', () => {
58
58
 
59
59
  expect(summaryList).toHaveClass('ds_summary-list');
60
60
  expect(summaryList.tagName).toEqual('OL');
61
- expect(summaryListItems.length).toEqual(items.length);
61
+ expect(summaryListItems.length).toEqual(SUMMARY_ITEMS.length);
62
62
  });
63
63
 
64
64
  test('summary list without border', () => {
65
65
  render(
66
- <SummaryList noBorder items={items} />
66
+ <SummaryList noBorder items={SUMMARY_ITEMS} />
67
67
  );
68
68
 
69
69
  const summaryList = screen.getAllByRole('list')[0];
@@ -72,11 +72,13 @@ test('summary list without border', () => {
72
72
  });
73
73
 
74
74
  test('summary list item renders correctly', () => {
75
+ const DESCRIBEDBY_ID = 'q2-date-of-birth';
76
+
75
77
  render(
76
78
  <Item
77
- actions={items[1].actions}
78
- title={items[1].title}
79
- value={items[1].value}
79
+ actions={SUMMARY_ITEMS[1].actions}
80
+ title={SUMMARY_ITEMS[1].title}
81
+ value={SUMMARY_ITEMS[1].value}
80
82
  />
81
83
  );
82
84
 
@@ -86,13 +88,11 @@ test('summary list item renders correctly', () => {
86
88
  const answer = value?.children[0];
87
89
  const actions = item.querySelector('.ds_summary-list__actions');
88
90
 
89
- const describedById = 'q2-date-of-birth';
90
-
91
91
  expect(item).toHaveClass('ds_summary-list__item');
92
92
 
93
93
  expect(key?.tagName).toEqual('SPAN');
94
94
  expect(key?.textContent).toEqual('Date of birth');
95
- expect(key).toHaveAttribute('id', describedById);
95
+ expect(key).toHaveAttribute('id', DESCRIBEDBY_ID);
96
96
 
97
97
  expect(value?.tagName).toEqual('SPAN');
98
98
 
@@ -101,15 +101,15 @@ test('summary list item renders correctly', () => {
101
101
 
102
102
  expect(actions?.tagName).toEqual('DIV');
103
103
 
104
- expect(actions?.querySelector('.ds_link')).toHaveAttribute('aria-describedby', describedById);
104
+ expect(actions?.querySelector('.ds_link')).toHaveAttribute('aria-describedby', DESCRIBEDBY_ID);
105
105
  });
106
106
 
107
107
  test('summary list item with multiple values', () => {
108
108
  render(
109
109
  <Item
110
- actions={items[3].actions}
111
- title={items[3].title}
112
- value={items[3].value}
110
+ actions={SUMMARY_ITEMS[3].actions}
111
+ title={SUMMARY_ITEMS[3].title}
112
+ value={SUMMARY_ITEMS[3].value}
113
113
  />
114
114
  );
115
115
 
@@ -121,17 +121,17 @@ test('summary list item with multiple values', () => {
121
121
  expect(valueList).toHaveClass('ds_no-bullets');
122
122
  expect(valueList?.tagName).toEqual('UL');
123
123
 
124
- expect(valueListItems?.length).toEqual(items[3].value.length);
124
+ expect(valueListItems?.length).toEqual(SUMMARY_ITEMS[3].value.length);
125
125
 
126
126
  expect(valueListItems[0].tagName).toEqual('LI');
127
- expect(valueListItems[0].innerHTML).toEqual(`<q class="ds_summary-list__answer">${items[3].value[0]}</q>`);
127
+ expect(valueListItems[0].innerHTML).toEqual(`<q class="ds_summary-list__answer">${SUMMARY_ITEMS[3].value[0]}</q>`);
128
128
  });
129
129
 
130
130
  test('summary list item with no value', () => {
131
131
  render(
132
132
  <Item
133
- actions={items[3].actions}
134
- title={items[3].title}
133
+ actions={SUMMARY_ITEMS[3].actions}
134
+ title={SUMMARY_ITEMS[3].title}
135
135
  />
136
136
  );
137
137
 
@@ -143,92 +143,91 @@ test('summary list item with no value', () => {
143
143
  });
144
144
 
145
145
  test('summary list item with multiple actions', () => {
146
- const title = 'Name';
147
- const value = 'Jane Smith';
148
- const actions = [
146
+ const ITEM_TITLE = 'Name';
147
+ const ITEM_VALUE = 'Jane Smith';
148
+ const ITEM_ACTIONS = [
149
149
  {
150
150
  title: 'Change',
151
151
  href: '#foo'
152
152
  },
153
153
  {
154
154
  title: 'Delete',
155
- onclick: onClickFn
155
+ onclick: ONCLICK_FUNCTION
156
156
  }
157
157
  ];
158
158
 
159
159
  render(
160
160
  <Item
161
- actions={items[0].actions}
162
- title={title}
163
- value={value}
161
+ actions={SUMMARY_ITEMS[0].actions}
162
+ title={ITEM_TITLE}
163
+ value={ITEM_VALUE}
164
164
  />
165
165
  );
166
166
 
167
167
  const item = screen.getAllByRole('listitem')[0];
168
168
  const actionsElement = item.querySelector('.ds_summary-list__actions');
169
169
 
170
- expect(actionsElement?.children.length).toEqual(actions.length);
171
- expect(actionsElement?.children[0].textContent).toEqual(actions[0].title);
172
- expect(actionsElement?.children[1].textContent).toEqual(actions[1].title);
170
+ expect(actionsElement?.children.length).toEqual(ITEM_ACTIONS.length);
171
+ expect(actionsElement?.children[0].textContent).toEqual(ITEM_ACTIONS[0].title);
172
+ expect(actionsElement?.children[1].textContent).toEqual(ITEM_ACTIONS[1].title);
173
173
  });
174
174
 
175
175
  test('button action', () => {
176
- const describedById = 'q1-name';
177
- const title = 'Name';
178
- const href = undefined;
179
- const onClick = onClickFn;
176
+ const DESCRIBEDBY_ID = 'q1-name';
177
+ const ACTION_TITLE = 'Name';
178
+ const ACTION_ONCLICK = ONCLICK_FUNCTION;
180
179
 
181
180
  render(
182
181
  <Action
183
- describedby={describedById}
184
- href={href}
185
- onclick={onClick}
186
- title={title}
182
+ describedby={DESCRIBEDBY_ID}
183
+ href={undefined}
184
+ onclick={ACTION_ONCLICK}
185
+ title={ACTION_TITLE}
187
186
  />
188
187
  );
189
188
 
190
189
  const action = screen.getByRole('button');
191
190
 
192
191
  expect(action).toHaveClass('ds_link');
193
- expect(action).toHaveAttribute('aria-describedby', describedById);
192
+ expect(action).toHaveAttribute('aria-describedby', DESCRIBEDBY_ID);
194
193
  expect(action).toHaveAttribute('type', 'button');
195
194
  expect(action).not.toHaveAttribute('href');
196
195
  expect(action.tagName).toEqual('BUTTON');
197
- expect(action.textContent).toEqual(title);
196
+ expect(action.textContent).toEqual(ACTION_TITLE);
198
197
 
199
198
  fireEvent.click(action);
200
199
 
201
- expect(onClickFn).toHaveBeenCalled();
200
+ expect(ONCLICK_FUNCTION).toHaveBeenCalled();
202
201
  });
203
202
 
204
203
  test('link action', () => {
205
- const describedById = 'q1-name';
206
- const title = 'Name';
207
- const href = "#foo"
208
- const onClick = onClickFn;
204
+ const DESCRIBEDBY_ID = 'q1-name';
205
+ const ACTION_TITLE = 'Name';
206
+ const ACTION_HREF = "#foo"
207
+ const ACTION_ONCLICK = ONCLICK_FUNCTION;
209
208
 
210
209
  render(
211
210
  <Action
212
- describedby={describedById}
213
- href={href}
214
- onclick={onClick}
215
- title={title}
211
+ describedby={DESCRIBEDBY_ID}
212
+ href={ACTION_HREF}
213
+ onclick={ACTION_ONCLICK}
214
+ title={ACTION_TITLE}
216
215
  />
217
216
  );
218
217
 
219
218
  const action = screen.getByRole('link');
220
219
 
221
220
  expect(action).toHaveClass('ds_link');
222
- expect(action).toHaveAttribute('aria-describedby', describedById);
223
- expect(action).toHaveAttribute('href', href);
221
+ expect(action).toHaveAttribute('aria-describedby', DESCRIBEDBY_ID);
222
+ expect(action).toHaveAttribute('href', ACTION_HREF);
224
223
  expect(action).not.toHaveAttribute('type');
225
224
  expect(action.tagName).toEqual('A');
226
- expect(action.textContent).toEqual(title);
225
+ expect(action.textContent).toEqual(ACTION_TITLE);
227
226
  });
228
227
 
229
228
  test('multiline answer', () => {
230
229
  render(
231
- <Answer value={items[2].value} />
230
+ <Answer value={SUMMARY_ITEMS[2].value} />
232
231
  );
233
232
 
234
233
  const answer = document.querySelector('.ds_summary-list__answer');
@@ -238,7 +237,7 @@ test('multiline answer', () => {
238
237
 
239
238
  test('passing additional props', () => {
240
239
  render(
241
- <SummaryList data-test="foo" items={items} />
240
+ <SummaryList data-test="foo" items={SUMMARY_ITEMS} />
242
241
  );
243
242
 
244
243
  const summaryList = screen.getAllByRole('list')[0];
@@ -247,7 +246,7 @@ test('passing additional props', () => {
247
246
 
248
247
  test('passing additional CSS classes', () => {
249
248
  render(
250
- <SummaryList className="foo" items={items} />
249
+ <SummaryList className="foo" items={SUMMARY_ITEMS} />
251
250
  );
252
251
 
253
252
  const summaryList = screen.getAllByRole('list')[0];
@@ -1,5 +1,5 @@
1
- import ConditionalWrapper from '../../common/conditional-wrapper';
2
- import WrapperTag from '../../common/wrapper-tag';
1
+ import ConditionalWrapper from '../../common/ConditionalWrapper';
2
+ import WrapperTag from '../../common/WrapperTag';
3
3
 
4
4
  function escapedNewLineToLineBreakTag (string: string) {
5
5
  if (typeof string === 'string') {
@@ -1,6 +1,6 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen } from '@testing-library/react';
3
- import Table from './table';
3
+ import Table from './Table';
4
4
 
5
5
  test('table renders correctly', () => {
6
6
  render(
@@ -30,10 +30,10 @@ test('table renders correctly', () => {
30
30
  });
31
31
 
32
32
  test('table with smallscreen behaviour', () => {
33
- const behaviour = 'scrolling';
33
+ const SMALL_SCREEN_BEHAVIOUR = 'scrolling';
34
34
 
35
35
  render(
36
- <Table smallscreen={behaviour}>
36
+ <Table smallscreen={SMALL_SCREEN_BEHAVIOUR}>
37
37
  <caption>Public holidays in 2020</caption>
38
38
  <thead>
39
39
  <tr>
@@ -54,7 +54,7 @@ test('table with smallscreen behaviour', () => {
54
54
 
55
55
  const table = screen.getByRole('table');
56
56
 
57
- expect(table).toHaveAttribute('data-smallscreen', behaviour);
57
+ expect(table).toHaveAttribute('data-smallscreen', SMALL_SCREEN_BEHAVIOUR);
58
58
  expect(table.nodeName).toEqual('TABLE');
59
59
  });
60
60
 
@@ -1,6 +1,6 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen, within } from '@testing-library/react';
3
- import Tabs from './tabs';
3
+ import Tabs from './Tabs';
4
4
  import slugify from '../../utils/slugify';
5
5
 
6
6
  test('tab container renders correctly', () => {
@@ -29,7 +29,7 @@ test('tab container renders correctly', () => {
29
29
  expect(tabContainer.tagName).toEqual('DIV');
30
30
 
31
31
  expect(tabHeading).toHaveClass('ds_tabs__title');
32
- // default header level
32
+ // default heading level
33
33
  expect(tabHeading.tagName).toEqual('H2');
34
34
  expect(tabHeading.parentElement).toEqual(tabContainer);
35
35
  // default ID-heading
@@ -83,10 +83,10 @@ test('non-bordered tabs', () => {
83
83
  });
84
84
 
85
85
  test('custom title', () => {
86
- const title = 'My title';
86
+ const TABS_TITLE = 'My title';
87
87
 
88
88
  render(
89
- <Tabs data-testid="tabcontainer" title={title}>
89
+ <Tabs data-testid="tabcontainer" title={TABS_TITLE}>
90
90
  <Tabs.Item tabLabel="Tab 1" data-testid="tabpanel1">
91
91
  <div data-testid="tabpanel1content">Content one</div>
92
92
  </Tabs.Item>
@@ -101,14 +101,14 @@ test('custom title', () => {
101
101
  const tabHeading = within(tabContainer).getByRole('heading');
102
102
 
103
103
  expect(tabList).toHaveAttribute('aria-labelledby', tabHeading.id);
104
- expect(tabHeading.textContent).toEqual(title)
104
+ expect(tabHeading.textContent).toEqual(TABS_TITLE)
105
105
  });
106
106
 
107
- test('custom base ID', () => {
108
- const baseId = 'foo';
107
+ test('custom heading level', () => {
108
+ const HEADING_LEVEL = 'h3';
109
109
 
110
110
  render(
111
- <Tabs data-testid="tabcontainer" baseId={baseId}>
111
+ <Tabs data-testid="tabcontainer" headingLevel={HEADING_LEVEL}>
112
112
  <Tabs.Item tabLabel="Tab 1" data-testid="tabpanel1">
113
113
  <div data-testid="tabpanel1content">Content one</div>
114
114
  </Tabs.Item>
@@ -121,34 +121,14 @@ test('custom base ID', () => {
121
121
  const tabContainer = screen.getByTestId('tabcontainer');
122
122
  const tabHeading = within(tabContainer).getByRole('heading');
123
123
 
124
- expect(tabHeading).toHaveAttribute('id', `${baseId}-heading`);
125
- });
126
-
127
- test('custom header level', () => {
128
- const headerLevel = 'h3';
129
-
130
- render(
131
- <Tabs data-testid="tabcontainer" headerLevel={headerLevel}>
132
- <Tabs.Item tabLabel="Tab 1" data-testid="tabpanel1">
133
- <div data-testid="tabpanel1content">Content one</div>
134
- </Tabs.Item>
135
- <Tabs.Item tabLabel="Tab 2" data-testid="tabpanel2">
136
- Content two
137
- </Tabs.Item>
138
- </Tabs>
139
- );
140
-
141
- const tabContainer = screen.getByTestId('tabcontainer');
142
- const tabHeading = within(tabContainer).getByRole('heading');
143
-
144
- expect(tabHeading.tagName).toEqual(headerLevel.toUpperCase());
124
+ expect(tabHeading.tagName).toEqual(HEADING_LEVEL.toUpperCase());
145
125
  });
146
126
 
147
127
  test('custom baseID', () => {
148
- const baseId = 'myId';
128
+ const BASE_ID = 'myId';
149
129
 
150
130
  render(
151
- <Tabs data-testid="tabcontainer" baseId={baseId}>
131
+ <Tabs data-testid="tabcontainer" baseId={BASE_ID}>
152
132
  <Tabs.Item tabLabel="Tab 1" data-testid="tabpanel1">
153
133
  <div data-testid="tabpanel1content">Content one</div>
154
134
  </Tabs.Item>
@@ -164,23 +144,23 @@ test('custom baseID', () => {
164
144
  const tabPanelTwo = screen.getByTestId('tabpanel2');
165
145
 
166
146
  // default title slugified to part of the ID
167
- expect(tabHeading).toHaveAttribute('id', `${baseId}-heading`);
147
+ expect(tabHeading).toHaveAttribute('id', `${BASE_ID}-heading`);
168
148
  // generated IDs using the slug of the tab title
169
- expect(tabPanelOne).toHaveAttribute('id', `${baseId}-tab-1`);
170
- expect(tabPanelTwo).toHaveAttribute('id', `${baseId}-tab-2`);
149
+ expect(tabPanelOne).toHaveAttribute('id', `${BASE_ID}-tab-1`);
150
+ expect(tabPanelTwo).toHaveAttribute('id', `${BASE_ID}-tab-2`);
171
151
  });
172
152
 
173
153
  test('tab with and without specific ID attribute', () => {
174
- const baseId = 'foo'
175
- const tabLabel = 'Tab 1';
176
- const id = 'bar';
154
+ const BASE_ID = 'foo'
155
+ const TAB_LABEL = 'Tab 1';
156
+ const TAB_ID = 'bar';
177
157
 
178
158
  render(
179
- <Tabs baseId={baseId}>
180
- <Tabs.Item tabLabel={tabLabel} data-testid="tabpanel1">
159
+ <Tabs baseId={BASE_ID}>
160
+ <Tabs.Item tabLabel={TAB_LABEL} data-testid="tabpanel1">
181
161
  <div data-testid="tabpanel1content">Content one</div>
182
162
  </Tabs.Item>
183
- <Tabs.Item tabLabel="Tab 2" id={id} data-testid="tabpanel2">
163
+ <Tabs.Item tabLabel="Tab 2" id={TAB_ID} data-testid="tabpanel2">
184
164
  <div data-testid="tabpanel1content">Content one</div>
185
165
  </Tabs.Item>
186
166
  </Tabs>
@@ -189,8 +169,8 @@ test('tab with and without specific ID attribute', () => {
189
169
  const tabPanelOne = screen.getByTestId('tabpanel1');
190
170
  const tabPanelTwo = screen.getByTestId('tabpanel2');
191
171
 
192
- expect(tabPanelOne).toHaveAttribute('id', `${baseId}-${slugify(tabLabel)}`);
193
- expect(tabPanelTwo).toHaveAttribute('id', id);
172
+ expect(tabPanelOne).toHaveAttribute('id', `${BASE_ID}-${slugify(TAB_LABEL)}`);
173
+ expect(tabPanelTwo).toHaveAttribute('id', TAB_ID);
194
174
  });
195
175
 
196
176
  test('with manual activation', () => {
@@ -1,5 +1,5 @@
1
1
  import React, { isValidElement, Children, useEffect, useRef } from 'react';
2
- import WrapperTag from '../../common/wrapper-tag';
2
+ import WrapperTag from '../../common/WrapperTag';
3
3
  // @ts-ignore
4
4
  import DSTabs from '@scottish-government/design-system/src/components/tabs/tabs';
5
5
  import slugify from '../../utils/slugify';
@@ -44,7 +44,7 @@ const Tabs: React.FC<SGDS.Component.Tabs>
44
44
  bordered = true,
45
45
  children,
46
46
  className,
47
- headerLevel = 'h2',
47
+ headingLevel = 'h2',
48
48
  manual = false,
49
49
  title = 'Contents',
50
50
  ...props
@@ -89,7 +89,7 @@ const Tabs: React.FC<SGDS.Component.Tabs>
89
89
  <WrapperTag
90
90
  id={headingId}
91
91
  className="ds_tabs__title"
92
- tagName={headerLevel}
92
+ tagName={headingLevel}
93
93
  >
94
94
  {title}
95
95
  </WrapperTag>
@@ -1,15 +1,15 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { render, screen } from '@testing-library/react';
3
- import Tag from './tag';
3
+ import Tag from './Tag';
4
4
 
5
- const tagText = 'Beta';
5
+ const TAG_TEXT = 'Beta';
6
6
 
7
7
  test('tag renders correctly', () => {
8
8
  render(
9
- <Tag title={tagText}/>
9
+ <Tag title={TAG_TEXT}/>
10
10
  );
11
11
 
12
- const tag = screen.getByText(tagText);
12
+ const tag = screen.getByText(TAG_TEXT);
13
13
 
14
14
  expect(tag).toHaveClass('ds_tag');
15
15
  expect(tag.nodeName).toEqual('SPAN');
@@ -17,29 +17,29 @@ test('tag renders correctly', () => {
17
17
 
18
18
  test('tag with custom colour', () => {
19
19
  render(
20
- <Tag colour="red" title={tagText}/>
20
+ <Tag colour="red" title={TAG_TEXT}/>
21
21
  );
22
22
 
23
- const tag = screen.getByText(tagText);
23
+ const tag = screen.getByText(TAG_TEXT);
24
24
 
25
25
  expect(tag).toHaveClass('ds_tag--red');
26
26
  });
27
27
 
28
28
  test('passing additional props', () => {
29
29
  render(
30
- <Tag data-test="foo" title={tagText}/>
30
+ <Tag data-test="foo" title={TAG_TEXT}/>
31
31
  );
32
32
 
33
- const tag = screen.getByText(tagText);
33
+ const tag = screen.getByText(TAG_TEXT);
34
34
  expect(tag?.dataset.test).toEqual('foo');
35
35
  });
36
36
 
37
37
  test('tag with additional CSS class', () => {
38
38
  render(
39
- <Tag className="foo" title={tagText}/>
39
+ <Tag className="foo" title={TAG_TEXT}/>
40
40
  );
41
41
 
42
- const tag = screen.getByText(tagText);
42
+ const tag = screen.getByText(TAG_TEXT);
43
43
 
44
44
  expect(tag).toHaveClass('foo', 'ds_tag');
45
45
  });