@dxc-technology/halstack-react 0.0.0-aa03ee1 → 0.0.0-aa15b96

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 (50) hide show
  1. package/ThemeContext.d.ts +4 -9
  2. package/ThemeContext.js +25 -17
  3. package/accordion/Accordion.test.js +57 -0
  4. package/accordion-group/AccordionGroup.test.js +133 -0
  5. package/alert/Alert.test.js +92 -0
  6. package/box/Box.test.js +18 -0
  7. package/button/Button.test.js +35 -0
  8. package/card/Card.test.js +50 -0
  9. package/checkbox/Checkbox.test.js +65 -0
  10. package/chip/Chip.test.js +56 -0
  11. package/common/variables.js +0 -5
  12. package/date-input/DateInput.test.js +469 -0
  13. package/dialog/Dialog.test.js +40 -0
  14. package/dropdown/Dropdown.test.js +189 -0
  15. package/file-input/FileInput.test.js +457 -0
  16. package/footer/Footer.test.js +109 -0
  17. package/header/Header.test.js +63 -0
  18. package/heading/Heading.test.js +186 -0
  19. package/link/Link.test.js +91 -0
  20. package/number-input/NumberInput.test.js +508 -0
  21. package/package.json +1 -1
  22. package/paginator/Paginator.test.js +266 -0
  23. package/password-input/PasswordInput.test.js +183 -0
  24. package/progress-bar/ProgressBar.test.js +65 -0
  25. package/radio/Radio.test.js +71 -0
  26. package/radio-group/Radio.d.ts +1 -1
  27. package/radio-group/Radio.js +24 -23
  28. package/radio-group/RadioGroup.js +39 -32
  29. package/radio-group/RadioGroup.stories.tsx +60 -39
  30. package/radio-group/RadioGroup.test.js +530 -83
  31. package/radio-group/types.d.ts +80 -2
  32. package/resultsetTable/ResultsetTable.test.js +306 -0
  33. package/select/Icons.d.ts +10 -0
  34. package/select/Icons.js +93 -0
  35. package/select/Option.d.ts +4 -0
  36. package/select/Option.js +110 -0
  37. package/select/Select.js +43 -172
  38. package/select/Select.test.js +1900 -0
  39. package/select/types.d.ts +13 -0
  40. package/sidenav/Sidenav.test.js +56 -0
  41. package/slider/Slider.test.js +129 -0
  42. package/spinner/Spinner.test.js +64 -0
  43. package/switch/Switch.test.js +73 -0
  44. package/table/Table.test.js +26 -0
  45. package/tabs/Tabs.test.js +123 -0
  46. package/tag/Tag.test.js +60 -0
  47. package/text-input/TextInput.test.js +1691 -0
  48. package/textarea/Textarea.test.js +436 -0
  49. package/toggle-group/ToggleGroup.test.js +125 -0
  50. package/wizard/Wizard.test.js +128 -0
package/ThemeContext.d.ts CHANGED
@@ -1,15 +1,10 @@
1
1
  import React from "react";
2
2
  declare const ThemeContext: React.Context<object>;
3
- declare type ThemeProviderCommonProps = {
3
+ declare type ThemeProviderPropsType = {
4
+ theme?: object;
5
+ advancedTheme?: object;
4
6
  children: React.ReactNode;
5
7
  };
6
- declare type ThemeProviderDefaultTheme = ThemeProviderCommonProps & {
7
- theme: object;
8
- };
9
- declare type ThemeProviderAdvancedTheme = ThemeProviderCommonProps & {
10
- advancedTheme: object;
11
- };
12
- declare type ThemeProviderPropsType = ThemeProviderDefaultTheme | ThemeProviderAdvancedTheme;
13
- declare const ThemeProvider: (props: ThemeProviderPropsType) => JSX.Element;
8
+ declare const ThemeProvider: ({ theme, advancedTheme, children }: ThemeProviderPropsType) => JSX.Element;
14
9
  export default ThemeContext;
15
10
  export { ThemeProvider };
package/ThemeContext.js CHANGED
@@ -81,7 +81,7 @@ var parseAdvancedTheme = function parseAdvancedTheme(advancedTheme) {
81
81
  };
82
82
 
83
83
  var parseTheme = function parseTheme(theme) {
84
- var _theme$accordion$font, _theme$accordion, _theme$accordion$font2, _theme$accordion2, _theme$accordion$acce, _theme$accordion3, _theme$accordion$acce2, _theme$accordion4, _theme$accordion$acce3, _theme$accordion5, _setOpacity, _theme$accordion6, _setOpacity2, _theme$accordion7, _setOpacity3, _theme$accordion8, _setOpacity4, _theme$accordion9, _setOpacity5, _theme$accordion10, _theme$button$primary, _theme$button, _theme$button$baseCol, _theme$button2, _theme$button$baseCol2, _theme$button3, _theme$button$seconda, _theme$button4, _theme$button$baseCol3, _theme$button5, _theme$button$baseCol4, _theme$button6, _theme$button$baseCol5, _theme$button7, _subLightness, _theme$button8, _subLightness2, _theme$button9, _subLightness3, _theme$button10, _addLightness, _theme$button11, _addLightness2, _theme$button12, _theme$checkbox$baseC, _theme$checkbox, _theme$checkbox$baseC2, _theme$checkbox2, _theme$checkbox$check, _theme$checkbox3, _setOpacity6, _theme$checkbox4, _setOpacity7, _theme$checkbox5, _setOpacity8, _theme$checkbox6, _theme$chip$baseColor, _theme$chip, _setOpacity9, _theme$chip2, _theme$chip$fontColor, _theme$chip3, _setOpacity10, _theme$chip4, _theme$dateInput$base, _theme$dateInput, _theme$dateInput$acce, _theme$dateInput2, _setOpacity11, _theme$dateInput3, _theme$dropdown$baseC, _theme$dropdown, _theme$dropdown$fontC, _theme$dropdown2, _setOpacity12, _theme$dropdown3, _setOpacity13, _theme$dropdown4, _setOpacity14, _theme$dropdown5, _setOpacity15, _theme$dropdown6, _theme$fileInput$font, _theme$fileInput, _theme$fileInput$font2, _theme$fileInput2, _theme$fileInput$font3, _theme$fileInput3, _theme$fileInput$font4, _theme$fileInput4, _setOpacity16, _theme$fileInput5, _setOpacity17, _theme$fileInput6, _setOpacity18, _theme$fileInput7, _theme$footer$baseCol, _theme$footer, _theme$footer$fontCol, _theme$footer2, _theme$footer$fontCol2, _theme$footer3, _theme$footer$fontCol3, _theme$footer4, _theme$footer$accentC, _theme$footer5, _theme$footer$logo, _theme$footer6, _theme$header$baseCol, _theme$header, _theme$header$accentC, _theme$header2, _theme$header$menuBas, _theme$header3, _theme$header$fontCol, _theme$header4, _theme$header$hamburg, _theme$header5, _setOpacity19, _theme$header6, _theme$header$logo, _theme$header7, _theme$header$logoRes, _theme$header8, _theme$header$content, _theme$header9, _theme$header$content2, _theme$header10, _theme$textInput$base, _theme$textInput, _subLightness4, _theme$textInput2, _theme$paginator$base, _theme$paginator, _theme$paginator$font, _theme$paginator2, _theme$progressBar$ac, _theme$progressBar, _theme$progressBar$ba, _theme$progressBar2, _theme$radio$baseColo, _theme$radio, _setOpacity20, _theme$radio2, _theme$sidenav$baseCo, _theme$sidenav, _setOpacity21, _theme$sidenav2, _theme$sidenav$arrowA, _theme$sidenav3, _theme$slider$baseCol, _theme$slider, _theme$slider$baseCol2, _theme$slider2, _theme$slider$baseCol3, _theme$slider3, _subLightness5, _theme$slider4, _subLightness6, _theme$slider5, _setOpacity22, _theme$slider6, _setOpacity23, _theme$slider7, _setOpacity24, _theme$slider8, _setOpacity25, _theme$slider9, _theme$spinner$accent, _theme$spinner, _theme$spinner$baseCo, _theme$spinner2, _theme$switch$checked, _theme$switch, _setOpacity26, _theme$switch2, _theme$table$baseColo, _theme$table, _theme$table$fontColo, _theme$table2, _theme$tabs$baseColor, _theme$tabs, _theme$tabs$baseColor2, _theme$tabs2, _theme$tabs$baseColor3, _theme$tabs3, _theme$tabs$baseColor4, _theme$tabs4, _addLightness3, _theme$tabs5, _addLightness4, _theme$tabs6, _theme$toggleGroup$se, _theme$toggleGroup, _theme$toggleGroup$se2, _theme$toggleGroup2, _theme$toggleGroup$un, _theme$toggleGroup3, _theme$toggleGroup$se3, _theme$toggleGroup4, _theme$toggleGroup$un2, _theme$toggleGroup5, _subLightness7, _theme$toggleGroup6, _subLightness8, _theme$toggleGroup7, _addLightness5, _theme$toggleGroup8, _addLightness6, _theme$toggleGroup9, _subLightness9, _theme$toggleGroup10, _addLightness7, _theme$toggleGroup11, _setOpacity27, _theme$toggleGroup12, _theme$wizard$baseCol, _theme$wizard, _theme$wizard$fontCol, _theme$wizard2;
84
+ var _theme$accordion$font, _theme$accordion, _theme$accordion$font2, _theme$accordion2, _theme$accordion$acce, _theme$accordion3, _theme$accordion$acce2, _theme$accordion4, _theme$accordion$acce3, _theme$accordion5, _setOpacity, _theme$accordion6, _setOpacity2, _theme$accordion7, _setOpacity3, _theme$accordion8, _setOpacity4, _theme$accordion9, _setOpacity5, _theme$accordion10, _theme$button$primary, _theme$button, _theme$button$baseCol, _theme$button2, _theme$button$baseCol2, _theme$button3, _theme$button$seconda, _theme$button4, _theme$button$baseCol3, _theme$button5, _theme$button$baseCol4, _theme$button6, _theme$button$baseCol5, _theme$button7, _subLightness, _theme$button8, _subLightness2, _theme$button9, _subLightness3, _theme$button10, _addLightness, _theme$button11, _addLightness2, _theme$button12, _theme$checkbox$baseC, _theme$checkbox, _theme$checkbox$baseC2, _theme$checkbox2, _theme$checkbox$check, _theme$checkbox3, _setOpacity6, _theme$checkbox4, _setOpacity7, _theme$checkbox5, _setOpacity8, _theme$checkbox6, _theme$chip$baseColor, _theme$chip, _setOpacity9, _theme$chip2, _theme$chip$fontColor, _theme$chip3, _setOpacity10, _theme$chip4, _theme$dateInput$base, _theme$dateInput, _theme$dateInput$acce, _theme$dateInput2, _setOpacity11, _theme$dateInput3, _theme$dropdown$baseC, _theme$dropdown, _theme$dropdown$fontC, _theme$dropdown2, _setOpacity12, _theme$dropdown3, _setOpacity13, _theme$dropdown4, _setOpacity14, _theme$dropdown5, _setOpacity15, _theme$dropdown6, _theme$fileInput$font, _theme$fileInput, _theme$fileInput$font2, _theme$fileInput2, _theme$fileInput$font3, _theme$fileInput3, _theme$fileInput$font4, _theme$fileInput4, _setOpacity16, _theme$fileInput5, _setOpacity17, _theme$fileInput6, _setOpacity18, _theme$fileInput7, _theme$footer$baseCol, _theme$footer, _theme$footer$fontCol, _theme$footer2, _theme$footer$fontCol2, _theme$footer3, _theme$footer$fontCol3, _theme$footer4, _theme$footer$accentC, _theme$footer5, _theme$footer$logo, _theme$footer6, _theme$header$baseCol, _theme$header, _theme$header$accentC, _theme$header2, _theme$header$menuBas, _theme$header3, _theme$header$fontCol, _theme$header4, _theme$header$hamburg, _theme$header5, _setOpacity19, _theme$header6, _theme$header$logo, _theme$header7, _theme$header$logoRes, _theme$header8, _theme$header$content, _theme$header9, _theme$paginator$base, _theme$paginator, _theme$paginator$font, _theme$paginator2, _theme$progressBar$ac, _theme$progressBar, _theme$progressBar$ba, _theme$progressBar2, _theme$radio$baseColo, _theme$radio, _setOpacity20, _theme$radio2, _theme$select$baseCol, _theme$select, _theme$select$fontCol, _theme$select2, _theme$select$fontCol2, _theme$select3, _addLightness3, _theme$select4, _subLightness4, _theme$select5, _theme$sidenav$baseCo, _theme$sidenav, _setOpacity21, _theme$sidenav2, _theme$sidenav$arrowA, _theme$sidenav3, _theme$slider$baseCol, _theme$slider, _theme$slider$baseCol2, _theme$slider2, _theme$slider$baseCol3, _theme$slider3, _subLightness5, _theme$slider4, _subLightness6, _theme$slider5, _setOpacity22, _theme$slider6, _setOpacity23, _theme$slider7, _setOpacity24, _theme$slider8, _setOpacity25, _theme$slider9, _theme$spinner$accent, _theme$spinner, _theme$spinner$baseCo, _theme$spinner2, _theme$switch$checked, _theme$switch, _setOpacity26, _theme$switch2, _theme$table$baseColo, _theme$table, _theme$table$fontColo, _theme$table2, _theme$tabs$baseColor, _theme$tabs, _theme$tabs$baseColor2, _theme$tabs2, _theme$tabs$baseColor3, _theme$tabs3, _theme$tabs$baseColor4, _theme$tabs4, _addLightness4, _theme$tabs5, _addLightness5, _theme$tabs6, _theme$textInput$base, _theme$textInput, _subLightness7, _theme$textInput2, _theme$toggleGroup$se, _theme$toggleGroup, _theme$toggleGroup$se2, _theme$toggleGroup2, _theme$toggleGroup$un, _theme$toggleGroup3, _theme$toggleGroup$se3, _theme$toggleGroup4, _theme$toggleGroup$un2, _theme$toggleGroup5, _subLightness8, _theme$toggleGroup6, _subLightness9, _theme$toggleGroup7, _addLightness6, _theme$toggleGroup8, _addLightness7, _theme$toggleGroup9, _subLightness10, _theme$toggleGroup10, _addLightness8, _theme$toggleGroup11, _setOpacity27, _theme$toggleGroup12, _theme$wizard$baseCol, _theme$wizard, _theme$wizard$fontCol, _theme$wizard2;
85
85
 
86
86
  var componentTokensCopy = JSON.parse(JSON.stringify(_variables.componentTokens));
87
87
  var accordionTokens = componentTokensCopy.accordion;
@@ -156,10 +156,6 @@ var parseTheme = function parseTheme(theme) {
156
156
  headerTokens.logo = (_theme$header$logo = theme === null || theme === void 0 ? void 0 : (_theme$header7 = theme.header) === null || _theme$header7 === void 0 ? void 0 : _theme$header7.logo) !== null && _theme$header$logo !== void 0 ? _theme$header$logo : headerTokens.logo;
157
157
  headerTokens.logoResponsive = (_theme$header$logoRes = theme === null || theme === void 0 ? void 0 : (_theme$header8 = theme.header) === null || _theme$header8 === void 0 ? void 0 : _theme$header8.logoResponsive) !== null && _theme$header$logoRes !== void 0 ? _theme$header$logoRes : headerTokens.logoResponsive;
158
158
  headerTokens.contentColor = (_theme$header$content = theme === null || theme === void 0 ? void 0 : (_theme$header9 = theme.header) === null || _theme$header9 === void 0 ? void 0 : _theme$header9.contentColor) !== null && _theme$header$content !== void 0 ? _theme$header$content : headerTokens.contentColor;
159
- headerTokens.contentColorOnDark = (_theme$header$content2 = theme === null || theme === void 0 ? void 0 : (_theme$header10 = theme.header) === null || _theme$header10 === void 0 ? void 0 : _theme$header10.contentColorOnDark) !== null && _theme$header$content2 !== void 0 ? _theme$header$content2 : headerTokens.contentColorOnDark;
160
- var textInputTokens = componentTokensCopy.textInput;
161
- textInputTokens.hoverListOptionBackgroundColor = (_theme$textInput$base = theme === null || theme === void 0 ? void 0 : (_theme$textInput = theme.textInput) === null || _theme$textInput === void 0 ? void 0 : _theme$textInput.baseColor) !== null && _theme$textInput$base !== void 0 ? _theme$textInput$base : textInputTokens.hoverListOptionBackgroundColor;
162
- textInputTokens.activeListOptionBackgroundColor = (_subLightness4 = subLightness(theme === null || theme === void 0 ? void 0 : (_theme$textInput2 = theme.textInput) === null || _theme$textInput2 === void 0 ? void 0 : _theme$textInput2.baseColor, 15)) !== null && _subLightness4 !== void 0 ? _subLightness4 : textInputTokens.activeListOptionBackgroundColor;
163
159
  var paginatorTokens = componentTokensCopy.paginator;
164
160
  paginatorTokens.backgroundColor = (_theme$paginator$base = theme === null || theme === void 0 ? void 0 : (_theme$paginator = theme.paginator) === null || _theme$paginator === void 0 ? void 0 : _theme$paginator.baseColor) !== null && _theme$paginator$base !== void 0 ? _theme$paginator$base : paginatorTokens.backgroundColor;
165
161
  paginatorTokens.fontColor = (_theme$paginator$font = theme === null || theme === void 0 ? void 0 : (_theme$paginator2 = theme.paginator) === null || _theme$paginator2 === void 0 ? void 0 : _theme$paginator2.fontColor) !== null && _theme$paginator$font !== void 0 ? _theme$paginator$font : paginatorTokens.fontColor;
@@ -169,6 +165,12 @@ var parseTheme = function parseTheme(theme) {
169
165
  var radioTokens = componentTokensCopy.radio;
170
166
  radioTokens.color = (_theme$radio$baseColo = theme === null || theme === void 0 ? void 0 : (_theme$radio = theme.radio) === null || _theme$radio === void 0 ? void 0 : _theme$radio.baseColor) !== null && _theme$radio$baseColo !== void 0 ? _theme$radio$baseColo : radioTokens.color;
171
167
  radioTokens.disabledColor = (_setOpacity20 = setOpacity(theme === null || theme === void 0 ? void 0 : (_theme$radio2 = theme.radio) === null || _theme$radio2 === void 0 ? void 0 : _theme$radio2.baseColor, 0.34)) !== null && _setOpacity20 !== void 0 ? _setOpacity20 : radioTokens.disabledColor;
168
+ var selectTokens = componentTokensCopy.select;
169
+ selectTokens.selectedOptionBackgroundColor = (_theme$select$baseCol = theme === null || theme === void 0 ? void 0 : (_theme$select = theme.select) === null || _theme$select === void 0 ? void 0 : _theme$select.baseColor) !== null && _theme$select$baseCol !== void 0 ? _theme$select$baseCol : selectTokens.selectedOptionBackgroundColor;
170
+ selectTokens.optionFontColor = (_theme$select$fontCol = theme === null || theme === void 0 ? void 0 : (_theme$select2 = theme.select) === null || _theme$select2 === void 0 ? void 0 : _theme$select2.fontColor) !== null && _theme$select$fontCol !== void 0 ? _theme$select$fontCol : selectTokens.optionFontColor;
171
+ selectTokens.valueFontColor = (_theme$select$fontCol2 = theme === null || theme === void 0 ? void 0 : (_theme$select3 = theme.select) === null || _theme$select3 === void 0 ? void 0 : _theme$select3.fontColor) !== null && _theme$select$fontCol2 !== void 0 ? _theme$select$fontCol2 : selectTokens.valueFontColor;
172
+ selectTokens.hoverOptionBackgroundColor = (_addLightness3 = addLightness(theme === null || theme === void 0 ? void 0 : (_theme$select4 = theme.select) === null || _theme$select4 === void 0 ? void 0 : _theme$select4.baseColor, 10)) !== null && _addLightness3 !== void 0 ? _addLightness3 : selectTokens.hoverOptionBackgroundColor;
173
+ selectTokens.activeOptionBackgroundColor = (_subLightness4 = subLightness(theme === null || theme === void 0 ? void 0 : (_theme$select5 = theme.select) === null || _theme$select5 === void 0 ? void 0 : _theme$select5.baseColor, 15)) !== null && _subLightness4 !== void 0 ? _subLightness4 : selectTokens.activeOptionBackgroundColor;
172
174
  var sideNavTokens = componentTokensCopy.sidenav;
173
175
  sideNavTokens.backgroundColor = (_theme$sidenav$baseCo = theme === null || theme === void 0 ? void 0 : (_theme$sidenav = theme.sidenav) === null || _theme$sidenav === void 0 ? void 0 : _theme$sidenav.baseColor) !== null && _theme$sidenav$baseCo !== void 0 ? _theme$sidenav$baseCo : sideNavTokens.backgroundColor;
174
176
  sideNavTokens.arrowContainerColor = (_setOpacity21 = setOpacity(theme === null || theme === void 0 ? void 0 : (_theme$sidenav2 = theme.sidenav) === null || _theme$sidenav2 === void 0 ? void 0 : _theme$sidenav2.arrowBaseColor, 0.8)) !== null && _setOpacity21 !== void 0 ? _setOpacity21 : sideNavTokens.arrowContainerColor;
@@ -197,20 +199,23 @@ var parseTheme = function parseTheme(theme) {
197
199
  tabsTokens.selectedIconColor = (_theme$tabs$baseColor2 = theme === null || theme === void 0 ? void 0 : (_theme$tabs2 = theme.tabs) === null || _theme$tabs2 === void 0 ? void 0 : _theme$tabs2.baseColor) !== null && _theme$tabs$baseColor2 !== void 0 ? _theme$tabs$baseColor2 : tabsTokens.selectedIconColor;
198
200
  tabsTokens.selectedUnderlineColor = (_theme$tabs$baseColor3 = theme === null || theme === void 0 ? void 0 : (_theme$tabs3 = theme.tabs) === null || _theme$tabs3 === void 0 ? void 0 : _theme$tabs3.baseColor) !== null && _theme$tabs$baseColor3 !== void 0 ? _theme$tabs$baseColor3 : tabsTokens.selectedUnderlineColor;
199
201
  tabsTokens.focusOutline = (_theme$tabs$baseColor4 = theme === null || theme === void 0 ? void 0 : (_theme$tabs4 = theme.tabs) === null || _theme$tabs4 === void 0 ? void 0 : _theme$tabs4.baseColor) !== null && _theme$tabs$baseColor4 !== void 0 ? _theme$tabs$baseColor4 : tabsTokens.focusOutline;
200
- tabsTokens.hoverBackgroundColor = (_addLightness3 = addLightness(theme === null || theme === void 0 ? void 0 : (_theme$tabs5 = theme.tabs) === null || _theme$tabs5 === void 0 ? void 0 : _theme$tabs5.baseColor, 58)) !== null && _addLightness3 !== void 0 ? _addLightness3 : tabsTokens.hoverBackgroundColor;
201
- tabsTokens.pressedBackgroundColor = (_addLightness4 = addLightness(theme === null || theme === void 0 ? void 0 : (_theme$tabs6 = theme.tabs) === null || _theme$tabs6 === void 0 ? void 0 : _theme$tabs6.baseColor, 53)) !== null && _addLightness4 !== void 0 ? _addLightness4 : tabsTokens.pressedBackgroundColor;
202
+ tabsTokens.hoverBackgroundColor = (_addLightness4 = addLightness(theme === null || theme === void 0 ? void 0 : (_theme$tabs5 = theme.tabs) === null || _theme$tabs5 === void 0 ? void 0 : _theme$tabs5.baseColor, 58)) !== null && _addLightness4 !== void 0 ? _addLightness4 : tabsTokens.hoverBackgroundColor;
203
+ tabsTokens.pressedBackgroundColor = (_addLightness5 = addLightness(theme === null || theme === void 0 ? void 0 : (_theme$tabs6 = theme.tabs) === null || _theme$tabs6 === void 0 ? void 0 : _theme$tabs6.baseColor, 53)) !== null && _addLightness5 !== void 0 ? _addLightness5 : tabsTokens.pressedBackgroundColor;
204
+ var textInputTokens = componentTokensCopy.textInput;
205
+ textInputTokens.hoverListOptionBackgroundColor = (_theme$textInput$base = theme === null || theme === void 0 ? void 0 : (_theme$textInput = theme.textInput) === null || _theme$textInput === void 0 ? void 0 : _theme$textInput.baseColor) !== null && _theme$textInput$base !== void 0 ? _theme$textInput$base : textInputTokens.hoverListOptionBackgroundColor;
206
+ textInputTokens.activeListOptionBackgroundColor = (_subLightness7 = subLightness(theme === null || theme === void 0 ? void 0 : (_theme$textInput2 = theme.textInput) === null || _theme$textInput2 === void 0 ? void 0 : _theme$textInput2.baseColor, 15)) !== null && _subLightness7 !== void 0 ? _subLightness7 : textInputTokens.activeListOptionBackgroundColor;
202
207
  var toggleGroupTokens = componentTokensCopy.toggleGroup;
203
208
  toggleGroupTokens.selectedBackgroundColor = (_theme$toggleGroup$se = theme === null || theme === void 0 ? void 0 : (_theme$toggleGroup = theme.toggleGroup) === null || _theme$toggleGroup === void 0 ? void 0 : _theme$toggleGroup.selectedBaseColor) !== null && _theme$toggleGroup$se !== void 0 ? _theme$toggleGroup$se : buttonTokens.selectedBackgroundColor;
204
209
  toggleGroupTokens.selectedFontColor = (_theme$toggleGroup$se2 = theme === null || theme === void 0 ? void 0 : (_theme$toggleGroup2 = theme.toggleGroup) === null || _theme$toggleGroup2 === void 0 ? void 0 : _theme$toggleGroup2.selectedFontColor) !== null && _theme$toggleGroup$se2 !== void 0 ? _theme$toggleGroup$se2 : toggleGroupTokens.selectedFontColor;
205
210
  toggleGroupTokens.unselectedBackgroundColor = (_theme$toggleGroup$un = theme === null || theme === void 0 ? void 0 : (_theme$toggleGroup3 = theme.toggleGroup) === null || _theme$toggleGroup3 === void 0 ? void 0 : _theme$toggleGroup3.unselectedBaseColor) !== null && _theme$toggleGroup$un !== void 0 ? _theme$toggleGroup$un : toggleGroupTokens.unselectedBackgroundColor;
206
211
  toggleGroupTokens.unselectedActiveBackgroundColor = (_theme$toggleGroup$se3 = theme === null || theme === void 0 ? void 0 : (_theme$toggleGroup4 = theme.toggleGroup) === null || _theme$toggleGroup4 === void 0 ? void 0 : _theme$toggleGroup4.selectedBaseColor) !== null && _theme$toggleGroup$se3 !== void 0 ? _theme$toggleGroup$se3 : toggleGroupTokens.unselectedActiveBackgroundColor;
207
212
  toggleGroupTokens.unselectedFontColor = (_theme$toggleGroup$un2 = theme === null || theme === void 0 ? void 0 : (_theme$toggleGroup5 = theme.toggleGroup) === null || _theme$toggleGroup5 === void 0 ? void 0 : _theme$toggleGroup5.unselectedFontColor) !== null && _theme$toggleGroup$un2 !== void 0 ? _theme$toggleGroup$un2 : toggleGroupTokens.unselectedFontColor;
208
- toggleGroupTokens.selectedHoverBackgroundColor = (_subLightness7 = subLightness(theme === null || theme === void 0 ? void 0 : (_theme$toggleGroup6 = theme.toggleGroup) === null || _theme$toggleGroup6 === void 0 ? void 0 : _theme$toggleGroup6.selectedBaseColor, 8)) !== null && _subLightness7 !== void 0 ? _subLightness7 : buttonTokens.selectedHoverBackgroundColor;
209
- toggleGroupTokens.selectedActiveBackgroundColor = (_subLightness8 = subLightness(theme === null || theme === void 0 ? void 0 : (_theme$toggleGroup7 = theme.toggleGroup) === null || _theme$toggleGroup7 === void 0 ? void 0 : _theme$toggleGroup7.selectedBaseColor, 18)) !== null && _subLightness8 !== void 0 ? _subLightness8 : toggleGroupTokens.selectedActiveBackgroundColor;
210
- toggleGroupTokens.selectedDisabledBackgroundColor = (_addLightness5 = addLightness(theme === null || theme === void 0 ? void 0 : (_theme$toggleGroup8 = theme.toggleGroup) === null || _theme$toggleGroup8 === void 0 ? void 0 : _theme$toggleGroup8.selectedBaseColor, 57)) !== null && _addLightness5 !== void 0 ? _addLightness5 : toggleGroupTokens.selectedDisabledBackgroundColor;
211
- toggleGroupTokens.selectedDisabledFontColor = (_addLightness6 = addLightness(theme === null || theme === void 0 ? void 0 : (_theme$toggleGroup9 = theme.toggleGroup) === null || _theme$toggleGroup9 === void 0 ? void 0 : _theme$toggleGroup9.selectedBaseColor, 42)) !== null && _addLightness6 !== void 0 ? _addLightness6 : toggleGroupTokens.selectedDisabledFontColor;
212
- toggleGroupTokens.unselectedHoverBackgroundColor = (_subLightness9 = subLightness(theme === null || theme === void 0 ? void 0 : (_theme$toggleGroup10 = theme.toggleGroup) === null || _theme$toggleGroup10 === void 0 ? void 0 : _theme$toggleGroup10.unselectedBaseColor, 8)) !== null && _subLightness9 !== void 0 ? _subLightness9 : toggleGroupTokens.unselectedHoverBackgroundColor;
213
- toggleGroupTokens.unselectedDisabledBackgroundColor = (_addLightness7 = addLightness(theme === null || theme === void 0 ? void 0 : (_theme$toggleGroup11 = theme.toggleGroup) === null || _theme$toggleGroup11 === void 0 ? void 0 : _theme$toggleGroup11.unselectedBaseColor, 5)) !== null && _addLightness7 !== void 0 ? _addLightness7 : toggleGroupTokens.unselectedDisabledBackgroundColor;
213
+ toggleGroupTokens.selectedHoverBackgroundColor = (_subLightness8 = subLightness(theme === null || theme === void 0 ? void 0 : (_theme$toggleGroup6 = theme.toggleGroup) === null || _theme$toggleGroup6 === void 0 ? void 0 : _theme$toggleGroup6.selectedBaseColor, 8)) !== null && _subLightness8 !== void 0 ? _subLightness8 : buttonTokens.selectedHoverBackgroundColor;
214
+ toggleGroupTokens.selectedActiveBackgroundColor = (_subLightness9 = subLightness(theme === null || theme === void 0 ? void 0 : (_theme$toggleGroup7 = theme.toggleGroup) === null || _theme$toggleGroup7 === void 0 ? void 0 : _theme$toggleGroup7.selectedBaseColor, 18)) !== null && _subLightness9 !== void 0 ? _subLightness9 : toggleGroupTokens.selectedActiveBackgroundColor;
215
+ toggleGroupTokens.selectedDisabledBackgroundColor = (_addLightness6 = addLightness(theme === null || theme === void 0 ? void 0 : (_theme$toggleGroup8 = theme.toggleGroup) === null || _theme$toggleGroup8 === void 0 ? void 0 : _theme$toggleGroup8.selectedBaseColor, 57)) !== null && _addLightness6 !== void 0 ? _addLightness6 : toggleGroupTokens.selectedDisabledBackgroundColor;
216
+ toggleGroupTokens.selectedDisabledFontColor = (_addLightness7 = addLightness(theme === null || theme === void 0 ? void 0 : (_theme$toggleGroup9 = theme.toggleGroup) === null || _theme$toggleGroup9 === void 0 ? void 0 : _theme$toggleGroup9.selectedFontColor, 42)) !== null && _addLightness7 !== void 0 ? _addLightness7 : toggleGroupTokens.selectedDisabledFontColor;
217
+ toggleGroupTokens.unselectedHoverBackgroundColor = (_subLightness10 = subLightness(theme === null || theme === void 0 ? void 0 : (_theme$toggleGroup10 = theme.toggleGroup) === null || _theme$toggleGroup10 === void 0 ? void 0 : _theme$toggleGroup10.unselectedBaseColor, 8)) !== null && _subLightness10 !== void 0 ? _subLightness10 : toggleGroupTokens.unselectedHoverBackgroundColor;
218
+ toggleGroupTokens.unselectedDisabledBackgroundColor = (_addLightness8 = addLightness(theme === null || theme === void 0 ? void 0 : (_theme$toggleGroup11 = theme.toggleGroup) === null || _theme$toggleGroup11 === void 0 ? void 0 : _theme$toggleGroup11.unselectedBaseColor, 5)) !== null && _addLightness8 !== void 0 ? _addLightness8 : toggleGroupTokens.unselectedDisabledBackgroundColor;
214
219
  toggleGroupTokens.unselectedDisabledFontColor = (_setOpacity27 = setOpacity(theme === null || theme === void 0 ? void 0 : (_theme$toggleGroup12 = theme.toggleGroup) === null || _theme$toggleGroup12 === void 0 ? void 0 : _theme$toggleGroup12.unselectedFontColor, 0.34)) !== null && _setOpacity27 !== void 0 ? _setOpacity27 : toggleGroupTokens.unselectedDisabledFontColor;
215
220
  var wizardTokens = componentTokensCopy.wizard;
216
221
  wizardTokens.stepContainerSelectedBackgroundColor = (_theme$wizard$baseCol = theme === null || theme === void 0 ? void 0 : (_theme$wizard = theme.wizard) === null || _theme$wizard === void 0 ? void 0 : _theme$wizard.baseColor) !== null && _theme$wizard$baseCol !== void 0 ? _theme$wizard$baseCol : wizardTokens.stepContainerSelectedBackgroundColor;
@@ -218,13 +223,16 @@ var parseTheme = function parseTheme(theme) {
218
223
  return componentTokensCopy;
219
224
  };
220
225
 
221
- var ThemeProvider = function ThemeProvider(props) {
226
+ var ThemeProvider = function ThemeProvider(_ref) {
227
+ var theme = _ref.theme,
228
+ advancedTheme = _ref.advancedTheme,
229
+ children = _ref.children;
222
230
  var parsedTheme = (0, _react.useMemo)(function () {
223
- if ("theme" in props) return parseTheme(props.theme);else if ("advancedTheme" in props) return parseAdvancedTheme(props.advancedTheme);
224
- }, ["theme" in props ? props.theme : props.advancedTheme]);
231
+ return theme && parseTheme(theme) || advancedTheme && parseAdvancedTheme(advancedTheme);
232
+ }, [theme, advancedTheme]);
225
233
  return /*#__PURE__*/_react["default"].createElement(Halstack, null, /*#__PURE__*/_react["default"].createElement(ThemeContext.Provider, {
226
234
  value: parsedTheme
227
- }, props.children));
235
+ }, children));
228
236
  };
229
237
 
230
238
  exports.ThemeProvider = ThemeProvider;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _react = _interopRequireDefault(require("react"));
6
+
7
+ var _react2 = require("@testing-library/react");
8
+
9
+ var _Accordion = _interopRequireDefault(require("./Accordion"));
10
+
11
+ describe("Accordion component tests", function () {
12
+ test("Accordion renders with correct text", function () {
13
+ var onChange = jest.fn();
14
+
15
+ var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Accordion["default"], {
16
+ label: "Accordion",
17
+ onChange: onChange
18
+ })),
19
+ getByText = _render.getByText;
20
+
21
+ expect(getByText("Accordion")).toBeTruthy();
22
+ });
23
+ test("Calls correct function on click", function () {
24
+ var onChange = jest.fn();
25
+
26
+ var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Accordion["default"], {
27
+ label: "Accordion",
28
+ onChange: onChange
29
+ })),
30
+ getByText = _render2.getByText;
31
+
32
+ _react2.fireEvent.click(getByText("Accordion"));
33
+
34
+ expect(onChange).toHaveBeenCalled();
35
+ });
36
+ test("Controlled accordion", function () {
37
+ var onChange = jest.fn();
38
+
39
+ var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Accordion["default"], {
40
+ label: "Accordion",
41
+ onChange: onChange,
42
+ isExpanded: true
43
+ })),
44
+ getByText = _render3.getByText;
45
+
46
+ _react2.fireEvent.click(getByText("Accordion"));
47
+
48
+ _react2.fireEvent.click(getByText("Accordion"));
49
+
50
+ _react2.fireEvent.click(getByText("Accordion"));
51
+
52
+ expect(onChange).toHaveBeenCalledTimes(3);
53
+ expect(onChange.mock.calls[0][0]).toBe(false);
54
+ expect(onChange.mock.calls[1][0]).toBe(false);
55
+ expect(onChange.mock.calls[2][0]).toBe(false);
56
+ });
57
+ });
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _react = _interopRequireDefault(require("react"));
6
+
7
+ var _react2 = require("@testing-library/react");
8
+
9
+ var _AccordionGroup = _interopRequireDefault(require("./AccordionGroup"));
10
+
11
+ describe("Accordion component tests", function () {
12
+ test("Uncontrolled accordion group renders with children", function () {
13
+ var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"], null, /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"].Accordion, {
14
+ label: "Accordion1",
15
+ padding: "medium"
16
+ }, /*#__PURE__*/_react["default"].createElement("div", null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo lobortis eget.")), /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"].Accordion, {
17
+ label: "Accordion2",
18
+ padding: "medium"
19
+ }, /*#__PURE__*/_react["default"].createElement("div", null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo lobortis eget.")))),
20
+ getByText = _render.getByText,
21
+ getAllByRole = _render.getAllByRole;
22
+
23
+ expect(getByText("Accordion1")).toBeTruthy();
24
+ expect(getByText("Accordion2")).toBeTruthy();
25
+ expect(getAllByRole("button")[0].getAttribute("aria-expanded")).toBe("false");
26
+ expect(getAllByRole("button")[1].getAttribute("aria-expanded")).toBe("false");
27
+ });
28
+ test("Uncontrolled accordion group renders with only one children", function () {
29
+ var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"], null, /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"].Accordion, {
30
+ label: "Accordion1",
31
+ padding: "medium"
32
+ }, /*#__PURE__*/_react["default"].createElement("div", null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo lobortis eget.")))),
33
+ getByText = _render2.getByText,
34
+ getAllByRole = _render2.getAllByRole;
35
+
36
+ expect(getByText("Accordion1")).toBeTruthy();
37
+ expect(getAllByRole("button")[0].getAttribute("aria-expanded")).toBe("false");
38
+ });
39
+ test("Uncontrolled accordion group calls correct function on click", function () {
40
+ var onActiveChange = jest.fn();
41
+
42
+ var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"], {
43
+ margin: "large",
44
+ onActiveChange: onActiveChange
45
+ }, /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"].Accordion, {
46
+ label: "Accordion1",
47
+ padding: "medium",
48
+ margin: "large"
49
+ }, /*#__PURE__*/_react["default"].createElement("div", null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo lobortis eget.")), /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"].Accordion, {
50
+ label: "Accordion2",
51
+ padding: "medium"
52
+ }, /*#__PURE__*/_react["default"].createElement("div", null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo lobortis eget.")))),
53
+ getByText = _render3.getByText,
54
+ getAllByRole = _render3.getAllByRole;
55
+
56
+ expect(getAllByRole("button")[0].getAttribute("aria-expanded")).toBe("false");
57
+ expect(getAllByRole("button")[1].getAttribute("aria-expanded")).toBe("false");
58
+
59
+ _react2.fireEvent.click(getByText("Accordion1"));
60
+
61
+ expect(onActiveChange).toHaveBeenCalled();
62
+ expect(getAllByRole("button")[0].getAttribute("aria-expanded")).toBe("true");
63
+ expect(getAllByRole("button")[1].getAttribute("aria-expanded")).toBe("false");
64
+ });
65
+ test("Controlled accordion with indexActive change", function () {
66
+ var onActiveChange = jest.fn();
67
+
68
+ var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"], {
69
+ margin: "large",
70
+ indexActive: 1,
71
+ onActiveChange: onActiveChange
72
+ }, /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"].Accordion, {
73
+ label: "Accordion1",
74
+ padding: "medium",
75
+ margin: "large"
76
+ }, /*#__PURE__*/_react["default"].createElement("div", null, "Text1")), /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"].Accordion, {
77
+ label: "Accordion2",
78
+ padding: "medium"
79
+ }, /*#__PURE__*/_react["default"].createElement("div", null, "Text2")))),
80
+ getByText = _render4.getByText,
81
+ getAllByRole = _render4.getAllByRole,
82
+ rerender = _render4.rerender;
83
+
84
+ expect(getByText("Text1")).toBeTruthy();
85
+ expect(getByText("Text2")).toBeTruthy();
86
+
87
+ _react2.fireEvent.click(getByText("Accordion1"));
88
+
89
+ _react2.fireEvent.click(getByText("Accordion2"));
90
+
91
+ expect(onActiveChange.mock.calls[0][0]).toBe(0);
92
+ expect(onActiveChange.mock.calls[1][0]).toBe(1);
93
+ expect(getAllByRole("button")[0].getAttribute("aria-expanded")).toBe("false");
94
+ expect(getAllByRole("button")[1].getAttribute("aria-expanded")).toBe("true");
95
+ rerender( /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"], {
96
+ margin: "large",
97
+ indexActive: 0,
98
+ onActiveChange: onActiveChange
99
+ }, /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"].Accordion, {
100
+ label: "Accordion1",
101
+ padding: "medium",
102
+ margin: "large"
103
+ }, /*#__PURE__*/_react["default"].createElement("div", null, "Text1")), /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"].Accordion, {
104
+ label: "Accordion2",
105
+ padding: "medium"
106
+ }, /*#__PURE__*/_react["default"].createElement("div", null, "Text2"))));
107
+ expect(getAllByRole("button")[0].getAttribute("aria-expanded")).toBe("true");
108
+ expect(getAllByRole("button")[1].getAttribute("aria-expanded")).toBe("false");
109
+ });
110
+ test("Disabled uncontrolled accordion group", function () {
111
+ var onActiveChange = jest.fn();
112
+
113
+ var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"], {
114
+ margin: "large",
115
+ onActiveChange: onActiveChange,
116
+ disabled: true
117
+ }, /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"].Accordion, {
118
+ label: "Accordion1",
119
+ padding: "medium",
120
+ margin: "large"
121
+ }, /*#__PURE__*/_react["default"].createElement("div", null, "Text1")), /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"].Accordion, {
122
+ label: "Accordion2",
123
+ padding: "medium"
124
+ }, /*#__PURE__*/_react["default"].createElement("div", null, "Text2")))),
125
+ getByText = _render5.getByText;
126
+
127
+ _react2.fireEvent.click(getByText("Accordion1"));
128
+
129
+ _react2.fireEvent.click(getByText("Accordion2"));
130
+
131
+ expect(onActiveChange).toHaveBeenCalledTimes(0);
132
+ });
133
+ });
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _react = _interopRequireDefault(require("react"));
6
+
7
+ var _react2 = require("@testing-library/react");
8
+
9
+ var _Alert = _interopRequireDefault(require("./Alert"));
10
+
11
+ describe("Alert component tests", function () {
12
+ test("Info alert renders with correct text", function () {
13
+ var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
14
+ type: "info",
15
+ inlineText: "info-alert-text"
16
+ })),
17
+ getByText = _render.getByText;
18
+
19
+ expect(getByText("information")).toBeTruthy();
20
+ expect(getByText("info-alert-text")).toBeTruthy();
21
+ });
22
+ test("Confirm alert renders with correct text", function () {
23
+ var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
24
+ type: "confirm",
25
+ inlineText: "confirm-alert-text"
26
+ })),
27
+ getByText = _render2.getByText;
28
+
29
+ expect(getByText("success")).toBeTruthy();
30
+ expect(getByText("confirm-alert-text")).toBeTruthy();
31
+ });
32
+ test("Warning alert renders with correct text", function () {
33
+ var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
34
+ type: "warning",
35
+ inlineText: "warning-alert-text"
36
+ })),
37
+ getByText = _render3.getByText;
38
+
39
+ expect(getByText("warning")).toBeTruthy();
40
+ expect(getByText("warning-alert-text")).toBeTruthy();
41
+ });
42
+ test("Error alert renders with correct text", function () {
43
+ var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
44
+ type: "error",
45
+ inlineText: "error-alert-text"
46
+ })),
47
+ getByText = _render4.getByText;
48
+
49
+ expect(getByText("error")).toBeTruthy();
50
+ expect(getByText("error-alert-text")).toBeTruthy();
51
+ });
52
+ test("Alert renders with correct children", function () {
53
+ var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
54
+ inlineText: "alert-text"
55
+ }, /*#__PURE__*/_react["default"].createElement("p", null, "sample-children"))),
56
+ getByText = _render5.getByText;
57
+
58
+ expect(getByText("alert-text")).toBeTruthy();
59
+ expect(getByText("sample-children")).toBeTruthy();
60
+ });
61
+ test("Calls correct function on close", function () {
62
+ var onClose = jest.fn();
63
+
64
+ var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
65
+ onClose: onClose,
66
+ inlineText: "info-alert-text"
67
+ })),
68
+ getByRole = _render6.getByRole;
69
+
70
+ var closeButton = getByRole("button");
71
+
72
+ _react2.fireEvent.click(closeButton);
73
+
74
+ expect(onClose).toHaveBeenCalled();
75
+ });
76
+ test("Modal alert calls correct function on close", function () {
77
+ var onClose = jest.fn();
78
+
79
+ var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
80
+ onClose: onClose,
81
+ mode: "modal",
82
+ inlineText: "info-alert-text"
83
+ })),
84
+ getByRole = _render7.getByRole;
85
+
86
+ var closeButton = getByRole("button");
87
+
88
+ _react2.fireEvent.click(closeButton);
89
+
90
+ expect(onClose).toHaveBeenCalled();
91
+ });
92
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _react = _interopRequireDefault(require("react"));
6
+
7
+ var _react2 = require("@testing-library/react");
8
+
9
+ var _Card = _interopRequireDefault(require("../card/Card"));
10
+
11
+ describe("Box component tests", function () {
12
+ test("Box renders with correct text", function () {
13
+ var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], null, "test-box")),
14
+ getByText = _render.getByText;
15
+
16
+ expect(getByText("test-box")).toBeTruthy();
17
+ });
18
+ });
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _react = _interopRequireDefault(require("react"));
6
+
7
+ var _react2 = require("@testing-library/react");
8
+
9
+ var _Button = _interopRequireDefault(require("./Button"));
10
+
11
+ describe("Button component tests", function () {
12
+ test("Button renders with correct text", function () {
13
+ var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
14
+ label: "Button"
15
+ })),
16
+ getByText = _render.getByText;
17
+
18
+ expect(getByText("Button")).toBeTruthy();
19
+ });
20
+ test("Calls correct function on click", function () {
21
+ var onClick = jest.fn();
22
+
23
+ var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
24
+ label: "Button",
25
+ onClick: onClick
26
+ })),
27
+ getByText = _render2.getByText;
28
+
29
+ var button = getByText("Button");
30
+
31
+ _react2.fireEvent.click(button);
32
+
33
+ expect(onClick).toHaveBeenCalled();
34
+ });
35
+ });
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _react = _interopRequireDefault(require("react"));
6
+
7
+ var _react2 = require("@testing-library/react");
8
+
9
+ var _Card = _interopRequireDefault(require("./Card"));
10
+
11
+ describe("Card component tests", function () {
12
+ test("Card renders with correct content", function () {
13
+ var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], null, "test-card")),
14
+ getByText = _render.getByText;
15
+
16
+ expect(getByText("test-card")).toBeTruthy();
17
+ });
18
+ test("Card renders with correct href", function () {
19
+ var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], {
20
+ linkHref: "/testPage"
21
+ }, "test-card")),
22
+ getByRole = _render2.getByRole;
23
+
24
+ var card = getByRole("link");
25
+ expect(card.getAttribute("href")).toEqual("/testPage");
26
+ });
27
+ test("Card renders with correct image", function () {
28
+ var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], {
29
+ imageSrc: "/testImage"
30
+ }, "test-card")),
31
+ getByRole = _render3.getByRole;
32
+
33
+ var card = getByRole("img");
34
+ expect(card.getAttribute("src")).toEqual("/testImage");
35
+ });
36
+ test("OnClick function is called", function () {
37
+ var onClick = jest.fn();
38
+
39
+ var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Card["default"], {
40
+ onClick: onClick
41
+ }, "test-card")),
42
+ getByText = _render4.getByText;
43
+
44
+ var card = getByText("test-card");
45
+
46
+ _react2.fireEvent.click(card);
47
+
48
+ expect(onClick).toHaveBeenCalled();
49
+ });
50
+ });
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _react = _interopRequireDefault(require("react"));
6
+
7
+ var _react2 = require("@testing-library/react");
8
+
9
+ var _Checkbox = _interopRequireDefault(require("./Checkbox"));
10
+
11
+ describe("Checkbox component tests", function () {
12
+ test("Checkbox renders with correct text", function () {
13
+ var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
14
+ label: "Checkbox"
15
+ })),
16
+ getByText = _render.getByText;
17
+
18
+ expect(getByText("Checkbox")).toBeTruthy();
19
+ });
20
+ test("Calls correct function on click", function () {
21
+ var onChange = jest.fn();
22
+
23
+ var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
24
+ label: "Checkbox",
25
+ onChange: onChange
26
+ })),
27
+ getByText = _render2.getByText;
28
+
29
+ _react2.fireEvent.click(getByText("Checkbox"));
30
+
31
+ expect(onChange).toHaveBeenCalled();
32
+ });
33
+ test("Uncontrolled checkbox", function () {
34
+ var onChange = jest.fn();
35
+ var component = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
36
+ label: "Checkbox",
37
+ onChange: onChange
38
+ }));
39
+ var visibleCheckbox = component.getByText("Checkbox");
40
+ var input = component.getByRole("checkbox");
41
+ expect(input.checked).toBe(false);
42
+
43
+ _react2.fireEvent.click(visibleCheckbox);
44
+
45
+ expect(onChange).toHaveBeenCalled();
46
+ expect(onChange).toHaveBeenCalledWith(true);
47
+ expect(input.checked).toBe(true);
48
+ });
49
+ test("Controlled checkbox", function () {
50
+ var onChange = jest.fn();
51
+ var component = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
52
+ label: "Checkbox",
53
+ checked: false,
54
+ onChange: onChange
55
+ }));
56
+ var input = component.getByRole("checkbox");
57
+ var visibleCheckbox = component.getByText("Checkbox");
58
+
59
+ _react2.fireEvent.click(visibleCheckbox);
60
+
61
+ expect(onChange).toHaveBeenCalled();
62
+ expect(onChange).toHaveBeenCalledWith(true);
63
+ expect(input.checked).toBe(false);
64
+ });
65
+ });