@bytebrand/fe-ui-core 4.8.49 → 4.8.51

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 (194) 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 +2 -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/OfferCheckboxGroup/CheckboxContainer.tsx +1 -1
  74. package/source/components/OfferPanel/OfferCheckboxGroup/OfferCheckboxGroup.styl +24 -0
  75. package/source/components/OfferPanel/OfferCheckboxGroup/OfferCheckboxGroup.tsx +1 -1
  76. package/source/components/OfferPanel/OfferPanel.story.js +139 -0
  77. package/source/components/OfferPanel/OfferPanel.tsx +1 -1
  78. package/source/components/OfferPanel/RangeGroup/RangeGroup.story.js +35 -0
  79. package/source/components/OfferPanel/RangeGroup/RangeGroup.story.styl +3 -0
  80. package/source/components/PriceRating/PriceRating.story.js +39 -0
  81. package/source/components/PriceRating/PriceRating.story.styl +2 -0
  82. package/source/components/PriceRatingDetailed/PriceRatingDetailed.story.js +78 -0
  83. package/source/components/PriceRatingDetailed/PriceRatingDetailed.story.styl +11 -0
  84. package/source/components/RateSearchValue/RateSearchValue.story.js +78 -0
  85. package/source/components/RateSearchValue/RateSearchValue.story.styl +2 -0
  86. package/source/components/RateSearchWidget/RateSearchWidget.story.js +57 -0
  87. package/source/components/RateSearchWidget/RateSearchWidget.story.styl +12 -0
  88. package/source/components/SearchFilters/FiltersFactory.story.js +273 -0
  89. package/source/components/SearchPage/Filters/MakeModel/MakeModel.story.js +12 -0
  90. package/source/components/SearchWidget/BasicDataWidget/BasicDataWidget.story.js +834 -0
  91. package/source/components/SearchWidget/BasicDataWidget/BasicDataWidget.story.styl +40 -0
  92. package/source/components/SearchWidget/SearchWidget.story.js +191 -0
  93. package/source/components/SearchWidget/SearchWidget.story.styl +6 -0
  94. package/source/components/Stepper/Stepper.story.js +119 -0
  95. package/source/components/Stepper/Stepper.story.styl +41 -0
  96. package/source/components/Theme.story.js +36 -0
  97. package/source/components/Theme.story.styl +85 -0
  98. package/source/components/TickerText/TickerText.story.js +17 -0
  99. package/source/components/UserDashboardPage/sections/OrderStatusSection/OrderStatusSection.story.js +95 -0
  100. package/source/components/UserDashboardPage/sections/RequestedCarsSection/RequestedCarsSection.story.js +97 -0
  101. package/source/components/Vehicle/VehicleConsumption/VehicleConsumption.story.js +31 -0
  102. package/source/components/Vehicle/VehicleFormattedPrice/VehicleFormattedPrice.story.js +247 -0
  103. package/source/components/VehicleCompared/CompareGeneral/CompareGeneral.story.js +30 -0
  104. package/source/components/VehicleCompared/ComparePrice/ComparePrice.story.js +18 -0
  105. package/source/components/VehicleCompared/CompareTitle/CompareTitle.story.js +19 -0
  106. package/source/components/VehicleDetailedSidebar/VehicleDetailedSidebar.story.js +44 -0
  107. package/source/components/VehicleDetailedSidebar/VehicleDetailedSidebar.tsx +23 -11
  108. package/source/components/VehicleDetailedSlider/VehicleDetailedSlider.story.js +120 -0
  109. package/source/components/VehicleDetailedSlider/VehicleDetailedSlider.tsx +2 -0
  110. package/source/components/VehicleDetailedSlider/partials/PriceData.tsx +7 -4
  111. package/source/components/VehiclePromoSlider/VehiclePromoInfo/VehiclePromoInfo.story.js +42 -0
  112. package/source/components/VehiclePromoSlider/VehiclePromoSlide/VehiclePromoSlide.story.js +62 -0
  113. package/source/components/VehiclePromoSlider/VehiclePromoSlider.story.js +42 -0
  114. package/source/components/VehicleSmallCard/VehicleData/VechiclePriceItem/VechiclePriceItem.styl +5 -0
  115. package/source/components/VehicleSmallCard/VehicleData/VechiclePriceItem/VechiclePriceItem.tsx +3 -1
  116. package/source/components/VehicleSmallCard/VehicleData/VehicleInfo/VehicleInfo.styl +1 -1
  117. package/source/components/VehicleSmallCard/VehicleData/VehicleInfo/VehicleInfo.tsx +24 -11
  118. package/source/components/VehicleSmallCard/VehicleData/VehiclePrice/VehiclePrice.styl +3 -2
  119. package/source/components/VehicleSmallCard/VehicleData/VehicleProperty/VehicleProperty.styl +4 -1
  120. package/source/components/VehicleSmallCard/VehicleData/VehicleProperty/VehicleProperty.tsx +3 -2
  121. package/source/components/VehicleSmallCard/VehicleData/VehicleTitle/VehicleTitle.tsx +1 -1
  122. package/source/components/VehicleSmallCard/VehicleSmallCard.story.js +412 -0
  123. package/source/components/VehicleSmallCard/VehicleSmallCard.story.styl +56 -0
  124. package/source/components/VehicleSmallCard/VehicleSmallCard.tsx +14 -3
  125. package/source/components/VehicleSmallCardForDealerships/VehicleSmallCardForDealerships.story.js +199 -0
  126. package/source/components/VehicleSmallCardForDealerships/VehicleSmallCardForDealerships.story.styl +40 -0
  127. package/source/components/_common/Accordion/Accordion.story.js +36 -0
  128. package/source/components/_common/Badge/Badge.story.js +27 -0
  129. package/source/components/_common/Badge/Badge.story.styl +5 -0
  130. package/source/components/_common/Bubble/Bubble.story.js +52 -0
  131. package/source/components/_common/Button/Button.story.js +52 -0
  132. package/source/components/_common/Button/Button.story.styl +5 -0
  133. package/source/components/_common/ButtonOld/Button.story.js +54 -0
  134. package/source/components/_common/ButtonOld/Button.story.styl +5 -0
  135. package/source/components/_common/Checkbox/Checkbox.story.js +85 -0
  136. package/source/components/_common/Checkbox/Checkbox.story.styl +14 -0
  137. package/source/components/_common/CheckboxMaterial/CheckboxMaterial.story.js +126 -0
  138. package/source/components/_common/CheckboxMaterial/CheckboxMaterial.story.styl +14 -0
  139. package/source/components/_common/Chip/Chip.story.js +43 -0
  140. package/source/components/_common/ChipList/ChipList.story.js +36 -0
  141. package/source/components/_common/DropDown/DropDown.story.js +35 -0
  142. package/source/components/_common/ExpandablePanel/ExpandablePanel.story.js +41 -0
  143. package/source/components/_common/Histogram/Histogram.story.js +51 -0
  144. package/source/components/_common/IconSVG/IconSVG.story.js +21 -0
  145. package/source/components/_common/IconSVG/IconSVG.story.styl +25 -0
  146. package/source/components/_common/Image/Image.story.js +142 -0
  147. package/source/components/_common/Image/Image.story.styl +18 -0
  148. package/source/components/_common/ImagesSet/ImagesSet.story.js +34 -0
  149. package/source/components/_common/ImagesSet/ImagesSet.story.styl +4 -0
  150. package/source/components/_common/Loader/Loader.story.js +21 -0
  151. package/source/components/_common/MaterialAccordionGroup/MaterialAccordionGroup.story.js +49 -0
  152. package/source/components/_common/MaterialAccordionGroup/MaterialAccordionGroup.styled.tsx +4 -1
  153. package/source/components/_common/MaterialDatePicker/MaterialDatePicker.story.js +45 -0
  154. package/source/components/_common/MaterialDatePicker/MaterialDatePicker.story.styl +6 -0
  155. package/source/components/_common/MaterialField/MaterialField.story.js +87 -0
  156. package/source/components/_common/MaterialField/MaterialField.story.styl +34 -0
  157. package/source/components/_common/MaterialSelect/MaterialSelect.story.js +52 -0
  158. package/source/components/_common/MaterialSelect/MaterialSelect.story.styl +6 -0
  159. package/source/components/_common/MaterialStepButton/MaterialStepButton.story.js +47 -0
  160. package/source/components/_common/MaterialStepButton/MaterialStepButton.story.styl +6 -0
  161. package/source/components/_common/MaterialSwitch/MaterialSwitch.story.js +17 -0
  162. package/source/components/_common/MaterialTooltip/MaterialTooltip.story.js +10 -0
  163. package/source/components/_common/MaterialTooltip/MaterialTooltip.tsx +1 -1
  164. package/source/components/_common/Modal/Modal.story.js +37 -0
  165. package/source/components/_common/MuiGroupedSelect/MuiGroupedSelect.story.js +21 -0
  166. package/source/components/_common/PropertySelector/PSGroup.story.js +93 -0
  167. package/source/components/_common/PropertySelector/PSGroup.story.styl +25 -0
  168. package/source/components/_common/PropertySelector/ProperySelector.story.js +83 -0
  169. package/source/components/_common/Radio/FormRadioGroup.story.js +28 -0
  170. package/source/components/_common/Radio/FormRadioGroup.story.styl +2 -0
  171. package/source/components/_common/Radio/Radio.story.js +54 -0
  172. package/source/components/_common/Radio/RadioGroup.story.js +90 -0
  173. package/source/components/_common/Radio/RadioGroup.story.styl +39 -0
  174. package/source/components/_common/Range/Range.story.js +46 -0
  175. package/source/components/_common/Range/Range.story.styl +5 -0
  176. package/source/components/_common/SliderArrow/SliderArrow.story.js +18 -0
  177. package/source/components/_common/Tabs/Tabs.story.js +56 -0
  178. package/source/components/_common/TimePicker/TimePicker.story.js +37 -0
  179. package/source/components/_common/Tooltip/Tooltip.story.js +28 -0
  180. package/source/components/_common/UserMenu/MaterialMenu.story.js +73 -0
  181. package/source/components/_common/VehicleSlider/VehicleSlider.story.js +99 -0
  182. package/source/components/_common/VehicleSlider/VehicleSlider.story.styl +0 -0
  183. package/source/components/_common/withLabel/withLabel.story.js +62 -0
  184. package/source/components/_common/withPopover/withPopover.story.js +48 -0
  185. package/source/components/_common/withPopover/withPopover.story.styl +54 -0
  186. package/source/components/_common/withStats/withStats.story.js +75 -0
  187. package/source/components/_common/withStats/withStats.tsx +1 -1
  188. package/source/framework/DataTransformers.ts +1 -0
  189. package/source/framework/constants/common.ts +8 -4
  190. package/source/framework/types/types.ts +1 -0
  191. package/source/framework/vehiclesProps/decoratedLightProps.tsx +48 -12
  192. package/source/framework/vehiclesProps/decoratedProps.tsx +35 -8
  193. package/source/locales/data.ts +3 -0
  194. package/bytebrand-fe-ui-core-4.8.47.tgz +0 -0
@@ -0,0 +1,335 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import FavoriteSection from '../../../../../source/components/UserDashboardPage/sections/FavoriteSection/FavoriteSection';
4
+ import { observable } from 'mobx';
5
+ import qs from 'qs';
6
+
7
+ const t = (phrase: string | string[], options: object) => {
8
+ if (options) {
9
+ const value = Object.values(options).map((option) => option);
10
+ return `${phrase} ${value}`;
11
+ }
12
+ return phrase;
13
+ };
14
+
15
+ interface IWithRouter {
16
+ children?: JSX.Element;
17
+ link?: string;
18
+ }
19
+ const LinkRouter = ({ children, link }: IWithRouter) => {
20
+ return (
21
+ <a href={link} >
22
+ {children}
23
+ </a>
24
+ );
25
+ };
26
+ const favoriteCars = [
27
+ {
28
+ parkedFor: 'N/A',
29
+ id: 'c4c9141a-5e4c-4d75-9d0f-c2f1b8f31241',
30
+ mainImageId: ' ',
31
+ imagesCount: ' ',
32
+ hasInteriorExteriorPhoto: ' ',
33
+ title: {
34
+ make: 'Volkswagen',
35
+ model: 'Polo',
36
+ subModel: '1.0 TSI Style',
37
+ option: '',
38
+ to: ''
39
+ },
40
+ showNewLabel: false,
41
+ info: {
42
+ regDate: ' ',
43
+ mileage: 0,
44
+ gearbox: 'selector_gearbox_manualShift',
45
+ numberOfPreviousOwners: 0,
46
+ usageType: 'selector_unknown',
47
+ condition: 'selector_condition_new',
48
+ damaged: false,
49
+ driveType: 'selector_driveType_frontWheelDrive'
50
+ },
51
+ location: {
52
+ city: 't',
53
+ street: 't',
54
+ zipCode: 12345
55
+ },
56
+ consumption: {
57
+ fuel: 'selector_fuel_petrol',
58
+ consumptionCombined: 5.2,
59
+ consumptionPowerCombined: ' '
60
+ },
61
+ engineData: {
62
+ powerKW: 70,
63
+ powerPS: 70
64
+ },
65
+ environmentEmissions: {
66
+ co2: 118
67
+ },
68
+ offer: {
69
+ offerId: ' ',
70
+ autoDeOfferId: ' ',
71
+ offerFrom: 'selector_unknown',
72
+ offerSource: ' ',
73
+ offerAvailability: 'selector_unknown',
74
+ offerDescription: '',
75
+ deliveryDate: 1698969600,
76
+ deliveryPeriod: 'selector_deliveryPeriod_days270',
77
+ dealerHomepage: ' ',
78
+ closedDomain: ' ',
79
+ export: ' ',
80
+ commercial: ' ',
81
+ warranty: false,
82
+ rentingPossible: ' ',
83
+ newHuAu: true,
84
+ internalNumber: '118_92436S/3243',
85
+ availabilityMode: 'selector_availabilityMode_fromDate',
86
+ mobileDeOfferId: ' ',
87
+ as24DeOfferId: ' ',
88
+ elnOfferId: 'bd11b00a8d643e16b69c308360e5236b'
89
+ },
90
+ price: {
91
+ offerIndex: 0,
92
+ isStrike: false,
93
+ comparable: {
94
+ annualMileage: 10000,
95
+ firstInstallment: ' ',
96
+ paybackPeriod: 48,
97
+ withAddServices: ' ',
98
+ withTransportation: ' '
99
+ },
100
+ checkout: {
101
+ warrantyRates: [
102
+ 0,
103
+ 0,
104
+ 0
105
+ ],
106
+ warrantyPackage: 0,
107
+ warrantyPeriod: 1,
108
+ admissionService: 0,
109
+ licensePlateFee: 0
110
+ },
111
+ common: {
112
+ firstRegistration: ' ',
113
+ mileage: 0,
114
+ currentSalesPrice: 30666,
115
+ highestPrice: 34232,
116
+ isStrikeShown: true,
117
+ isHybridOrElectric: false
118
+ },
119
+ financing: {
120
+ grossLoanAmountWithoutFinalInstallment: 0,
121
+ purchasePrice: 0,
122
+ hasPaymentProtection: false,
123
+ paymentProtectionInsurance: 0,
124
+ monthlyInstallment: 142,
125
+ oldMonthlyInstallment: 180,
126
+ annualMileage: 25000,
127
+ firstInstallment: 11900,
128
+ withTransportation: false,
129
+ withAddServices: true,
130
+ addServicesCostRaw: 799,
131
+ addServicesCost: 799,
132
+ transportationCostRaw: 499,
133
+ transportationCost: 499,
134
+ withFinalInstallment: true,
135
+ paybackPeriod: 72,
136
+ rawPaybackPeriod: 72,
137
+ nominalInterestRate: 3.92,
138
+ annualPercentageRate: 6.99,
139
+ financialInstitution: 'Santander Consumer Bank AG, Santander-Platz 1, 41061 Mönchengladbach',
140
+ periodInterestRate: [
141
+ {
142
+ duration: 12,
143
+ recommended: 70,
144
+ current: 88,
145
+ inEUR: ' ',
146
+ value: 18766,
147
+ highestValue: 30124.16
148
+ },
149
+ {
150
+ duration: 24,
151
+ recommended: 66,
152
+ current: 77,
153
+ inEUR: ' ',
154
+ value: 18766,
155
+ highestValue: 26358.64
156
+ },
157
+ {
158
+ duration: 36,
159
+ recommended: 60,
160
+ current: 66,
161
+ inEUR: ' ',
162
+ value: 18766,
163
+ highestValue: 22593.12
164
+ },
165
+ {
166
+ duration: 48,
167
+ recommended: 50,
168
+ current: 60,
169
+ inEUR: ' ',
170
+ value: 17920.2,
171
+ highestValue: 20539.2
172
+ },
173
+ {
174
+ duration: 60,
175
+ recommended: 40,
176
+ current: 50,
177
+ inEUR: ' ',
178
+ value: 14933.5,
179
+ highestValue: 17116
180
+ },
181
+ {
182
+ duration: 72,
183
+ recommended: 30,
184
+ current: 40,
185
+ inEUR: ' ',
186
+ value: 11946.8,
187
+ highestValue: 13692.8
188
+ },
189
+ {
190
+ duration: 84,
191
+ recommended: 20,
192
+ current: 30,
193
+ inEUR: ' ',
194
+ value: 8960.1,
195
+ highestValue: 10269.6
196
+ },
197
+ {
198
+ duration: 96,
199
+ recommended: 10,
200
+ current: 20,
201
+ inEUR: ' ',
202
+ value: 5973.4,
203
+ highestValue: 6846.4
204
+ }
205
+ ],
206
+ closingCosts: 0,
207
+ offersFinancing: true,
208
+ rateMode: 'dealer'
209
+ },
210
+ buy: {
211
+ withTransportation: false,
212
+ withAddServices: true,
213
+ withoutAddServices: true,
214
+ transportationCost: 499,
215
+ addServicesCost: 799,
216
+ currentSalesPriceExtra: 30666,
217
+ highestPriceExtra: 34232,
218
+ extraCost: 0
219
+ },
220
+ leasing: {
221
+ RWG: 7,
222
+ maxAge: 24,
223
+ maxMileage: 1000000,
224
+ isActive: true,
225
+ withTransportation: false,
226
+ withAddServices: false,
227
+ addServicesCostRaw: 799,
228
+ transportationCostRaw: 499,
229
+ addServicesCost: 799,
230
+ transportationCost: 499,
231
+ monthlyAddServices: 0,
232
+ monthlyTransportation: 0,
233
+ monthlyInstallment: 441,
234
+ oldMonthlyInstallment: 526,
235
+ firstInstallment: 20,
236
+ firstInstallmentMax: 2000,
237
+ annualMileage: 10000,
238
+ paybackPeriodRange: [
239
+ 30,
240
+ 36,
241
+ 42,
242
+ 48,
243
+ 54,
244
+ 60
245
+ ],
246
+ paybackPeriod: 48,
247
+ santanderPayBackMin: 250,
248
+ nominalInterestRate: 6.78,
249
+ financialInstitution: 'Santander Consumer Bank AG, Santander-Platz 1, 41061 Mönchengladbach',
250
+ grossLoanAmountWithoutFinalInstallment: 0,
251
+ hasPaymentProtection: false,
252
+ paymentProtectionInsurance: 1100,
253
+ leasingMode: 'default',
254
+ currentSalesPrice: 30666
255
+ },
256
+ abo: {
257
+ paybackPeriod: 6,
258
+ annualMileage: 10000
259
+ },
260
+ firstRegistration: ' ',
261
+ mileage: 0,
262
+ currentSalesPrice: 30666,
263
+ highestPrice: 34232,
264
+ isStrikeShown: true,
265
+ carId: 'c4c9141a-5e4c-4d75-9d0f-c2f1b8f31241',
266
+ offerName: 'financing',
267
+ vehicleId: 'c4c9141a-5e4c-4d75-9d0f-c2f1b8f31241',
268
+ vatRate: 19,
269
+ mlCurrentSalesPricePredicted: ' ',
270
+ historyPriceDifference: 3566,
271
+ historyPriceDifferencePerCent: 10,
272
+ margin: 30666,
273
+ toRound: false
274
+ },
275
+ internalNumber: '118_92436S/3243',
276
+ vin: '',
277
+ isOnline: true,
278
+ firstIsOnline: 1675668230,
279
+ url: '/search/vehicle/c4c9141a-5e4c-4d75-9d0f-c2f1b8f31241',
280
+ relativeScore: 0,
281
+ baseUrl: '',
282
+ offerSource: '',
283
+ crawledAt: '',
284
+ ownerName: 'Guardian of Auto.de',
285
+ modificationDate: '18.05.2023',
286
+ seoText: ''
287
+ }
288
+ ];
289
+ const favoritesIDs = [
290
+ 'b359d74f-bb96-4fca-9539-579792fe7c36'
291
+ ];
292
+ const getFavoriteCarsMock = jest.fn();
293
+
294
+ const aggStatsData = observable({
295
+ 'b359d74f-bb96-4fca-9539-579792fe7c36': {
296
+ carId: 'b359d74f-bb96-4fca-9539-579792fe7c36',
297
+ totalFavCount: 3,
298
+ totalCarImpCount: 7399,
299
+ slidingCarImpCount: 10
300
+ },
301
+ get() {
302
+ return {
303
+ 'b359d74f-bb96-4fca-9539-579792fe7c36': {
304
+ carId: 'b359d74f-bb96-4fca-9539-579792fe7c36',
305
+ totalFavCount: 3,
306
+ totalCarImpCount: 7399,
307
+ slidingCarImpCount: 10
308
+ }
309
+ };
310
+ }
311
+ });
312
+ const mockProps = {
313
+ t,
314
+ LinkRouter,
315
+ favoriteCars,
316
+ PLACEHOLDER_IMAGE_SMALL_URL: 'PLACEHOLDER_IMAGE_SMALL_URL',
317
+ favoriteStore: { favoriteCars, favoritesIDs, showList: true, getFavouriteCars: getFavoriteCarsMock, getFavoritesIDs: jest.fn() },
318
+ appStore: {},
319
+ carsStore: { aggStatsData, getAggStatsData: jest.fn() },
320
+ imagesStore: { getSupportedImageFormat: jest.fn() }
321
+ };
322
+
323
+ describe('FavoriteSection', () => {
324
+ test('calls getFavouriteCars when component is mounted', () => {
325
+ const { container } = render(<FavoriteSection {...mockProps as any} />);
326
+ expect(container).toBeInTheDocument();
327
+ // expect(mockProps.favoriteStore.getFavouriteCars).toHaveBeenCalledTimes(1);
328
+ });
329
+ test('should display correct car data', () => {
330
+ const { container } = render(<FavoriteSection {...mockProps as any} />);
331
+ mockProps.favoriteCars.forEach((element:any) => {
332
+ expect(container).toHaveTextContent(element.title.make);
333
+ });
334
+ });
335
+ });
@@ -0,0 +1,127 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react'
3
+ import AdditionalOrderInfo from '../../../../../source/components/UserDashboardPage/sections/OrderStatusSection/AdditionalOrderInfo';
4
+ import { getFormattedPrice } from '../../../../../source/framework/utils/CommonUtils';
5
+
6
+ const t = (phrase: string | string[], options?: object): string | string[] => {
7
+ if (options) {
8
+ const value = Object.values(options).map((option) => option)
9
+ return `${phrase} ${value}`;
10
+ }
11
+ return phrase;
12
+ }
13
+
14
+ const commonProps = {
15
+ t,
16
+ redirectToUrl: () => {},
17
+ }
18
+
19
+ const additionalOrderData = (buyingType: 'buy' | 'leasing' | 'financing', objectData: any) => {
20
+ const {
21
+ customerFirstname,
22
+ customerLastname,
23
+ currentSalesPrice,
24
+ preparationCost,
25
+ registrationCost,
26
+ licensePlateCost,
27
+ transportationCost,
28
+ monthlyInstallment,
29
+ paybackPeriod,
30
+ deposit
31
+ } = objectData;
32
+ return {
33
+ addressData: [
34
+ { label: 'Billing address:', value: `${customerFirstname} ${customerLastname}` },
35
+ { label: 'Vehicle delivery:', value: 'Hannes Käther, Wittenberger Str. 81, 04129 Leipzig' }
36
+ ],
37
+ carPriceData: [
38
+ { label: 'Car price', value: getFormattedPrice(currentSalesPrice, '$,.2f', ' €') },
39
+ { label: 'Preparation cost', value: getFormattedPrice(preparationCost, '$,.2f', ' €')},
40
+ { label: 'vehicle registration', value: getFormattedPrice(registrationCost, '$,.2f', ' €') },
41
+ { label: 'license plates', value: getFormattedPrice(licensePlateCost, '$,.2f', ' €') },
42
+ { label: 'Delivery', value: getFormattedPrice(transportationCost, '$,.2f', ' €') },
43
+ ...(buyingType !== 'buy') ? [
44
+ { label: `${buyingType} rate`, value: `${getFormattedPrice(monthlyInstallment, '$,.2f', '', '€')} per month` },
45
+ { label: 'Running time (months)', value: `${paybackPeriod} months` },
46
+ { label: 'Deposit', value: getFormattedPrice(deposit, '$,.2f', ' €') }
47
+ ] : []
48
+ ],
49
+ overallRate: {
50
+ label: 'Your overall rate',
51
+ value: buyingType === 'buy' ? currentSalesPrice : monthlyInstallment
52
+ }
53
+ };
54
+ }
55
+
56
+ describe('AdditionalOrderInfo', () => {
57
+ it('renders AdditionalOrderInfo component without error', () => {
58
+ const objectData = {
59
+ customerFirstname: 'firstName',
60
+ customerLastname: 'lastName',
61
+ currentSalesPrice: 12000,
62
+ preparationCost: 1200,
63
+ registrationCost: 1000,
64
+ licensePlateCost: 1200,
65
+ transportationCost: 3000,
66
+ monthlyInstallment: 1000,
67
+ paybackPeriod: 48,
68
+ deposit: 5000
69
+ }
70
+
71
+ const additionalOrderInfoProps = {
72
+ ...commonProps,
73
+ buyingType: 'leasing',
74
+ additionalOrderData: additionalOrderData('leasing', objectData)
75
+ }
76
+ const { container } = render(<AdditionalOrderInfo {...additionalOrderInfoProps} />);
77
+ expect(container).toBeInTheDocument();
78
+ });
79
+
80
+ it('renders AdditionalOrderInfo component without some data', () => {
81
+ const objectData = {
82
+ customerFirstname: 'firstName',
83
+ customerLastname: 'lastName',
84
+ currentSalesPrice: 12000,
85
+ preparationCost: 1200,
86
+ registrationCost: 1000
87
+ }
88
+
89
+ const additionalOrderInfoProps = {
90
+ ...commonProps,
91
+ buyingType: 'leasing',
92
+ additionalOrderData: additionalOrderData('leasing', objectData)
93
+ }
94
+ const { container } = render(<AdditionalOrderInfo {...additionalOrderInfoProps} />);
95
+ expect(container).toBeInTheDocument();
96
+ });
97
+
98
+ it('renders AdditionalOrderInfo component with "buy" buying type', () => {
99
+ const objectData = {
100
+ customerFirstname: 'firstName',
101
+ customerLastname: 'lastName',
102
+ currentSalesPrice: 12000,
103
+ preparationCost: 1200,
104
+ registrationCost: 1000
105
+ }
106
+
107
+ const additionalOrderInfoProps = {
108
+ ...commonProps,
109
+ buyingType: 'buy',
110
+ additionalOrderData: additionalOrderData('buy', objectData)
111
+ }
112
+ const { container } = render(<AdditionalOrderInfo {...additionalOrderInfoProps} />);
113
+ expect(container).toBeInTheDocument();
114
+ });
115
+
116
+ it('renders AdditionalOrderInfo component without any data', () => {
117
+ const objectData = {};
118
+
119
+ const additionalOrderInfoProps = {
120
+ ...commonProps,
121
+ buyingType: 'leasing',
122
+ additionalOrderData: additionalOrderData('leasing', objectData)
123
+ }
124
+ const { container } = render(<AdditionalOrderInfo {...additionalOrderInfoProps} />);
125
+ expect(container).toBeInTheDocument();
126
+ });
127
+ });
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+ import { render, fireEvent } from '@testing-library/react';
3
+ import OrderStatusCar from '../../../../../source/components/UserDashboardPage/sections/OrderStatusSection/OrderStatusCar';
4
+
5
+ const t = (phrase: string | string[], options?: object): string | string[] => {
6
+ if (options) {
7
+ const value = Object.values(options).map((option) => option)
8
+ return `${phrase} ${value}`;
9
+ }
10
+ return phrase;
11
+ };
12
+
13
+ const mockProps = {
14
+ t,
15
+ make: 'Test Make',
16
+ model: 'Test Model',
17
+ subModel: 'test car',
18
+ buyingType: 'buy',
19
+ imageUrl: 'https://images.autode-dev.de/carimage/28121b1a-398c-4e9c-9097-51be545817c5/RQ_mHNek5hIk/small-cached.webp',
20
+ selfPickup: false,
21
+ paybackPeriod: 12,
22
+ monthlyInstallment: 2000,
23
+ status: 'selector_status_order_received',
24
+ request: '1234abcd',
25
+ registration: false,
26
+ currentSalesPrice: 30000,
27
+ onClick: jest.fn()
28
+ };
29
+
30
+ describe('OrderStatusCar', () => {
31
+ it('renders OrderStatusCar component without error', () => {
32
+ const { container } = render(<OrderStatusCar {...mockProps} />);
33
+ expect(container).toBeInTheDocument();
34
+ });
35
+
36
+ it('should display correct car make and model', () => {
37
+ const { getByText } = render(<OrderStatusCar {...mockProps} />);
38
+ expect(getByText(`${mockProps.make} ${mockProps.model}`)).toBeInTheDocument();
39
+ });
40
+
41
+ it('should display correct car characteristics', () => {
42
+ const { getByText } = render(<OrderStatusCar {...mockProps} />);
43
+ expect(getByText(mockProps.subModel)).toBeInTheDocument();
44
+ });
45
+
46
+ it('should display correct car image', () => {
47
+ const { getByTestId } = render(<OrderStatusCar {...mockProps}/>);
48
+ const carImage = getByTestId('car-image');
49
+ expect(carImage).toHaveAttribute('src', mockProps.imageUrl);
50
+ });
51
+
52
+ it('should call onClick function when user clicks on the car card', () => {
53
+ const { getByTestId } = render(<OrderStatusCar {...mockProps} />);
54
+ const carCard = getByTestId('car-card');
55
+ fireEvent.click(carCard);
56
+ expect(mockProps.onClick).toHaveBeenCalled();
57
+ });
58
+ });
@@ -0,0 +1,74 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import OrderStatusCard from '../../../../../source/components/UserDashboardPage/sections/OrderStatusSection/OrderStatusCard';
4
+
5
+ describe('OrderStatusCard', () => {
6
+ const icon = 'orderReceivedDashboard';
7
+ const title = 'Test title';
8
+ const description = 'Test description';
9
+ it('render container without errors', () => {
10
+ const { container } = render(
11
+ <OrderStatusCard
12
+ icon={icon}
13
+ title={title}
14
+ description={description}
15
+ />
16
+ );
17
+ expect(container).toBeInTheDocument();
18
+ });
19
+
20
+ it('renders a card with title, description, and icon', () => {
21
+ const { getByText, container, debug } = render(
22
+ <OrderStatusCard
23
+ icon={icon}
24
+ title={title}
25
+ description={description}
26
+ />
27
+ );
28
+ const cardTitle = getByText(title);
29
+ expect(cardTitle).toBeInTheDocument();
30
+ const cardDescription = getByText(description);
31
+ expect(cardDescription).toBeInTheDocument();
32
+ const svgElement = container.querySelector('svg');
33
+ expect(svgElement).toBeInTheDocument();
34
+ });
35
+
36
+ it('adds "notReachedTitle" class for title when "isDisabled" prop is set', () => {
37
+ const { getByTestId, debug } = render(
38
+ <OrderStatusCard
39
+ icon={icon}
40
+ title={title}
41
+ description={description}
42
+ isDisabled={true}
43
+ />
44
+ );
45
+ const cardTitle = getByTestId('cardTitle');
46
+ expect(cardTitle).toHaveClass('notReachedTitle');
47
+ });
48
+
49
+ it('adds "isDoneTitle" class for title when "isDone" prop is set', () => {
50
+ const { getByTestId, debug } = render(
51
+ <OrderStatusCard
52
+ icon={icon}
53
+ title={title}
54
+ description={description}
55
+ isDone={true}
56
+ />
57
+ );
58
+ const cardTitle = getByTestId('cardTitle');
59
+ expect(cardTitle).toHaveClass('isDoneTitle');
60
+ });
61
+
62
+ it('adds "cardInProgress" class for card when "isActive" prop is set', () => {
63
+ const { getByTestId, debug } = render(
64
+ <OrderStatusCard
65
+ icon={icon}
66
+ title={title}
67
+ description={description}
68
+ isActive={true}
69
+ />
70
+ );
71
+ const orderStatusCard = getByTestId('orderStatusCard');
72
+ expect(orderStatusCard).toHaveClass('cardInProgress');
73
+ });
74
+ });
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react'
3
+ import OrderStatusSection from '../../../../../source/components/UserDashboardPage/sections/OrderStatusSection/OrderStatusSection';
4
+ import { car } from '../../../../mockedData/mockedPendingRequestedCar';
5
+
6
+ const t = (phrase: string | string[], options?: object): string | string[] => {
7
+ if (options) {
8
+ const value = Object.values(options).map((option) => option)
9
+ return `${phrase} ${value}`;
10
+ }
11
+ return phrase;
12
+ }
13
+ const leasingCar = car;
14
+ const financingCar = { ...car, buyingType: 'financing' };
15
+ const buyCar = { ...car, buyingType: 'buy' };
16
+
17
+ const commonProps = {
18
+ t,
19
+ isFetching: false,
20
+ getSupportedImageFormat: () => {
21
+ return 'https://images.autode-dev.de/carimage/28121b1a-398c-4e9c-9097-51be545817c5/RQ_mHNek5hIk/small-cached.webp'
22
+ },
23
+ redirectToUrl: () => {},
24
+ }
25
+
26
+ describe('OrderStatusSection', () => {
27
+ it('renders OrderStatusSection component without error', () => {
28
+ const orderStatusSectionProps = {
29
+ ...commonProps,
30
+ orderedCars: [
31
+ leasingCar,
32
+ financingCar,
33
+ buyCar
34
+ ]
35
+ }
36
+ const { container } = render(<OrderStatusSection {...orderStatusSectionProps} />);
37
+ expect(container).toBeInTheDocument();
38
+ });
39
+
40
+ it('renders OrderStatusSection component without cars', () => {
41
+ const orderStatusSectionProps = {
42
+ ...commonProps,
43
+ orderedCars: [] as any[]
44
+ }
45
+ const { container } = render(<OrderStatusSection {...orderStatusSectionProps} />);
46
+ expect(container).toBeInTheDocument();
47
+ });
48
+
49
+ it('renders OrderStatusSection component with additional data', () => {
50
+ const orderStatusSectionProps = {
51
+ ...commonProps,
52
+ withAdditionalData: true,
53
+ orderedCars: [
54
+ leasingCar,
55
+ financingCar,
56
+ buyCar
57
+ ]
58
+ }
59
+ const { container } = render(<OrderStatusSection {...orderStatusSectionProps} />);
60
+ expect(container).toBeInTheDocument();
61
+ });
62
+ });