@bytebrand/fe-ui-core 4.8.49 → 4.8.50

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 (189) hide show
  1. package/.husky/pre-push +4 -0
  2. package/.storybook/addons.js +4 -0
  3. package/.storybook/config.js +64 -0
  4. package/.storybook/postcss.config.js +6 -0
  5. package/.storybook/preview-head.html +10 -0
  6. package/.storybook/webpack.config.js +130 -0
  7. package/__tests__/components/Checkout/OrderOverviewItem/OrderOverviewItem.test.tsx +42 -0
  8. package/__tests__/components/Checkout/PaymentTypeCard/PaymentTypeCard.test.tsx +50 -0
  9. package/__tests__/components/Checkout/RadioGroup.test.tsx +95 -0
  10. package/__tests__/components/Checkout/ServiceCardWrapper.test.tsx +53 -0
  11. package/__tests__/components/Checkout/Switcher.test.tsx +43 -0
  12. package/__tests__/components/UserDasboardPage/sections/CheckoutSection/CheckoutSection.test.tsx +613 -0
  13. package/__tests__/components/UserDasboardPage/sections/FavoriteSection/FavoriteSection.test.tsx +335 -0
  14. package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/AdditionalOrderInfo.test.tsx +127 -0
  15. package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/OrderStatusCar.test.tsx +58 -0
  16. package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/OrderStatusCard.test.tsx +74 -0
  17. package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/OrderStatusSection.test.tsx +62 -0
  18. package/__tests__/components/UserDasboardPage/sections/RequestedCarsSection/RequestedCarsSection.test.tsx +117 -0
  19. package/__tests__/components/Vehicle/VehicleFormattedPrice/VehicleFormattedPrice.test.tsx +58 -0
  20. package/__tests__/components/VehicleSmallCard/VehicleInfo.test.tsx +88 -0
  21. package/__tests__/components/VehicleSmallCard/VehicleTitle.test.tsx +91 -0
  22. package/__tests__/components/_common/Badge/Badge.test.tsx +15 -0
  23. package/__tests__/components/_common/IconSVG/IconSVG.test.tsx +23 -0
  24. package/__tests__/components/_common/Image/Image.test.tsx +82 -0
  25. package/__tests__/components/_common/MaterialAutocomplete/MaterialAutocomplete.test.tsx +49 -0
  26. package/__tests__/components/_common/MaterialDatePicker/MaterialDatePicker.test.tsx +54 -0
  27. package/__tests__/components/_common/MaterialField/MaterialField.test.tsx +58 -0
  28. package/__tests__/components/_common/StarButton/StarButton.test.tsx +46 -0
  29. package/__tests__/mockedData/financingConfig.js +202 -0
  30. package/__tests__/mockedData/mockedPendingRequestedCar.js +69 -0
  31. package/__tests__/utils/CommonUtils/addPrefixToKeys.test.ts +18 -0
  32. package/__tests__/utils/CommonUtils/arrToObj.test.js +32 -0
  33. package/__tests__/utils/CommonUtils/checkRangeValuesOnEqual.test.ts +17 -0
  34. package/__tests__/utils/CommonUtils/fixNumber.test.ts +20 -0
  35. package/__tests__/utils/CommonUtils/formatMileage.test.ts +8 -0
  36. package/__tests__/utils/CommonUtils/getChipFilterValue.test.ts +22 -0
  37. package/__tests__/utils/CommonUtils/getFormattedNumber.test.ts +19 -0
  38. package/__tests__/utils/CommonUtils/getFormattedPrice.test.ts +19 -0
  39. package/__tests__/utils/CommonUtils/getGroupValuesForQuery.test.ts +51 -0
  40. package/__tests__/utils/CommonUtils/getOfferSliders.test.ts +64 -0
  41. package/__tests__/utils/CommonUtils/getPriceRating.test.ts +26 -0
  42. package/__tests__/utils/CommonUtils/getPriceRatingConfig.test.ts +33 -0
  43. package/__tests__/utils/CommonUtils/preloadNearbyImages.test.ts +9 -0
  44. package/__tests__/utils/CommonUtils/sliceLessThan.test.ts +23 -0
  45. package/__tests__/utils/CommonUtils/sliceMoreThan.test.ts +23 -0
  46. package/media/locales/de/promoSlider.json +1 -0
  47. package/media/locales/en/promoSlider.json +1 -0
  48. package/package.json +3 -5
  49. package/source/components/AccordionWidget/AccordionWidget.styl +1 -0
  50. package/source/components/AccordionWidget/AccordionWidget.tsx +8 -4
  51. package/source/components/AdvantageItem/AdvantageItem.story.js +23 -0
  52. package/source/components/Alternative/Dealer.story.js +32 -0
  53. package/source/components/Alternative/Dealer.story.styl +3 -0
  54. package/source/components/Breadcrumbs/Breadcrumbs.story.js +40 -0
  55. package/source/components/Breadcrumbs/FirstInfoBlock/FirstInfoBlock.story.js +45 -0
  56. package/source/components/Checkout/OrderOverviewItem/OrderOverviewItem.story.js +243 -0
  57. package/source/components/Checkout/OrderOverviewItem/OrderOverviewItem.story.styl +21 -0
  58. package/source/components/Checkout/RadioCards/RadioGroupCheckout.story.js +105 -0
  59. package/source/components/Checkout/RadioCards/RadioGroupCheckout.story.styl +37 -0
  60. package/source/components/Checkout/Switcher/Switcher.story.js +41 -0
  61. package/source/components/Checkout/Switcher/Switcher.story.styl +2 -0
  62. package/source/components/CompactSearchWidget/CompactSearchWidget.story.js +187 -0
  63. package/source/components/ContactForm/ContactForm.story.js +94 -0
  64. package/source/components/ContactForm/ContactForm.story.styl +0 -0
  65. package/source/components/ContactInfo/ContactInfo.story.js +58 -0
  66. package/source/components/CustomerQuote/CustomerQuote.story.js +41 -0
  67. package/source/components/CustomerQuotesSlider/CustomerQuotesSlider.story.js +73 -0
  68. package/source/components/CustomerQuotesSlider/CustomerQuotesSlider.story.styl +5 -0
  69. package/source/components/FormattedNumber/FormattedNumber.story.js +114 -0
  70. package/source/components/InfoBlocks/InfoBlockWrapper.story.js +101 -0
  71. package/source/components/InfoBlocks/InfoBlockWrapper.story.styl +46 -0
  72. package/source/components/OfferPanel/AboAccordion/AboFaq/AboFaq.story.js +97 -0
  73. package/source/components/OfferPanel/OfferPanel.story.js +139 -0
  74. package/source/components/OfferPanel/RangeGroup/RangeGroup.story.js +35 -0
  75. package/source/components/OfferPanel/RangeGroup/RangeGroup.story.styl +3 -0
  76. package/source/components/PriceRating/PriceRating.story.js +39 -0
  77. package/source/components/PriceRating/PriceRating.story.styl +2 -0
  78. package/source/components/PriceRatingDetailed/PriceRatingDetailed.story.js +78 -0
  79. package/source/components/PriceRatingDetailed/PriceRatingDetailed.story.styl +11 -0
  80. package/source/components/RateSearchValue/RateSearchValue.story.js +78 -0
  81. package/source/components/RateSearchValue/RateSearchValue.story.styl +2 -0
  82. package/source/components/RateSearchWidget/RateSearchWidget.story.js +57 -0
  83. package/source/components/RateSearchWidget/RateSearchWidget.story.styl +12 -0
  84. package/source/components/SearchFilters/FiltersFactory.story.js +273 -0
  85. package/source/components/SearchPage/Filters/MakeModel/MakeModel.story.js +12 -0
  86. package/source/components/SearchWidget/BasicDataWidget/BasicDataWidget.story.js +834 -0
  87. package/source/components/SearchWidget/BasicDataWidget/BasicDataWidget.story.styl +40 -0
  88. package/source/components/SearchWidget/SearchWidget.story.js +191 -0
  89. package/source/components/SearchWidget/SearchWidget.story.styl +6 -0
  90. package/source/components/Stepper/Stepper.story.js +119 -0
  91. package/source/components/Stepper/Stepper.story.styl +41 -0
  92. package/source/components/Theme.story.js +36 -0
  93. package/source/components/Theme.story.styl +85 -0
  94. package/source/components/TickerText/TickerText.story.js +17 -0
  95. package/source/components/UserDashboardPage/sections/OrderStatusSection/OrderStatusSection.story.js +95 -0
  96. package/source/components/UserDashboardPage/sections/RequestedCarsSection/RequestedCarsSection.story.js +97 -0
  97. package/source/components/Vehicle/VehicleConsumption/VehicleConsumption.story.js +31 -0
  98. package/source/components/Vehicle/VehicleFormattedPrice/VehicleFormattedPrice.story.js +247 -0
  99. package/source/components/VehicleCompared/CompareGeneral/CompareGeneral.story.js +30 -0
  100. package/source/components/VehicleCompared/ComparePrice/ComparePrice.story.js +18 -0
  101. package/source/components/VehicleCompared/CompareTitle/CompareTitle.story.js +19 -0
  102. package/source/components/VehicleDetailedSidebar/VehicleDetailedSidebar.story.js +44 -0
  103. package/source/components/VehicleDetailedSidebar/VehicleDetailedSidebar.tsx +23 -11
  104. package/source/components/VehicleDetailedSlider/VehicleDetailedSlider.story.js +120 -0
  105. package/source/components/VehicleDetailedSlider/VehicleDetailedSlider.tsx +2 -0
  106. package/source/components/VehicleDetailedSlider/partials/PriceData.tsx +48 -45
  107. package/source/components/VehiclePromoSlider/VehiclePromoInfo/VehiclePromoInfo.story.js +42 -0
  108. package/source/components/VehiclePromoSlider/VehiclePromoSlide/VehiclePromoSlide.story.js +62 -0
  109. package/source/components/VehiclePromoSlider/VehiclePromoSlider.story.js +42 -0
  110. package/source/components/VehicleSmallCard/VehicleData/VechiclePriceItem/VechiclePriceItem.styl +5 -0
  111. package/source/components/VehicleSmallCard/VehicleData/VechiclePriceItem/VechiclePriceItem.tsx +3 -1
  112. package/source/components/VehicleSmallCard/VehicleData/VehicleInfo/VehicleInfo.styl +1 -1
  113. package/source/components/VehicleSmallCard/VehicleData/VehicleInfo/VehicleInfo.tsx +24 -11
  114. package/source/components/VehicleSmallCard/VehicleData/VehiclePrice/VehiclePrice.styl +3 -2
  115. package/source/components/VehicleSmallCard/VehicleData/VehicleProperty/VehicleProperty.styl +4 -1
  116. package/source/components/VehicleSmallCard/VehicleData/VehicleProperty/VehicleProperty.tsx +3 -2
  117. package/source/components/VehicleSmallCard/VehicleData/VehicleTitle/VehicleTitle.tsx +1 -1
  118. package/source/components/VehicleSmallCard/VehicleSmallCard.story.js +412 -0
  119. package/source/components/VehicleSmallCard/VehicleSmallCard.story.styl +56 -0
  120. package/source/components/VehicleSmallCard/VehicleSmallCard.tsx +14 -3
  121. package/source/components/VehicleSmallCardForDealerships/VehicleSmallCardForDealerships.story.js +199 -0
  122. package/source/components/VehicleSmallCardForDealerships/VehicleSmallCardForDealerships.story.styl +40 -0
  123. package/source/components/_common/Accordion/Accordion.story.js +36 -0
  124. package/source/components/_common/Badge/Badge.story.js +27 -0
  125. package/source/components/_common/Badge/Badge.story.styl +5 -0
  126. package/source/components/_common/Bubble/Bubble.story.js +52 -0
  127. package/source/components/_common/Button/Button.story.js +52 -0
  128. package/source/components/_common/Button/Button.story.styl +5 -0
  129. package/source/components/_common/ButtonOld/Button.story.js +54 -0
  130. package/source/components/_common/ButtonOld/Button.story.styl +5 -0
  131. package/source/components/_common/Checkbox/Checkbox.story.js +85 -0
  132. package/source/components/_common/Checkbox/Checkbox.story.styl +14 -0
  133. package/source/components/_common/CheckboxMaterial/CheckboxMaterial.story.js +126 -0
  134. package/source/components/_common/CheckboxMaterial/CheckboxMaterial.story.styl +14 -0
  135. package/source/components/_common/Chip/Chip.story.js +43 -0
  136. package/source/components/_common/ChipList/ChipList.story.js +36 -0
  137. package/source/components/_common/DropDown/DropDown.story.js +35 -0
  138. package/source/components/_common/ExpandablePanel/ExpandablePanel.story.js +41 -0
  139. package/source/components/_common/Histogram/Histogram.story.js +51 -0
  140. package/source/components/_common/IconSVG/IconSVG.story.js +21 -0
  141. package/source/components/_common/IconSVG/IconSVG.story.styl +25 -0
  142. package/source/components/_common/Image/Image.story.js +142 -0
  143. package/source/components/_common/Image/Image.story.styl +18 -0
  144. package/source/components/_common/ImagesSet/ImagesSet.story.js +34 -0
  145. package/source/components/_common/ImagesSet/ImagesSet.story.styl +4 -0
  146. package/source/components/_common/Loader/Loader.story.js +21 -0
  147. package/source/components/_common/MaterialAccordionGroup/MaterialAccordionGroup.story.js +49 -0
  148. package/source/components/_common/MaterialAccordionGroup/MaterialAccordionGroup.styled.tsx +4 -1
  149. package/source/components/_common/MaterialDatePicker/MaterialDatePicker.story.js +45 -0
  150. package/source/components/_common/MaterialDatePicker/MaterialDatePicker.story.styl +6 -0
  151. package/source/components/_common/MaterialField/MaterialField.story.js +87 -0
  152. package/source/components/_common/MaterialField/MaterialField.story.styl +34 -0
  153. package/source/components/_common/MaterialSelect/MaterialSelect.story.js +52 -0
  154. package/source/components/_common/MaterialSelect/MaterialSelect.story.styl +6 -0
  155. package/source/components/_common/MaterialStepButton/MaterialStepButton.story.js +47 -0
  156. package/source/components/_common/MaterialStepButton/MaterialStepButton.story.styl +6 -0
  157. package/source/components/_common/MaterialSwitch/MaterialSwitch.story.js +17 -0
  158. package/source/components/_common/MaterialTooltip/MaterialTooltip.story.js +10 -0
  159. package/source/components/_common/Modal/Modal.story.js +37 -0
  160. package/source/components/_common/MuiGroupedSelect/MuiGroupedSelect.story.js +21 -0
  161. package/source/components/_common/PropertySelector/PSGroup.story.js +93 -0
  162. package/source/components/_common/PropertySelector/PSGroup.story.styl +25 -0
  163. package/source/components/_common/PropertySelector/ProperySelector.story.js +83 -0
  164. package/source/components/_common/Radio/FormRadioGroup.story.js +28 -0
  165. package/source/components/_common/Radio/FormRadioGroup.story.styl +2 -0
  166. package/source/components/_common/Radio/Radio.story.js +54 -0
  167. package/source/components/_common/Radio/RadioGroup.story.js +90 -0
  168. package/source/components/_common/Radio/RadioGroup.story.styl +39 -0
  169. package/source/components/_common/Range/Range.story.js +46 -0
  170. package/source/components/_common/Range/Range.story.styl +5 -0
  171. package/source/components/_common/SliderArrow/SliderArrow.story.js +18 -0
  172. package/source/components/_common/Tabs/Tabs.story.js +56 -0
  173. package/source/components/_common/TimePicker/TimePicker.story.js +37 -0
  174. package/source/components/_common/Tooltip/Tooltip.story.js +28 -0
  175. package/source/components/_common/UserMenu/MaterialMenu.story.js +73 -0
  176. package/source/components/_common/VehicleSlider/VehicleSlider.story.js +99 -0
  177. package/source/components/_common/VehicleSlider/VehicleSlider.story.styl +0 -0
  178. package/source/components/_common/withLabel/withLabel.story.js +62 -0
  179. package/source/components/_common/withPopover/withPopover.story.js +48 -0
  180. package/source/components/_common/withPopover/withPopover.story.styl +54 -0
  181. package/source/components/_common/withStats/withStats.story.js +75 -0
  182. package/source/components/_common/withStats/withStats.tsx +1 -1
  183. package/source/framework/DataTransformers.ts +1 -0
  184. package/source/framework/constants/common.ts +8 -4
  185. package/source/framework/types/types.ts +1 -0
  186. package/source/framework/vehiclesProps/decoratedLightProps.tsx +48 -12
  187. package/source/framework/vehiclesProps/decoratedProps.tsx +35 -8
  188. package/source/locales/data.ts +3 -0
  189. package/bytebrand-fe-ui-core-4.8.47.tgz +0 -0
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import { render, fireEvent } from '@testing-library/react';
3
+ import StarButton from '../../../../source/components/_common/StarButton/StarButton';
4
+
5
+
6
+ describe('StarButton', () => {
7
+ const defaultProps = {
8
+ onClick: jest.fn(),
9
+ isFavorite: true,
10
+ amountOfFavorite: 5
11
+ }
12
+
13
+ it('render StarButton component', () => {
14
+ const { container } = render(<StarButton {...defaultProps} />);
15
+ const svgIcon = container.querySelector('svg');
16
+ expect(svgIcon.firstChild).toBeTruthy();
17
+ });
18
+
19
+ it('should trigger the onClick function when clicked', () => {
20
+ const { container } = render(<StarButton {...defaultProps} />);
21
+ fireEvent.click(container.querySelector('svg'));
22
+ expect(defaultProps.onClick).toHaveBeenCalled();
23
+ });
24
+
25
+ it('render amount of favorite if is amountOfFavorite are true', () => {
26
+ const { container, queryByTitle } = render(<StarButton {...defaultProps} amountOfFavorite={5} />);
27
+ expect(container.querySelector('span')).toBeInTheDocument();
28
+ expect(queryByTitle(`${defaultProps.amountOfFavorite}`));
29
+ });
30
+
31
+ it('removes amount of favorite if no favorites are present', () => {
32
+ const { queryByTitle } = render(<StarButton {...defaultProps} amountOfFavorite={0} />);
33
+ expect(queryByTitle(`${defaultProps.amountOfFavorite}`)).toBeFalsy();
34
+ });
35
+
36
+ it('renders custom container class when custom container prop exists', () => {
37
+ const customContainerClass = 'custom-container-class';
38
+ const { container } = render(<StarButton {...defaultProps} customContainer={customContainerClass} />);
39
+ expect(container.firstChild).toHaveClass(customContainerClass);
40
+ });
41
+
42
+ it('adds "active" className when isFavorite is true', () => {
43
+ const { container } = render(<StarButton isFavorite />);
44
+ expect(container.querySelector('svg')).toHaveClass('active');
45
+ });
46
+ });
@@ -0,0 +1,202 @@
1
+ export const financingConfig = {
2
+ offerIndex: 0,
3
+ isStrike: false,
4
+ comparable: {
5
+ annualMileage: 40000,
6
+ firstInstallment: 16100,
7
+ paybackPeriod: 24,
8
+ withAddServices: true,
9
+ withTransportation: false,
10
+ isUpdated: 1677632978,
11
+ withFinalInstallment: false
12
+ },
13
+ checkout: {
14
+ warrantyRates: [
15
+ 30.33,
16
+ 0,
17
+ 39.01
18
+ ],
19
+ warrantyPackage: 0,
20
+ warrantyPeriod: 1,
21
+ admissionService: 6.47,
22
+ licensePlateFee: 2.13,
23
+ licensePlateFeeFinalInstallment: 0,
24
+ admissionServiceFinalInstallment: 0
25
+ },
26
+ common: {
27
+ firstRegistration: 1572562800,
28
+ mileage: 102000,
29
+ currentSalesPrice: 21666,
30
+ highestPrice: 21666,
31
+ isStrikeShown: false,
32
+ isHybridOrElectric: false
33
+ },
34
+ financing: {
35
+ grossLoanAmountWithoutFinalInstallment: 5796.24,
36
+ purchasePrice: 0,
37
+ hasPaymentProtection: false,
38
+ paymentProtectionInsurance: 0,
39
+ monthlyInstallment: 241.51,
40
+ oldMonthlyInstallment: 241.51,
41
+ annualMileage: 40000,
42
+ firstInstallment: 16100,
43
+ withTransportation: false,
44
+ withAddServices: true,
45
+ addServicesCostRaw: 799,
46
+ addServicesCost: 34.67,
47
+ transportationCostRaw: 499,
48
+ transportationCost: 21.65,
49
+ withFinalInstallment: false,
50
+ paybackPeriod: 24,
51
+ rawPaybackPeriod: 24,
52
+ nominalInterestRate: 3.92,
53
+ annualPercentageRate: 3.99,
54
+ financialInstitution: 'Santander Consumer Bank AG, Santander-Platz 1, 41061 Mönchengladbach',
55
+ periodInterestRate: [
56
+ {
57
+ duration: 12,
58
+ recommended: 70,
59
+ current: 88,
60
+ inEUR: null,
61
+ value: 17566,
62
+ highestValue: 19066.08
63
+ },
64
+ {
65
+ duration: 24,
66
+ recommended: 66,
67
+ current: 77,
68
+ inEUR: null,
69
+ value: 16067.59,
70
+ highestValue: 16682.82
71
+ },
72
+ {
73
+ duration: 36,
74
+ recommended: 60,
75
+ current: 66,
76
+ inEUR: null,
77
+ value: 13772.22,
78
+ highestValue: 14299.56
79
+ },
80
+ {
81
+ duration: 48,
82
+ recommended: 50,
83
+ current: 60,
84
+ inEUR: null,
85
+ value: 12520.2,
86
+ highestValue: 12999.6
87
+ },
88
+ {
89
+ duration: 60,
90
+ recommended: 40,
91
+ current: 50,
92
+ inEUR: null,
93
+ value: 10433.5,
94
+ highestValue: 10833
95
+ },
96
+ {
97
+ duration: 72,
98
+ recommended: 30,
99
+ current: 40,
100
+ inEUR: null,
101
+ value: 8346.8,
102
+ highestValue: 8666.4
103
+ },
104
+ {
105
+ duration: 84,
106
+ recommended: 20,
107
+ current: 30,
108
+ inEUR: null,
109
+ value: 6260.1,
110
+ highestValue: 6499.8
111
+ },
112
+ {
113
+ duration: 96,
114
+ recommended: 10,
115
+ current: 20,
116
+ inEUR: null,
117
+ value: 4173.4,
118
+ highestValue: 4333.2
119
+ }
120
+ ],
121
+ closingCosts: 0,
122
+ offersFinancing: true,
123
+ rateMode: 'dealer',
124
+ isStrikeShown: false,
125
+ totalInterestPayments: 197.16,
126
+ grossLoanAmount: 5796.24,
127
+ onetimeSpecialPayment: 16100,
128
+ currentSalesPrice: 21666,
129
+ highestPrice: 21666,
130
+ oldMonthlyCarPrice: 206.84,
131
+ monthlyCarPrice: 206.84,
132
+ currentSalesPriceExtraCost: 21666,
133
+ finalInstallment: 0,
134
+ netLoanAmount: 5566
135
+ },
136
+ buy: {
137
+ withTransportation: false,
138
+ withAddServices: true,
139
+ withoutAddServices: true,
140
+ transportationCost: 499,
141
+ addServicesCost: 799,
142
+ currentSalesPriceExtra: 21666,
143
+ highestPriceExtra: 21666,
144
+ extraCost: 0
145
+ },
146
+ leasing: {
147
+ RWG: 4,
148
+ maxAge: 24,
149
+ maxMileage: 1000000,
150
+ isActive: false,
151
+ withTransportation: false,
152
+ withAddServices: true,
153
+ addServicesCostRaw: 799,
154
+ transportationCostRaw: 499,
155
+ addServicesCost: 18.76,
156
+ transportationCost: 11.71,
157
+ monthlyAddServices: 0,
158
+ monthlyTransportation: 0,
159
+ monthlyInstallment: 77.25,
160
+ oldMonthlyInstallment: 77.25,
161
+ firstInstallment: 11871.64,
162
+ firstInstallmentMax: 11871.64,
163
+ annualMileage: 40000,
164
+ paybackPeriodRange: [
165
+ 30,
166
+ 36,
167
+ 42,
168
+ 48,
169
+ 54,
170
+ 60
171
+ ],
172
+ paybackPeriod: 30,
173
+ santanderPayBackMin: 250,
174
+ nominalInterestRate: 6.78,
175
+ financialInstitution: 'Santander Consumer Bank AG, Santander-Platz 1, 41061 Mönchengladbach',
176
+ grossLoanAmountWithoutFinalInstallment: 2317.5,
177
+ hasPaymentProtection: false,
178
+ paymentProtectionInsurance: 0,
179
+ leasingMode: 'default',
180
+ currentSalesPrice: 21666,
181
+ monthlyCarPrice: 58.49,
182
+ oldMonthlyCarPrice: 58.49,
183
+ currentSalesPriceExtraCost: 21666,
184
+ onetimeSpecialPayment: 11871.64,
185
+ netLoanAmount: 9794.36,
186
+ grossLoanAmount: 11062.86,
187
+ finalInstallment: 0,
188
+ annualPercentageRate: 6.99
189
+ },
190
+ abo: {
191
+ paybackPeriod: 6,
192
+ annualMileage: 40000
193
+ },
194
+ firstRegistration: 1572562800,
195
+ mileage: 102000,
196
+ currentSalesPrice: 21666,
197
+ highestPrice: 21666,
198
+ isStrikeShown: false,
199
+ carId: '26ee4c6c-2c55-48e8-bba7-c22aa185558d',
200
+ offerName: 'financing',
201
+ vehicleId: '26ee4c6c-2c55-48e8-bba7-c22aa185558d'
202
+ }
@@ -0,0 +1,69 @@
1
+ export const car = {
2
+ _id: '63e12296aeb426dad4af5e5c',
3
+ odooLead: 213907,
4
+ buyingType: 'leasing',
5
+ car: {
6
+ _id: '30b7bdeb-c193-4dc3-9f92-86680c9fcf59',
7
+ metaData: {
8
+ creationDate: 1675668285,
9
+ modificationDate: 1676979836,
10
+ ownerId: 'ZdHm8pCH0nWnIDdky6rm37JouFv1',
11
+ tsn: null,
12
+ codeKBA: null,
13
+ codeDAT: null,
14
+ codeSchwacke: null,
15
+ codeJato: null,
16
+ mainImageId: 'HekeLJ2ehJ9R',
17
+ secImageId: 'CdhVrQF7kXgP',
18
+ thirdImageId: 'oYLuytuZTBSb',
19
+ vehicleId: 'F6DF54',
20
+ imagesCount: 0,
21
+ allImagesCount: 13,
22
+ postProcessingConfigurationId: null,
23
+ imagePackageID: null,
24
+ imagesByApp: false,
25
+ ownerName: 'Guardian of Auto.de',
26
+ imagesRemovedBg: true
27
+ },
28
+ mainData: {
29
+ make: 'Fiat',
30
+ model: '500',
31
+ subModel: '1,0 GSE HYBRID PIU DOLCEVITA MJ22',
32
+ series: '500',
33
+ trimLine: null,
34
+ vehicleClass: 'selector_vehicleClass_car',
35
+ category: 'selector_category_convertible',
36
+ modelDescription: '',
37
+ condition: 'selector_condition_new',
38
+ usageType: 'selector_unknown',
39
+ firstRegistration: null,
40
+ mileage: 15,
41
+ doors: 3,
42
+ seats: 4,
43
+ constructionYear: null,
44
+ constructionDate: null,
45
+ firstModelsProductionDate: null,
46
+ countryVersion: null,
47
+ numberOfPreviousOwners: 0,
48
+ nonSmokerVehicle: null,
49
+ damageUnrepaired: null,
50
+ accidentDamaged: false,
51
+ roadworthy: true,
52
+ damageByHail: null,
53
+ taxi: null,
54
+ damaged: false
55
+ },
56
+ createdAt: '2023-02-06T15:53:58.836Z',
57
+ currentSalesPrice: 30666,
58
+ delivery: true,
59
+ monthlyInstallment: 401.28,
60
+ paybackPeriod: 36,
61
+ registration: true,
62
+ request: 'REQ228794',
63
+ selfPickup: false,
64
+ status: 'selector_status_handing_over',
65
+ updatedAt: '2023-02-10T09:31:31.859Z',
66
+ user: 'eGWQxSdo97UPkTlYmJrNZVNQCdy1',
67
+ wonStatus: 'pending'
68
+ }
69
+ }
@@ -0,0 +1,18 @@
1
+ import { addPrefixToKeys } from '../../../source/framework/utils/CommonUtils';
2
+
3
+ describe('addPrefixToKeys', () => {
4
+ it('should return an empty object when given an empty object', () => {
5
+ const obj = {};
6
+ const prefix = 'test';
7
+ const result = addPrefixToKeys(obj, prefix);
8
+ expect(result).toEqual({});
9
+ });
10
+
11
+ it('should add the prefix to each key in the object', () => {
12
+ const obj = { a: 1, b: 2, c: 3 };
13
+ const prefix = 'test';
14
+ const result = addPrefixToKeys(obj, prefix);
15
+ const expected = { test_a: 1, test_b: 2, test_c: 3 };
16
+ expect(result).toEqual(expected);
17
+ });
18
+ });
@@ -0,0 +1,32 @@
1
+ import { arrToObj } from '../../../source/framework/utils/CommonUtils';
2
+
3
+ const mockArr = ['first', 'second', 'third'];
4
+
5
+ describe('arrToObj', () => {
6
+ it('should return an empty object when passed a non-array value', () => {
7
+ expect(arrToObj(null)).toEqual({});
8
+ expect(arrToObj(undefined)).toEqual({});
9
+ expect(arrToObj('')).toEqual({});
10
+ expect(arrToObj(42)).toEqual({});
11
+ expect(arrToObj({})).toEqual({});
12
+ });
13
+
14
+ it('should convert an array of strings to an object where each string is a key with a value of true', () => {
15
+ const obj = arrToObj(mockArr);
16
+ expect(obj).toMatchObject({ first: true, second: true, third: true });
17
+ expect(Object.keys(obj)).toHaveLength(mockArr.length);
18
+ mockArr.forEach((val) => {
19
+ expect(obj[val]).toBe(true);
20
+ });
21
+ });
22
+
23
+ it('should not modify the original array', () => {
24
+ const originalArr = [...mockArr];
25
+ arrToObj(mockArr);
26
+ expect(mockArr).toEqual(originalArr);
27
+ });
28
+
29
+ it('should return an empty object when passed an empty array', () => {
30
+ expect(arrToObj([])).toEqual({});
31
+ });
32
+ });
@@ -0,0 +1,17 @@
1
+ import { checkRangeValuesOnEqual } from '../../../source/framework/utils/CommonUtils';
2
+
3
+ describe('checkRangeValuesOnEqual', () => {
4
+ it('returns true when defaultValues and filterValues have exactly the same values', () => {
5
+ const defaultValues = { from: 1000, to: 2000 };
6
+ const filterValues = { from: 1000, to: 2000 };
7
+ const result = checkRangeValuesOnEqual(defaultValues, filterValues);
8
+ expect(result).toEqual(true);
9
+ });
10
+
11
+ it('returns false when defaultValues and filterValues have different values', () => {
12
+ const defaultValues = { from: 1000, to: 2000 };
13
+ const filterValues = { from: 500, to: 2000 };
14
+ const result = checkRangeValuesOnEqual(defaultValues, filterValues);
15
+ expect(result).toEqual(false);
16
+ });
17
+ });
@@ -0,0 +1,20 @@
1
+ import { fixNumber } from '../../../source/framework/utils/CommonUtils';
2
+
3
+ describe('fixNumber', () => {
4
+ it('should return fix number when given a float with two decimals', () => {
5
+ expect(fixNumber(5.555)).toEqual(5.56);
6
+ });
7
+
8
+ it('should return fix number when given an integer', () => {
9
+ expect(fixNumber(6)).toEqual(6);
10
+ });
11
+
12
+ it('should return fix number when given a string which have two decimal places only', () => {
13
+ expect(fixNumber('7.225')).toEqual(7.23);
14
+ });
15
+
16
+ it('should return fix number when given a string with extra whitespace characters', () => {
17
+ expect(fixNumber(' 4.444 ')).toEqual(4.44);
18
+ });
19
+ });
20
+
@@ -0,0 +1,8 @@
1
+ import { formatMileage } from '../../../source/framework/utils/CommonUtils';
2
+
3
+ describe('formatMileage', () => {
4
+ it('should correctly format millage when passed as number', () => {
5
+ const result = formatMileage(123456789);
6
+ expect(result).toEqual('123.456.789');
7
+ });
8
+ });
@@ -0,0 +1,22 @@
1
+ import { getChipFilterValue } from "../../../source/framework/utils/CommonUtils";
2
+
3
+ const translatePathFrom = 'SearchPage:filters.from';
4
+ const translatePathTo = 'SearchPage:filters.to';
5
+ const t = (key: string) => key;
6
+ const language = 'en';
7
+
8
+ describe('getChipFilterValue', () => {
9
+ it('should return the chip with original filter value', () => {
10
+ const chip = { filterKey: 'MANUFACTURER', filterValue: 'Audi' };
11
+ const filterValue = getChipFilterValue(chip);
12
+ expect(filterValue).toEqual('Audi');
13
+ });
14
+
15
+ it('should return the correct chip for a range values with title', () => {
16
+ const chip = { filterKey: 'PRICE', filterValue: { from: 10000, to: 20000 } };
17
+ const filterValue = getChipFilterValue(chip, t, language).replace(/\s+/g, ' ').trim();
18
+ const translatePathPrice = `SearchPage:filters.${chip.filterKey.toLocaleLowerCase()}`;
19
+ const expectedValue = `${translatePathPrice} ${translatePathFrom} 10.000 ${translatePathTo} 20.000`.replace(/\s+/g, ' ').trim()
20
+ expect(filterValue).toBe(expectedValue);
21
+ });
22
+ });
@@ -0,0 +1,19 @@
1
+ import { getFormattedNumber } from '../../../source/framework/utils/CommonUtils';
2
+
3
+ describe('getFormattedNumber', () => {
4
+ it('should format a number with German locale', () => {
5
+ const formattedNumber = getFormattedNumber(123456789.5);
6
+ expect(formattedNumber).toBe('123.456.789,5');
7
+ });
8
+
9
+ it('should return null if input is not finite number', () => {
10
+ const formattedNumber = getFormattedNumber(NaN);
11
+ expect(formattedNumber).toBeNull();
12
+
13
+ const formattedNumber2 = getFormattedNumber(undefined);
14
+ expect(formattedNumber2).toBeNull();
15
+
16
+ const formattedNumber3 = getFormattedNumber('invalidNumber' as any);
17
+ expect(formattedNumber3).toBeNull();
18
+ });
19
+ });
@@ -0,0 +1,19 @@
1
+ import { getFormattedPrice } from '../../../source/framework/utils/CommonUtils';
2
+
3
+ describe('getFormattedPrice', () => {
4
+ it('should format the given price correctly with default parameters', () => {
5
+ const result = getFormattedPrice(1234567890);
6
+ expect(result).toEqual('1.234.567.890');
7
+ });
8
+
9
+ it('should format the given price correctly with custom format and currency', () => {
10
+ const result = getFormattedPrice(1990.75, '$.2f', 'USD');
11
+ expect(result).toEqual('1990,75USD');
12
+ });
13
+
14
+ it('should return "-" if price is not finite number or null/undefined', () => {
15
+ expect(getFormattedPrice(undefined)).toEqual('-');
16
+ expect(getFormattedPrice(null)).toEqual('-');
17
+ expect(getFormattedPrice(NaN)).toEqual('-');
18
+ });
19
+ });
@@ -0,0 +1,51 @@
1
+ import { getGroupValuesForQuery } from '../../../source/framework/utils/CommonUtils';
2
+
3
+ describe('getGroupValuesForQuery', () => {
4
+ it('should return array of objects, each containing key/value pairs for all properties with truthy values', () => {
5
+ const filterObj = [
6
+ {
7
+ MANUFACTURER: {
8
+ field: 'mainData_make',
9
+ value: 'Audi',
10
+ isAbsolute: true
11
+ },
12
+ MODEL: {
13
+ field: 'mainData_model',
14
+ value: 'A5',
15
+ isAbsolute: true
16
+ },
17
+ SUB_MODEL: {
18
+ field: 'mainData_subModel',
19
+ value: 'sportback',
20
+ isAbsolute: true
21
+ },
22
+ SERIES: {
23
+ field: 'mainData_series',
24
+ value: 'series',
25
+ isAbsolute: true
26
+ }
27
+ }
28
+ ];
29
+
30
+ const result = getGroupValuesForQuery(filterObj);
31
+
32
+ const expectedResult = [
33
+ {
34
+ MANUFACTURER: 'Audi',
35
+ MODEL: 'A5',
36
+ SUB_MODEL: 'sportback',
37
+ SERIES: 'series'
38
+ }
39
+ ]
40
+
41
+ expect(result).toEqual(expectedResult);
42
+ });
43
+
44
+ it('should return empty array if argument is an empty array', () => {
45
+ const groups: any[] = [];
46
+
47
+ const result = getGroupValuesForQuery(groups);
48
+
49
+ expect(result).toEqual([]);
50
+ });
51
+ });
@@ -0,0 +1,64 @@
1
+ import { getOfferSliders } from '../../../source/framework/utils/CommonUtils';
2
+ import { financingConfig } from '../../mockedData/financingConfig';
3
+
4
+ const expectedResultCDP = [
5
+ {
6
+ name: 'firstInstallment',
7
+ min: 0,
8
+ step: 100,
9
+ unit: 'euro',
10
+ max: 21666,
11
+ value: 16100,
12
+ unitName: 'modals:financing.euro',
13
+ caption: 'modals:financing.firstInstallment',
14
+ withRangeLimit: true
15
+ },
16
+ {
17
+ name: 'annualMileage',
18
+ min: 5000,
19
+ max: 60000,
20
+ step: 5000,
21
+ unit: 'km',
22
+ value: 40000,
23
+ unitName: 'modals:financing.km',
24
+ caption: 'modals:financing.annualMileage'
25
+ }
26
+ ]
27
+
28
+ const expectedResultCheckout = [
29
+ {
30
+ name: 'firstInstallment',
31
+ min: 0,
32
+ step: 100,
33
+ unit: 'euro',
34
+ max: 21666,
35
+ value: 16100,
36
+ unitName: 'modals:financing.euro',
37
+ caption: 'modals:financing.firstInstallment',
38
+ withRangeLimit: true
39
+ }
40
+ ]
41
+
42
+ const t = (phrase: string, options?: object) => {
43
+ return `${phrase} ${options ? options : ''}`.trim();
44
+ }
45
+
46
+ describe('getOfferSliders', () => {
47
+ it('should return correct array with slider data for CDP', () => {
48
+
49
+ const priceTabIndex = 0; // financing tab
50
+ const componentType = 'main';
51
+
52
+ const result = getOfferSliders(financingConfig, t, priceTabIndex, componentType);
53
+ expect(result).toEqual(expectedResultCDP);
54
+ })
55
+
56
+ it('should return correct array with slider data for checkout page without annual mileage for financing', () => {
57
+
58
+ const priceTabIndex = 0; // financing tab
59
+ const componentType = 'checkout';
60
+
61
+ const result = getOfferSliders(financingConfig, t, priceTabIndex, componentType);
62
+ expect(result).toEqual(expectedResultCheckout);
63
+ })
64
+ })
@@ -0,0 +1,26 @@
1
+ import { getPriceRating } from "../../../utils";
2
+
3
+ describe('getPriceRating', () => {
4
+ it('should return 0 when input price is undefined or null', () => {
5
+ expect(getPriceRating(undefined, undefined)).toBe(0);
6
+ expect(getPriceRating(null, null)).toBe(0);
7
+ });
8
+
9
+ it('should return 1 when current price match the highest price in ratingConfig', () => {
10
+ const currentSalesPrice = 3800;
11
+ const predictablePrice = 3000;
12
+ expect(getPriceRating(currentSalesPrice, predictablePrice)).toBe(1);
13
+ });
14
+
15
+ it('should return topPrice index in priceRatings when current sales price less than or equals to range of topPrice', () => {
16
+ const currentSalesPrice = 1000;
17
+ const predictablePrice = 10000;
18
+ expect(getPriceRating(currentSalesPrice, predictablePrice)).toBe(5);
19
+ });
20
+
21
+ it('should return correct price rating index based on currentSalesPrice and predictablePrice', () => {
22
+ const currentSalesPrice = 9600;
23
+ const predictablePrice = 10000;
24
+ expect(getPriceRating(currentSalesPrice, predictablePrice)).toBe(3); // fairPrice index in priceRatings array
25
+ });
26
+ });
@@ -0,0 +1,33 @@
1
+ import { getPriceRatingConfig } from '../../../utils';
2
+
3
+ describe('getPriceRatingConfig', () => {
4
+ it('should generate the pricing config correctly', () => {
5
+ const currentPrice = 5000
6
+ const pricePredicted = 4000
7
+
8
+ const expectedOutput = {
9
+ topPrice: { min: 3000, max: 3600 },
10
+ goodPrice: { min: 3600, max: 3800 },
11
+ fairPrice: { min: 3800, max: 4200 },
12
+ increasedPrice: { min: 4200, max: 4700 },
13
+ highPrice: { min: 4700, max: 5000 }
14
+ }
15
+
16
+ expect(getPriceRatingConfig(currentPrice, pricePredicted)).toEqual(expectedOutput)
17
+ })
18
+
19
+ it('should return "???" for invalid predicted prices', () => {
20
+ const currentPrice = 5000
21
+ const pricePredicted = NaN
22
+
23
+ const expectedOutput = {
24
+ topPrice: { min: '???', max: '???' },
25
+ goodPrice: { min: '???', max: '???' },
26
+ fairPrice: { min: '???', max: '???' },
27
+ increasedPrice: { min: '???', max: '???' },
28
+ highPrice: { min: '???', max: '???' }
29
+ }
30
+
31
+ expect(getPriceRatingConfig(currentPrice, pricePredicted)).toEqual(expectedOutput)
32
+ })
33
+ })
@@ -0,0 +1,9 @@
1
+ import { preloadNearbyImages } from '../../../source/framework/utils/CommonUtils';
2
+
3
+ describe('preloadNearbyImages', () => {
4
+ it('should not break when no images provided', () => {
5
+ preloadNearbyImages([], 0, 'imageUrlMedium');
6
+
7
+ expect(document.images).toHaveLength(0);
8
+ });
9
+ });