@bytebrand/fe-ui-core 4.2.56 → 4.2.58
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.
- package/__tests__/mockedData/financingConfig.js +202 -0
- package/__tests__/utils/CommonUtils/fixNumber.test.ts +20 -0
- package/__tests__/utils/CommonUtils/getChipFilterValue.test.ts +22 -0
- package/__tests__/utils/CommonUtils/getOfferSliders.test.ts +62 -0
- package/__tests__/utils/CommonUtils/getPriceRatingConfig.test.ts +0 -2
- package/package.json +1 -1
- package/source/framework/utils/CommonUtils.ts +0 -3
|
@@ -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,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,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,62 @@
|
|
|
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
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: 'annualMileage',
|
|
17
|
+
min: 5000,
|
|
18
|
+
max: 60000,
|
|
19
|
+
step: 5000,
|
|
20
|
+
unit: 'km',
|
|
21
|
+
value: 40000,
|
|
22
|
+
unitName: 'modals:financing.km',
|
|
23
|
+
caption: 'modals:financing.annualMileage'
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
const expectedResultCheckout = [
|
|
28
|
+
{
|
|
29
|
+
name: 'firstInstallment',
|
|
30
|
+
min: 0,
|
|
31
|
+
step: 100,
|
|
32
|
+
unit: 'euro',
|
|
33
|
+
max: 21666,
|
|
34
|
+
value: 16100,
|
|
35
|
+
unitName: 'modals:financing.euro',
|
|
36
|
+
caption: 'modals:financing.firstInstallment'
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
const t = (phrase: string, options?: object) => {
|
|
41
|
+
return `${phrase} ${options ? options : ''}`.trim();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
describe('getOfferSliders', () => {
|
|
45
|
+
it('should return correct array with slider data for CDP', () => {
|
|
46
|
+
|
|
47
|
+
const priceTabIndex = 0; // financing tab
|
|
48
|
+
const componentType = 'main';
|
|
49
|
+
|
|
50
|
+
const result = getOfferSliders(financingConfig, t, priceTabIndex, componentType);
|
|
51
|
+
expect(result).toEqual(expectedResultCDP);
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('should return correct array with slider data for checkout page without annual mileage for financing', () => {
|
|
55
|
+
|
|
56
|
+
const priceTabIndex = 0; // financing tab
|
|
57
|
+
const componentType = 'checkout';
|
|
58
|
+
|
|
59
|
+
const result = getOfferSliders(financingConfig, t, priceTabIndex, componentType);
|
|
60
|
+
expect(result).toEqual(expectedResultCheckout);
|
|
61
|
+
})
|
|
62
|
+
})
|
package/package.json
CHANGED
|
@@ -19,7 +19,6 @@ declare global {
|
|
|
19
19
|
grantHotjarCookieConsent?: () => void;
|
|
20
20
|
grantCookieConsent?: (list: string[]) => void;
|
|
21
21
|
allowGoogle?: () => void;
|
|
22
|
-
fbq?: (option1: string, option2: string) => void;
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
|
|
@@ -564,8 +563,6 @@ export const updateCookieList = () => {
|
|
|
564
563
|
if (typeof window.grantCookieConsent === 'function') window.grantCookieConsent(cookieConsentList);
|
|
565
564
|
if (isHomeGoogleGranted && typeof window.allowGoogle === 'function') {
|
|
566
565
|
window.allowGoogle();
|
|
567
|
-
// grant FB cookies
|
|
568
|
-
window.fbq('consent', 'grant');
|
|
569
566
|
}
|
|
570
567
|
|
|
571
568
|
// grant Hotjar cookies
|