@bytebrand/fe-ui-core 4.8.46 → 4.8.48

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 (190) hide show
  1. package/bytebrand-fe-ui-core-4.8.47.tgz +0 -0
  2. package/media/locales/de/promoSlider.json +0 -1
  3. package/media/locales/en/promoSlider.json +0 -1
  4. package/package.json +5 -3
  5. package/source/components/AccordionWidget/AccordionWidget.styl +0 -1
  6. package/source/components/AccordionWidget/AccordionWidget.tsx +4 -8
  7. package/source/components/VehicleDetailedSidebar/VehicleDetailedSidebar.tsx +11 -23
  8. package/source/components/VehicleDetailedSlider/VehicleDetailedSlider.tsx +6 -1
  9. package/source/components/VehicleDetailedSlider/partials/PriceData.tsx +9 -8
  10. package/source/components/VehicleSmallCard/VehicleData/VechiclePriceItem/VechiclePriceItem.styl +0 -5
  11. package/source/components/VehicleSmallCard/VehicleData/VechiclePriceItem/VechiclePriceItem.tsx +1 -3
  12. package/source/components/VehicleSmallCard/VehicleData/VehicleInfo/VehicleInfo.styl +1 -1
  13. package/source/components/VehicleSmallCard/VehicleData/VehicleInfo/VehicleInfo.tsx +11 -24
  14. package/source/components/VehicleSmallCard/VehicleData/VehiclePrice/VehiclePrice.styl +2 -3
  15. package/source/components/VehicleSmallCard/VehicleData/VehicleProperty/VehicleProperty.styl +1 -4
  16. package/source/components/VehicleSmallCard/VehicleData/VehicleProperty/VehicleProperty.tsx +2 -3
  17. package/source/components/VehicleSmallCard/VehicleData/VehicleTitle/VehicleTitle.tsx +1 -1
  18. package/source/components/VehicleSmallCard/VehicleSmallCard.tsx +6 -15
  19. package/source/components/_common/MaterialAccordionGroup/MaterialAccordionGroup.styled.tsx +1 -4
  20. package/source/components/_common/withStats/withStats.styl +21 -0
  21. package/source/components/_common/withStats/withStats.tsx +21 -4
  22. package/source/framework/DataTransformers.ts +0 -1
  23. package/source/framework/constants/common.ts +4 -8
  24. package/source/framework/types/types.ts +0 -1
  25. package/source/framework/vehiclesProps/decoratedLightProps.tsx +12 -48
  26. package/source/framework/vehiclesProps/decoratedProps.tsx +8 -35
  27. package/source/locales/data.ts +5 -4
  28. package/.husky/pre-push +0 -4
  29. package/.storybook/addons.js +0 -4
  30. package/.storybook/config.js +0 -64
  31. package/.storybook/postcss.config.js +0 -6
  32. package/.storybook/preview-head.html +0 -10
  33. package/.storybook/webpack.config.js +0 -130
  34. package/__tests__/components/Checkout/OrderOverviewItem/OrderOverviewItem.test.tsx +0 -42
  35. package/__tests__/components/Checkout/PaymentTypeCard/PaymentTypeCard.test.tsx +0 -50
  36. package/__tests__/components/Checkout/RadioGroup.test.tsx +0 -95
  37. package/__tests__/components/Checkout/ServiceCardWrapper.test.tsx +0 -53
  38. package/__tests__/components/Checkout/Switcher.test.tsx +0 -43
  39. package/__tests__/components/UserDasboardPage/sections/CheckoutSection/CheckoutSection.test.tsx +0 -613
  40. package/__tests__/components/UserDasboardPage/sections/FavoriteSection/FavoriteSection.test.tsx +0 -335
  41. package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/AdditionalOrderInfo.test.tsx +0 -127
  42. package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/OrderStatusCar.test.tsx +0 -58
  43. package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/OrderStatusCard.test.tsx +0 -74
  44. package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/OrderStatusSection.test.tsx +0 -62
  45. package/__tests__/components/UserDasboardPage/sections/RequestedCarsSection/RequestedCarsSection.test.tsx +0 -117
  46. package/__tests__/components/Vehicle/VehicleFormattedPrice/VehicleFormattedPrice.test.tsx +0 -58
  47. package/__tests__/components/VehicleSmallCard/VehicleInfo.test.tsx +0 -88
  48. package/__tests__/components/VehicleSmallCard/VehicleTitle.test.tsx +0 -91
  49. package/__tests__/components/_common/Badge/Badge.test.tsx +0 -15
  50. package/__tests__/components/_common/IconSVG/IconSVG.test.tsx +0 -23
  51. package/__tests__/components/_common/Image/Image.test.tsx +0 -82
  52. package/__tests__/components/_common/MaterialAutocomplete/MaterialAutocomplete.test.tsx +0 -49
  53. package/__tests__/components/_common/MaterialDatePicker/MaterialDatePicker.test.tsx +0 -54
  54. package/__tests__/components/_common/MaterialField/MaterialField.test.tsx +0 -58
  55. package/__tests__/components/_common/StarButton/StarButton.test.tsx +0 -46
  56. package/__tests__/mockedData/financingConfig.js +0 -202
  57. package/__tests__/mockedData/mockedPendingRequestedCar.js +0 -69
  58. package/__tests__/utils/CommonUtils/addPrefixToKeys.test.ts +0 -18
  59. package/__tests__/utils/CommonUtils/arrToObj.test.js +0 -32
  60. package/__tests__/utils/CommonUtils/checkRangeValuesOnEqual.test.ts +0 -17
  61. package/__tests__/utils/CommonUtils/fixNumber.test.ts +0 -20
  62. package/__tests__/utils/CommonUtils/formatMileage.test.ts +0 -8
  63. package/__tests__/utils/CommonUtils/getChipFilterValue.test.ts +0 -22
  64. package/__tests__/utils/CommonUtils/getFormattedNumber.test.ts +0 -19
  65. package/__tests__/utils/CommonUtils/getFormattedPrice.test.ts +0 -19
  66. package/__tests__/utils/CommonUtils/getGroupValuesForQuery.test.ts +0 -51
  67. package/__tests__/utils/CommonUtils/getOfferSliders.test.ts +0 -64
  68. package/__tests__/utils/CommonUtils/getPriceRating.test.ts +0 -26
  69. package/__tests__/utils/CommonUtils/getPriceRatingConfig.test.ts +0 -33
  70. package/__tests__/utils/CommonUtils/preloadNearbyImages.test.ts +0 -9
  71. package/__tests__/utils/CommonUtils/sliceLessThan.test.ts +0 -23
  72. package/__tests__/utils/CommonUtils/sliceMoreThan.test.ts +0 -23
  73. package/source/components/AdvantageItem/AdvantageItem.story.js +0 -23
  74. package/source/components/Alternative/Dealer.story.js +0 -32
  75. package/source/components/Alternative/Dealer.story.styl +0 -3
  76. package/source/components/Breadcrumbs/Breadcrumbs.story.js +0 -40
  77. package/source/components/Breadcrumbs/FirstInfoBlock/FirstInfoBlock.story.js +0 -45
  78. package/source/components/Checkout/OrderOverviewItem/OrderOverviewItem.story.js +0 -243
  79. package/source/components/Checkout/OrderOverviewItem/OrderOverviewItem.story.styl +0 -21
  80. package/source/components/Checkout/RadioCards/RadioGroupCheckout.story.js +0 -105
  81. package/source/components/Checkout/RadioCards/RadioGroupCheckout.story.styl +0 -37
  82. package/source/components/Checkout/Switcher/Switcher.story.js +0 -41
  83. package/source/components/Checkout/Switcher/Switcher.story.styl +0 -2
  84. package/source/components/CompactSearchWidget/CompactSearchWidget.story.js +0 -187
  85. package/source/components/ContactForm/ContactForm.story.js +0 -94
  86. package/source/components/ContactForm/ContactForm.story.styl +0 -0
  87. package/source/components/ContactInfo/ContactInfo.story.js +0 -58
  88. package/source/components/CustomerQuote/CustomerQuote.story.js +0 -41
  89. package/source/components/CustomerQuotesSlider/CustomerQuotesSlider.story.js +0 -73
  90. package/source/components/CustomerQuotesSlider/CustomerQuotesSlider.story.styl +0 -5
  91. package/source/components/FormattedNumber/FormattedNumber.story.js +0 -114
  92. package/source/components/InfoBlocks/InfoBlockWrapper.story.js +0 -101
  93. package/source/components/InfoBlocks/InfoBlockWrapper.story.styl +0 -46
  94. package/source/components/OfferPanel/AboAccordion/AboFaq/AboFaq.story.js +0 -97
  95. package/source/components/OfferPanel/OfferPanel.story.js +0 -139
  96. package/source/components/OfferPanel/RangeGroup/RangeGroup.story.js +0 -35
  97. package/source/components/OfferPanel/RangeGroup/RangeGroup.story.styl +0 -3
  98. package/source/components/PriceRating/PriceRating.story.js +0 -39
  99. package/source/components/PriceRating/PriceRating.story.styl +0 -2
  100. package/source/components/PriceRatingDetailed/PriceRatingDetailed.story.js +0 -78
  101. package/source/components/PriceRatingDetailed/PriceRatingDetailed.story.styl +0 -11
  102. package/source/components/RateSearchValue/RateSearchValue.story.js +0 -78
  103. package/source/components/RateSearchValue/RateSearchValue.story.styl +0 -2
  104. package/source/components/RateSearchWidget/RateSearchWidget.story.js +0 -57
  105. package/source/components/RateSearchWidget/RateSearchWidget.story.styl +0 -12
  106. package/source/components/SearchFilters/FiltersFactory.story.js +0 -273
  107. package/source/components/SearchPage/Filters/MakeModel/MakeModel.story.js +0 -12
  108. package/source/components/SearchWidget/BasicDataWidget/BasicDataWidget.story.js +0 -834
  109. package/source/components/SearchWidget/BasicDataWidget/BasicDataWidget.story.styl +0 -40
  110. package/source/components/SearchWidget/SearchWidget.story.js +0 -191
  111. package/source/components/SearchWidget/SearchWidget.story.styl +0 -6
  112. package/source/components/Stepper/Stepper.story.js +0 -119
  113. package/source/components/Stepper/Stepper.story.styl +0 -41
  114. package/source/components/Theme.story.js +0 -36
  115. package/source/components/Theme.story.styl +0 -85
  116. package/source/components/TickerText/TickerText.story.js +0 -17
  117. package/source/components/UserDashboardPage/sections/OrderStatusSection/OrderStatusSection.story.js +0 -95
  118. package/source/components/UserDashboardPage/sections/RequestedCarsSection/RequestedCarsSection.story.js +0 -97
  119. package/source/components/Vehicle/VehicleConsumption/VehicleConsumption.story.js +0 -31
  120. package/source/components/Vehicle/VehicleFormattedPrice/VehicleFormattedPrice.story.js +0 -247
  121. package/source/components/VehicleCompared/CompareGeneral/CompareGeneral.story.js +0 -30
  122. package/source/components/VehicleCompared/ComparePrice/ComparePrice.story.js +0 -18
  123. package/source/components/VehicleCompared/CompareTitle/CompareTitle.story.js +0 -19
  124. package/source/components/VehicleDetailedSidebar/VehicleDetailedSidebar.story.js +0 -44
  125. package/source/components/VehicleDetailedSlider/VehicleDetailedSlider.story.js +0 -120
  126. package/source/components/VehiclePromoSlider/VehiclePromoInfo/VehiclePromoInfo.story.js +0 -42
  127. package/source/components/VehiclePromoSlider/VehiclePromoSlide/VehiclePromoSlide.story.js +0 -62
  128. package/source/components/VehiclePromoSlider/VehiclePromoSlider.story.js +0 -42
  129. package/source/components/VehicleSmallCard/VehicleSmallCard.story.js +0 -412
  130. package/source/components/VehicleSmallCard/VehicleSmallCard.story.styl +0 -56
  131. package/source/components/VehicleSmallCardForDealerships/VehicleSmallCardForDealerships.story.js +0 -199
  132. package/source/components/VehicleSmallCardForDealerships/VehicleSmallCardForDealerships.story.styl +0 -40
  133. package/source/components/_common/Accordion/Accordion.story.js +0 -36
  134. package/source/components/_common/Badge/Badge.story.js +0 -27
  135. package/source/components/_common/Badge/Badge.story.styl +0 -5
  136. package/source/components/_common/Bubble/Bubble.story.js +0 -52
  137. package/source/components/_common/Button/Button.story.js +0 -52
  138. package/source/components/_common/Button/Button.story.styl +0 -5
  139. package/source/components/_common/ButtonOld/Button.story.js +0 -54
  140. package/source/components/_common/ButtonOld/Button.story.styl +0 -5
  141. package/source/components/_common/Checkbox/Checkbox.story.js +0 -85
  142. package/source/components/_common/Checkbox/Checkbox.story.styl +0 -14
  143. package/source/components/_common/CheckboxMaterial/CheckboxMaterial.story.js +0 -126
  144. package/source/components/_common/CheckboxMaterial/CheckboxMaterial.story.styl +0 -14
  145. package/source/components/_common/Chip/Chip.story.js +0 -43
  146. package/source/components/_common/ChipList/ChipList.story.js +0 -36
  147. package/source/components/_common/DropDown/DropDown.story.js +0 -35
  148. package/source/components/_common/ExpandablePanel/ExpandablePanel.story.js +0 -41
  149. package/source/components/_common/Histogram/Histogram.story.js +0 -51
  150. package/source/components/_common/IconSVG/IconSVG.story.js +0 -21
  151. package/source/components/_common/IconSVG/IconSVG.story.styl +0 -25
  152. package/source/components/_common/Image/Image.story.js +0 -142
  153. package/source/components/_common/Image/Image.story.styl +0 -18
  154. package/source/components/_common/ImagesSet/ImagesSet.story.js +0 -34
  155. package/source/components/_common/ImagesSet/ImagesSet.story.styl +0 -4
  156. package/source/components/_common/Loader/Loader.story.js +0 -21
  157. package/source/components/_common/MaterialAccordionGroup/MaterialAccordionGroup.story.js +0 -49
  158. package/source/components/_common/MaterialDatePicker/MaterialDatePicker.story.js +0 -45
  159. package/source/components/_common/MaterialDatePicker/MaterialDatePicker.story.styl +0 -6
  160. package/source/components/_common/MaterialField/MaterialField.story.js +0 -87
  161. package/source/components/_common/MaterialField/MaterialField.story.styl +0 -34
  162. package/source/components/_common/MaterialSelect/MaterialSelect.story.js +0 -52
  163. package/source/components/_common/MaterialSelect/MaterialSelect.story.styl +0 -6
  164. package/source/components/_common/MaterialStepButton/MaterialStepButton.story.js +0 -47
  165. package/source/components/_common/MaterialStepButton/MaterialStepButton.story.styl +0 -6
  166. package/source/components/_common/MaterialSwitch/MaterialSwitch.story.js +0 -17
  167. package/source/components/_common/MaterialTooltip/MaterialTooltip.story.js +0 -10
  168. package/source/components/_common/Modal/Modal.story.js +0 -37
  169. package/source/components/_common/MuiGroupedSelect/MuiGroupedSelect.story.js +0 -21
  170. package/source/components/_common/PropertySelector/PSGroup.story.js +0 -93
  171. package/source/components/_common/PropertySelector/PSGroup.story.styl +0 -25
  172. package/source/components/_common/PropertySelector/ProperySelector.story.js +0 -83
  173. package/source/components/_common/Radio/FormRadioGroup.story.js +0 -28
  174. package/source/components/_common/Radio/FormRadioGroup.story.styl +0 -2
  175. package/source/components/_common/Radio/Radio.story.js +0 -54
  176. package/source/components/_common/Radio/RadioGroup.story.js +0 -90
  177. package/source/components/_common/Radio/RadioGroup.story.styl +0 -39
  178. package/source/components/_common/Range/Range.story.js +0 -46
  179. package/source/components/_common/Range/Range.story.styl +0 -5
  180. package/source/components/_common/SliderArrow/SliderArrow.story.js +0 -18
  181. package/source/components/_common/Tabs/Tabs.story.js +0 -56
  182. package/source/components/_common/TimePicker/TimePicker.story.js +0 -37
  183. package/source/components/_common/Tooltip/Tooltip.story.js +0 -28
  184. package/source/components/_common/UserMenu/MaterialMenu.story.js +0 -73
  185. package/source/components/_common/VehicleSlider/VehicleSlider.story.js +0 -99
  186. package/source/components/_common/VehicleSlider/VehicleSlider.story.styl +0 -0
  187. package/source/components/_common/withLabel/withLabel.story.js +0 -62
  188. package/source/components/_common/withPopover/withPopover.story.js +0 -48
  189. package/source/components/_common/withPopover/withPopover.story.styl +0 -54
  190. package/source/components/_common/withStats/withStats.story.js +0 -75
@@ -1,50 +0,0 @@
1
- import React from 'react';
2
- import { render, fireEvent } from '@testing-library/react';
3
- import PaymentTypeCard from '../../../../source/components/Checkout/RadioCards/PaymentTypeCard/PaymentTypeCard';
4
-
5
- describe('PaymentTypeCard', () => {
6
- it('should render correctly', () => {
7
- const { getByText } = render(<PaymentTypeCard value="test-value" label="Test Label" />);
8
- expect(getByText('Test Label')).toBeInTheDocument();
9
- });
10
-
11
- it('should handle onChange event correctly', () => {
12
- const handleChange = jest.fn();
13
- const { getByRole } = render(<PaymentTypeCard value="test-value" label="Test Label" onChange={handleChange} />);
14
- fireEvent.click(getByRole('radio'));
15
- expect(handleChange).toHaveBeenCalledTimes(1);
16
- });
17
-
18
- it('should handle onChange event correctly if we have checkbox="true"', () => {
19
- const handleChange = jest.fn();
20
- const { getByRole } = render(
21
- <PaymentTypeCard
22
- checkbox
23
- value="test-value"
24
- label="Test Label"
25
- onChange={handleChange}
26
- />
27
- );
28
- fireEvent.click(getByRole('checkbox'));
29
- fireEvent.click(getByRole('checkbox'));
30
- expect(handleChange).toHaveBeenCalledTimes(2);
31
- })
32
-
33
- it('should be correct classes on depend on prop "disabled, checked, error"', () => {
34
- const handleChange = jest.fn();
35
- const { getByTestId } = render(
36
- <PaymentTypeCard
37
- value="test-value"
38
- label="Test Label"
39
- onChange={handleChange}
40
- disabled
41
- checked
42
- error
43
- />
44
- );
45
- const container = getByTestId('container');
46
- expect(container).toHaveClass('disabled');
47
- expect(container).toHaveClass('checked');
48
- expect(container).toHaveClass('error');
49
- })
50
- });
@@ -1,95 +0,0 @@
1
- import React from 'react';
2
- import { render, fireEvent, screen, prettyDOM, waitFor } from '@testing-library/react';
3
- import RadioGroup from '../../../source/components/_common/Radio/RadioGroup';
4
- import ServiceCardWrapper from '../../../source/components/Checkout/RadioCards/AdditionalServiceCard/ServiceCardWrapper';
5
-
6
- const onChangeMock = jest.fn();
7
-
8
- const children = [
9
- <ServiceCardWrapper
10
- key={1}
11
- label={'additionalServices.warranty.label'}
12
- infoContent={'warranty'}
13
- footerText={'completeService'}
14
- value={3}
15
- warrantyCard={true}
16
- price={897456123}
17
- additionalOptions={['Alles aus Bronze Garantiepaket', 'Klima- & Kühlsysteme', 'Elektrische Anlagen']}
18
- monthly={'additionalServices.monthly'}
19
- className={'className'}
20
- modalTitle={'title'}
21
- modalContent={[
22
- 'Motor',
23
- 'Schalt- & Automatikgetriebe',
24
- 'Differenzial'
25
- ]}
26
- onCheckoutModalClick={() => {}}
27
- isHybridOrElectric={false}
28
- warrantyName={'name'}
29
- />,
30
- <ServiceCardWrapper
31
- key={2}
32
- label={'additionalServices.another.label'}
33
- infoContent={'another'}
34
- footerText={'completeService'}
35
- value={2}
36
- warrantyCard={true}
37
- price={987654321}
38
- additionalOptions={['Option 1', 'Option 2', 'Option 3']}
39
- monthly={'additionalServices.monthly'}
40
- className={'className'}
41
- modalTitle={'title'}
42
- modalContent={[
43
- 'Option 1',
44
- 'Option 2',
45
- 'Option 3'
46
- ]}
47
- onCheckoutModalClick={() => {}}
48
- isHybridOrElectric={false}
49
- warrantyName={'name'}
50
- checked={false}
51
- />
52
- ];
53
-
54
- describe('RadioGroup', () => {
55
- it('renders correctly with children', () => {
56
- const { getByText } = render(
57
- <RadioGroup
58
- name='testRadioGroup'
59
- value={1}
60
- onChange={onChangeMock}
61
- error={false}
62
- containerClassName='containerClassName'
63
- childClassName='childClassName'
64
- wrapperClassname='wrapperClassname'
65
- radioName='radioName'
66
- onBlur={() => {}}
67
- >
68
- {children}
69
- </RadioGroup>
70
- );
71
- expect(getByText('additionalServices.warranty.label')).toBeInTheDocument();
72
- expect(getByText('additionalServices.another.label')).toBeInTheDocument();
73
- });
74
-
75
- it('calls onChange when a radio button is selected', () => {
76
- const { getByRole, getByDisplayValue } = render(
77
- <RadioGroup
78
- name='testRadioGroup'
79
- value={1}
80
- onChange={onChangeMock}
81
- error={false}
82
- containerClassName='containerClassName'
83
- childClassName='childClassName'
84
- wrapperClassname='wrapperClassname'
85
- radioName='radioName'
86
- onBlur={() => {}}
87
- >
88
- {children}
89
- </RadioGroup>
90
- );
91
- const radioOption1 = getByRole('radio', { name: 'additionalServices.warranty.label 897.456.123 € /additionalServices.monthly warranty Alles aus Bronze Garantiepaket Klima- & Kühlsysteme Elektrische Anlagen' });
92
- fireEvent.click(radioOption1);
93
- expect(onChangeMock).toHaveBeenCalledTimes(1);
94
- });
95
- });
@@ -1,53 +0,0 @@
1
- import React from 'react';
2
- import { render, screen, fireEvent, prettyDOM } from '@testing-library/react';
3
- import ServiceCardWrapper from '../../../source/components/Checkout/RadioCards/AdditionalServiceCard/ServiceCardWrapper';
4
-
5
- describe('ServiceCardWrapper', () => {
6
- const defaultProps = {
7
- value: '1',
8
- checked: false,
9
- onCheckoutModalClick: jest.fn()
10
- };
11
- const getWrapper = (props = {}) => {
12
- return render(<ServiceCardWrapper {...defaultProps} {...props} />);
13
- };
14
-
15
- it('should render all elements properly', () => {
16
- const { container } = getWrapper({
17
- label: 'Test label',
18
- price: 100,
19
- checked: true,
20
- footerText: 'Test footer text'
21
- });
22
-
23
- expect(screen.getByText('Test label')).toBeInTheDocument();
24
- expect(screen.getByText('100')).toBeInTheDocument();
25
- expect(screen.getByText('€')).toBeInTheDocument();
26
- expect(container.querySelector('input[type="radio"]')).toBeInTheDocument();
27
- });
28
-
29
- it('should call onChange function with proper arguments on radio button click', () => {
30
- const onChange = jest.fn();
31
- const { container } = getWrapper({
32
- value: '2',
33
- onChange
34
- });
35
-
36
- fireEvent.click(container.querySelector('input[type="radio"]'));
37
-
38
- expect(onChange).toHaveBeenCalledTimes(1);
39
- expect(onChange).toHaveBeenCalledWith(expect.any(Object), true, '2');
40
- });
41
-
42
- it('should not call onChange function on radio button click if disabled', () => {
43
- const onChange = jest.fn();
44
- const { container } = getWrapper({
45
- disabled: true,
46
- onChange
47
- });
48
-
49
- fireEvent.click(container.querySelector('input[type="radio"]'));
50
-
51
- expect(onChange).not.toHaveBeenCalled();
52
- });
53
- });
@@ -1,43 +0,0 @@
1
- import React from 'react';
2
- import { render, fireEvent } from '@testing-library/react';
3
- import Switcher from '../../../source/components/Checkout/Switcher/Switcher';
4
-
5
- describe('Switcher component', () => {
6
- it('Should render options in Switcher', () => {
7
- const options = ['Option 1', 'Option 2', 'Option 3'];
8
- const { getAllByRole } = render(
9
- <Switcher options={options} value={1} />
10
- );
11
- const toggleButtons = getAllByRole('button');
12
- expect(toggleButtons.length).toBe(options.length);
13
- options.forEach((option, index) => {
14
- expect(toggleButtons[index]).toHaveTextContent(option);
15
- });
16
- });
17
-
18
- it('Should call onChange function when an option is selected', () => {
19
- const options = ['Option 1', 'Option 2', 'Option 3'];
20
- const onChangeMock = jest.fn();
21
- const { getAllByRole } = render(
22
- <Switcher options={options} value={1} onChange={onChangeMock} />
23
- );
24
- const toggleButtons = getAllByRole('button');
25
- fireEvent.click(toggleButtons[1]);
26
- expect(onChangeMock).toHaveBeenCalledTimes(1);
27
- expect(onChangeMock).toHaveBeenCalledWith(expect.anything(), 2, undefined);
28
- });
29
-
30
- it('Should pass correct values to ToggleButton', () => {
31
- const options = ['Option 1', 'Option 2', 'Option 3'];
32
- const value = 2;
33
- const { getAllByRole } = render(
34
- <Switcher options={options} value={value} />
35
- );
36
- const toggleButtons = getAllByRole('button');
37
- options.forEach((option, index) => {
38
- const toggleButton = toggleButtons[index];
39
- expect(toggleButton).toHaveTextContent(option);
40
- expect(toggleButton).toHaveAttribute('value', String(index + 1));
41
- });
42
- });
43
- });