@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.
- package/.husky/pre-push +4 -0
- package/.storybook/addons.js +4 -0
- package/.storybook/config.js +64 -0
- package/.storybook/postcss.config.js +6 -0
- package/.storybook/preview-head.html +10 -0
- package/.storybook/webpack.config.js +130 -0
- package/__tests__/components/Checkout/OrderOverviewItem/OrderOverviewItem.test.tsx +42 -0
- package/__tests__/components/Checkout/PaymentTypeCard/PaymentTypeCard.test.tsx +50 -0
- package/__tests__/components/Checkout/RadioGroup.test.tsx +95 -0
- package/__tests__/components/Checkout/ServiceCardWrapper.test.tsx +53 -0
- package/__tests__/components/Checkout/Switcher.test.tsx +43 -0
- package/__tests__/components/UserDasboardPage/sections/CheckoutSection/CheckoutSection.test.tsx +613 -0
- package/__tests__/components/UserDasboardPage/sections/FavoriteSection/FavoriteSection.test.tsx +335 -0
- package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/AdditionalOrderInfo.test.tsx +127 -0
- package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/OrderStatusCar.test.tsx +58 -0
- package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/OrderStatusCard.test.tsx +74 -0
- package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/OrderStatusSection.test.tsx +62 -0
- package/__tests__/components/UserDasboardPage/sections/RequestedCarsSection/RequestedCarsSection.test.tsx +117 -0
- package/__tests__/components/Vehicle/VehicleFormattedPrice/VehicleFormattedPrice.test.tsx +58 -0
- package/__tests__/components/VehicleSmallCard/VehicleInfo.test.tsx +88 -0
- package/__tests__/components/VehicleSmallCard/VehicleTitle.test.tsx +91 -0
- package/__tests__/components/_common/Badge/Badge.test.tsx +15 -0
- package/__tests__/components/_common/IconSVG/IconSVG.test.tsx +23 -0
- package/__tests__/components/_common/Image/Image.test.tsx +82 -0
- package/__tests__/components/_common/MaterialAutocomplete/MaterialAutocomplete.test.tsx +49 -0
- package/__tests__/components/_common/MaterialDatePicker/MaterialDatePicker.test.tsx +54 -0
- package/__tests__/components/_common/MaterialField/MaterialField.test.tsx +58 -0
- package/__tests__/components/_common/StarButton/StarButton.test.tsx +46 -0
- package/__tests__/mockedData/financingConfig.js +202 -0
- package/__tests__/mockedData/mockedPendingRequestedCar.js +69 -0
- package/__tests__/utils/CommonUtils/addPrefixToKeys.test.ts +18 -0
- package/__tests__/utils/CommonUtils/arrToObj.test.js +32 -0
- package/__tests__/utils/CommonUtils/checkRangeValuesOnEqual.test.ts +17 -0
- package/__tests__/utils/CommonUtils/fixNumber.test.ts +20 -0
- package/__tests__/utils/CommonUtils/formatMileage.test.ts +8 -0
- package/__tests__/utils/CommonUtils/getChipFilterValue.test.ts +22 -0
- package/__tests__/utils/CommonUtils/getFormattedNumber.test.ts +19 -0
- package/__tests__/utils/CommonUtils/getFormattedPrice.test.ts +19 -0
- package/__tests__/utils/CommonUtils/getGroupValuesForQuery.test.ts +51 -0
- package/__tests__/utils/CommonUtils/getOfferSliders.test.ts +64 -0
- package/__tests__/utils/CommonUtils/getPriceRating.test.ts +26 -0
- package/__tests__/utils/CommonUtils/getPriceRatingConfig.test.ts +33 -0
- package/__tests__/utils/CommonUtils/preloadNearbyImages.test.ts +9 -0
- package/__tests__/utils/CommonUtils/sliceLessThan.test.ts +23 -0
- package/__tests__/utils/CommonUtils/sliceMoreThan.test.ts +23 -0
- package/media/locales/de/promoSlider.json +1 -0
- package/media/locales/en/promoSlider.json +1 -0
- package/package.json +3 -5
- package/source/components/AccordionWidget/AccordionWidget.styl +1 -0
- package/source/components/AccordionWidget/AccordionWidget.tsx +8 -4
- package/source/components/AdvantageItem/AdvantageItem.story.js +23 -0
- package/source/components/Alternative/Dealer.story.js +32 -0
- package/source/components/Alternative/Dealer.story.styl +3 -0
- package/source/components/Breadcrumbs/Breadcrumbs.story.js +40 -0
- package/source/components/Breadcrumbs/FirstInfoBlock/FirstInfoBlock.story.js +45 -0
- package/source/components/Checkout/OrderOverviewItem/OrderOverviewItem.story.js +243 -0
- package/source/components/Checkout/OrderOverviewItem/OrderOverviewItem.story.styl +21 -0
- package/source/components/Checkout/RadioCards/RadioGroupCheckout.story.js +105 -0
- package/source/components/Checkout/RadioCards/RadioGroupCheckout.story.styl +37 -0
- package/source/components/Checkout/Switcher/Switcher.story.js +41 -0
- package/source/components/Checkout/Switcher/Switcher.story.styl +2 -0
- package/source/components/CompactSearchWidget/CompactSearchWidget.story.js +187 -0
- package/source/components/ContactForm/ContactForm.story.js +94 -0
- package/source/components/ContactForm/ContactForm.story.styl +0 -0
- package/source/components/ContactInfo/ContactInfo.story.js +58 -0
- package/source/components/CustomerQuote/CustomerQuote.story.js +41 -0
- package/source/components/CustomerQuotesSlider/CustomerQuotesSlider.story.js +73 -0
- package/source/components/CustomerQuotesSlider/CustomerQuotesSlider.story.styl +5 -0
- package/source/components/FormattedNumber/FormattedNumber.story.js +114 -0
- package/source/components/InfoBlocks/InfoBlockWrapper.story.js +101 -0
- package/source/components/InfoBlocks/InfoBlockWrapper.story.styl +46 -0
- package/source/components/OfferPanel/AboAccordion/AboFaq/AboFaq.story.js +97 -0
- package/source/components/OfferPanel/OfferPanel.story.js +139 -0
- package/source/components/OfferPanel/RangeGroup/RangeGroup.story.js +35 -0
- package/source/components/OfferPanel/RangeGroup/RangeGroup.story.styl +3 -0
- package/source/components/PriceRating/PriceRating.story.js +39 -0
- package/source/components/PriceRating/PriceRating.story.styl +2 -0
- package/source/components/PriceRatingDetailed/PriceRatingDetailed.story.js +78 -0
- package/source/components/PriceRatingDetailed/PriceRatingDetailed.story.styl +11 -0
- package/source/components/RateSearchValue/RateSearchValue.story.js +78 -0
- package/source/components/RateSearchValue/RateSearchValue.story.styl +2 -0
- package/source/components/RateSearchWidget/RateSearchWidget.story.js +57 -0
- package/source/components/RateSearchWidget/RateSearchWidget.story.styl +12 -0
- package/source/components/SearchFilters/FiltersFactory.story.js +273 -0
- package/source/components/SearchPage/Filters/MakeModel/MakeModel.story.js +12 -0
- package/source/components/SearchWidget/BasicDataWidget/BasicDataWidget.story.js +834 -0
- package/source/components/SearchWidget/BasicDataWidget/BasicDataWidget.story.styl +40 -0
- package/source/components/SearchWidget/SearchWidget.story.js +191 -0
- package/source/components/SearchWidget/SearchWidget.story.styl +6 -0
- package/source/components/Stepper/Stepper.story.js +119 -0
- package/source/components/Stepper/Stepper.story.styl +41 -0
- package/source/components/Theme.story.js +36 -0
- package/source/components/Theme.story.styl +85 -0
- package/source/components/TickerText/TickerText.story.js +17 -0
- package/source/components/UserDashboardPage/sections/OrderStatusSection/OrderStatusSection.story.js +95 -0
- package/source/components/UserDashboardPage/sections/RequestedCarsSection/RequestedCarsSection.story.js +97 -0
- package/source/components/Vehicle/VehicleConsumption/VehicleConsumption.story.js +31 -0
- package/source/components/Vehicle/VehicleFormattedPrice/VehicleFormattedPrice.story.js +247 -0
- package/source/components/VehicleCompared/CompareGeneral/CompareGeneral.story.js +30 -0
- package/source/components/VehicleCompared/ComparePrice/ComparePrice.story.js +18 -0
- package/source/components/VehicleCompared/CompareTitle/CompareTitle.story.js +19 -0
- package/source/components/VehicleDetailedSidebar/VehicleDetailedSidebar.story.js +44 -0
- package/source/components/VehicleDetailedSidebar/VehicleDetailedSidebar.tsx +23 -11
- package/source/components/VehicleDetailedSlider/VehicleDetailedSlider.story.js +120 -0
- package/source/components/VehicleDetailedSlider/VehicleDetailedSlider.tsx +2 -0
- package/source/components/VehicleDetailedSlider/partials/PriceData.tsx +48 -45
- package/source/components/VehiclePromoSlider/VehiclePromoInfo/VehiclePromoInfo.story.js +42 -0
- package/source/components/VehiclePromoSlider/VehiclePromoSlide/VehiclePromoSlide.story.js +62 -0
- package/source/components/VehiclePromoSlider/VehiclePromoSlider.story.js +42 -0
- package/source/components/VehicleSmallCard/VehicleData/VechiclePriceItem/VechiclePriceItem.styl +5 -0
- package/source/components/VehicleSmallCard/VehicleData/VechiclePriceItem/VechiclePriceItem.tsx +3 -1
- package/source/components/VehicleSmallCard/VehicleData/VehicleInfo/VehicleInfo.styl +1 -1
- package/source/components/VehicleSmallCard/VehicleData/VehicleInfo/VehicleInfo.tsx +24 -11
- package/source/components/VehicleSmallCard/VehicleData/VehiclePrice/VehiclePrice.styl +3 -2
- package/source/components/VehicleSmallCard/VehicleData/VehicleProperty/VehicleProperty.styl +4 -1
- package/source/components/VehicleSmallCard/VehicleData/VehicleProperty/VehicleProperty.tsx +3 -2
- package/source/components/VehicleSmallCard/VehicleData/VehicleTitle/VehicleTitle.tsx +1 -1
- package/source/components/VehicleSmallCard/VehicleSmallCard.story.js +412 -0
- package/source/components/VehicleSmallCard/VehicleSmallCard.story.styl +56 -0
- package/source/components/VehicleSmallCard/VehicleSmallCard.tsx +14 -3
- package/source/components/VehicleSmallCardForDealerships/VehicleSmallCardForDealerships.story.js +199 -0
- package/source/components/VehicleSmallCardForDealerships/VehicleSmallCardForDealerships.story.styl +40 -0
- package/source/components/_common/Accordion/Accordion.story.js +36 -0
- package/source/components/_common/Badge/Badge.story.js +27 -0
- package/source/components/_common/Badge/Badge.story.styl +5 -0
- package/source/components/_common/Bubble/Bubble.story.js +52 -0
- package/source/components/_common/Button/Button.story.js +52 -0
- package/source/components/_common/Button/Button.story.styl +5 -0
- package/source/components/_common/ButtonOld/Button.story.js +54 -0
- package/source/components/_common/ButtonOld/Button.story.styl +5 -0
- package/source/components/_common/Checkbox/Checkbox.story.js +85 -0
- package/source/components/_common/Checkbox/Checkbox.story.styl +14 -0
- package/source/components/_common/CheckboxMaterial/CheckboxMaterial.story.js +126 -0
- package/source/components/_common/CheckboxMaterial/CheckboxMaterial.story.styl +14 -0
- package/source/components/_common/Chip/Chip.story.js +43 -0
- package/source/components/_common/ChipList/ChipList.story.js +36 -0
- package/source/components/_common/DropDown/DropDown.story.js +35 -0
- package/source/components/_common/ExpandablePanel/ExpandablePanel.story.js +41 -0
- package/source/components/_common/Histogram/Histogram.story.js +51 -0
- package/source/components/_common/IconSVG/IconSVG.story.js +21 -0
- package/source/components/_common/IconSVG/IconSVG.story.styl +25 -0
- package/source/components/_common/Image/Image.story.js +142 -0
- package/source/components/_common/Image/Image.story.styl +18 -0
- package/source/components/_common/ImagesSet/ImagesSet.story.js +34 -0
- package/source/components/_common/ImagesSet/ImagesSet.story.styl +4 -0
- package/source/components/_common/Loader/Loader.story.js +21 -0
- package/source/components/_common/MaterialAccordionGroup/MaterialAccordionGroup.story.js +49 -0
- package/source/components/_common/MaterialAccordionGroup/MaterialAccordionGroup.styled.tsx +4 -1
- package/source/components/_common/MaterialDatePicker/MaterialDatePicker.story.js +45 -0
- package/source/components/_common/MaterialDatePicker/MaterialDatePicker.story.styl +6 -0
- package/source/components/_common/MaterialField/MaterialField.story.js +87 -0
- package/source/components/_common/MaterialField/MaterialField.story.styl +34 -0
- package/source/components/_common/MaterialSelect/MaterialSelect.story.js +52 -0
- package/source/components/_common/MaterialSelect/MaterialSelect.story.styl +6 -0
- package/source/components/_common/MaterialStepButton/MaterialStepButton.story.js +47 -0
- package/source/components/_common/MaterialStepButton/MaterialStepButton.story.styl +6 -0
- package/source/components/_common/MaterialSwitch/MaterialSwitch.story.js +17 -0
- package/source/components/_common/MaterialTooltip/MaterialTooltip.story.js +10 -0
- package/source/components/_common/Modal/Modal.story.js +37 -0
- package/source/components/_common/MuiGroupedSelect/MuiGroupedSelect.story.js +21 -0
- package/source/components/_common/PropertySelector/PSGroup.story.js +93 -0
- package/source/components/_common/PropertySelector/PSGroup.story.styl +25 -0
- package/source/components/_common/PropertySelector/ProperySelector.story.js +83 -0
- package/source/components/_common/Radio/FormRadioGroup.story.js +28 -0
- package/source/components/_common/Radio/FormRadioGroup.story.styl +2 -0
- package/source/components/_common/Radio/Radio.story.js +54 -0
- package/source/components/_common/Radio/RadioGroup.story.js +90 -0
- package/source/components/_common/Radio/RadioGroup.story.styl +39 -0
- package/source/components/_common/Range/Range.story.js +46 -0
- package/source/components/_common/Range/Range.story.styl +5 -0
- package/source/components/_common/SliderArrow/SliderArrow.story.js +18 -0
- package/source/components/_common/Tabs/Tabs.story.js +56 -0
- package/source/components/_common/TimePicker/TimePicker.story.js +37 -0
- package/source/components/_common/Tooltip/Tooltip.story.js +28 -0
- package/source/components/_common/UserMenu/MaterialMenu.story.js +73 -0
- package/source/components/_common/VehicleSlider/VehicleSlider.story.js +99 -0
- package/source/components/_common/VehicleSlider/VehicleSlider.story.styl +0 -0
- package/source/components/_common/withLabel/withLabel.story.js +62 -0
- package/source/components/_common/withPopover/withPopover.story.js +48 -0
- package/source/components/_common/withPopover/withPopover.story.styl +54 -0
- package/source/components/_common/withStats/withStats.story.js +75 -0
- package/source/components/_common/withStats/withStats.tsx +1 -1
- package/source/framework/DataTransformers.ts +1 -0
- package/source/framework/constants/common.ts +8 -4
- package/source/framework/types/types.ts +1 -0
- package/source/framework/vehiclesProps/decoratedLightProps.tsx +48 -12
- package/source/framework/vehiclesProps/decoratedProps.tsx +35 -8
- package/source/locales/data.ts +3 -0
- package/bytebrand-fe-ui-core-4.8.47.tgz +0 -0
package/.husky/pre-push
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { configure, addDecorator, addParameters } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import i18n from 'i18next';
|
|
4
|
+
import centered from '@storybook/addon-centered/react';
|
|
5
|
+
|
|
6
|
+
import { reactI18nextModule } from 'react-i18next';
|
|
7
|
+
import { withI18next } from 'storybook-addon-i18next';
|
|
8
|
+
import { en, de } from '@bytebrand/i18n-dictionaries';
|
|
9
|
+
|
|
10
|
+
import '!style-loader!css-loader!stylus-loader!../source/theme/colors.styl';
|
|
11
|
+
|
|
12
|
+
i18n
|
|
13
|
+
.use(reactI18nextModule)
|
|
14
|
+
.init({
|
|
15
|
+
whitelist: ['en', 'de'],
|
|
16
|
+
lng: 'de',
|
|
17
|
+
fallbackLng: 'de',
|
|
18
|
+
interpolation: {
|
|
19
|
+
escapeValue: false,
|
|
20
|
+
},
|
|
21
|
+
debug: process.env.NODE_ENV === 'development',
|
|
22
|
+
react: {
|
|
23
|
+
wait: true
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
(err, t) => {
|
|
27
|
+
if (err) {
|
|
28
|
+
return console.error('Something went wrong loading', err);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
i18n.addResourceBundle('en', 'cbd', en, true, true);
|
|
32
|
+
i18n.addResourceBundle('de', 'cbd', de, true, true);
|
|
33
|
+
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
addDecorator(withI18next({
|
|
37
|
+
i18n,
|
|
38
|
+
languages: {
|
|
39
|
+
en: 'English',
|
|
40
|
+
de: 'Deutsch',
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
addParameters({
|
|
45
|
+
options: {
|
|
46
|
+
sortStoriesByKind: true
|
|
47
|
+
},
|
|
48
|
+
backgrounds: [
|
|
49
|
+
{ name: 'white', value: '#fff' },
|
|
50
|
+
{ name: 'grey', value: '#808080', default: true },
|
|
51
|
+
{ name: 'black', value: '#000' }
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
addDecorator(centered);
|
|
56
|
+
|
|
57
|
+
// automatically import all files ending in *.stories.js
|
|
58
|
+
const req = require.context('../source/components', true, /.story.js$/);
|
|
59
|
+
|
|
60
|
+
function loadStories() {
|
|
61
|
+
req.keys().forEach(filename => req(filename));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
configure(loadStories, module);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<link rel="stylesheet" type="text/css" charset="UTF-8"
|
|
2
|
+
href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css" />
|
|
3
|
+
<link rel="stylesheet" type="text/css"
|
|
4
|
+
href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick-theme.min.css" />
|
|
5
|
+
|
|
6
|
+
<link rel="stylesheet" type="text/css"
|
|
7
|
+
href="https://cdn.jsdelivr.net/npm/react-checkbox-tree@1.5.1/lib/react-checkbox-tree.css" />
|
|
8
|
+
|
|
9
|
+
<link rel="stylesheet" type="text/css"
|
|
10
|
+
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" />
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const autoprefixer = require('autoprefixer');
|
|
3
|
+
|
|
4
|
+
const babelPlugins = [
|
|
5
|
+
[require('@babel/plugin-proposal-decorators').default , { legacy: true }],
|
|
6
|
+
require('@babel/plugin-transform-react-constant-elements').default,
|
|
7
|
+
require('@babel/plugin-proposal-class-properties').default,
|
|
8
|
+
require('babel-plugin-minify-dead-code-elimination'),
|
|
9
|
+
require('babel-plugin-transform-imports')
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
const presetOptions = {
|
|
13
|
+
useBuiltIns: 'usage',
|
|
14
|
+
corejs: '2'
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const babelPresets = [
|
|
18
|
+
[require('@babel/preset-env').default, presetOptions],
|
|
19
|
+
require('@babel/preset-react').default,
|
|
20
|
+
require('@babel/preset-typescript').default
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const BABEL_LOADER = {
|
|
24
|
+
loader: require.resolve('babel-loader'),
|
|
25
|
+
options: {
|
|
26
|
+
babelrc: false,
|
|
27
|
+
cacheDirectory: true,
|
|
28
|
+
presets: babelPresets,
|
|
29
|
+
plugins: babelPlugins
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const TSLINT_LOADER = {
|
|
34
|
+
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const CSS_LOADER = ({ modules }) => ({
|
|
38
|
+
loader: require.resolve('css-loader'),
|
|
39
|
+
options: {
|
|
40
|
+
modules,
|
|
41
|
+
sourceMap: true,
|
|
42
|
+
importLoaders: 1,
|
|
43
|
+
localsConvention: 'camelCase'
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const STYLUS_LOADER = {
|
|
48
|
+
loader: require.resolve('stylus-loader'),
|
|
49
|
+
options: {
|
|
50
|
+
sourceMap: 'inline'
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const POST_CSS_LOADER = {
|
|
55
|
+
loader: require.resolve('postcss-loader'),
|
|
56
|
+
options: {
|
|
57
|
+
sourceMap: 'inline',
|
|
58
|
+
ident: 'postcss',
|
|
59
|
+
config: {
|
|
60
|
+
path: path.join(__dirname, './postcss.config.js')
|
|
61
|
+
},
|
|
62
|
+
plugins: () => [
|
|
63
|
+
autoprefixer({
|
|
64
|
+
grid: false
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const STYLE_LOADER = {
|
|
71
|
+
loader: require.resolve('style-loader'),
|
|
72
|
+
options: {
|
|
73
|
+
injectType: 'singletonStyleTag'
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const buildConfig = async ({ config, mode }) => {
|
|
78
|
+
config.module.rules.push({
|
|
79
|
+
enforce: 'pre',
|
|
80
|
+
test: /\.tsx?$/,
|
|
81
|
+
loader: require.resolve('tslint-loader'),
|
|
82
|
+
exclude: '/node_modules/',
|
|
83
|
+
options: {
|
|
84
|
+
emitErrors: true
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
config.module.rules.push({
|
|
89
|
+
test: /\.tsx?$/,
|
|
90
|
+
exclude: /(node_modules|public)\/(?!@bytebrand).*/,
|
|
91
|
+
use: [BABEL_LOADER]
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
config.module.rules.push({
|
|
95
|
+
test: /\.css$/,
|
|
96
|
+
use: [
|
|
97
|
+
STYLE_LOADER,
|
|
98
|
+
CSS_LOADER({ modules: true }),
|
|
99
|
+
POST_CSS_LOADER
|
|
100
|
+
]
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
config.module.rules.push({
|
|
104
|
+
test: /\.styl$/,
|
|
105
|
+
exclude: /\.global.styl$/,
|
|
106
|
+
use: [
|
|
107
|
+
STYLE_LOADER,
|
|
108
|
+
CSS_LOADER({ modules: true }),
|
|
109
|
+
POST_CSS_LOADER,
|
|
110
|
+
STYLUS_LOADER
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// prepend .global to *.stylus file to import it globally
|
|
115
|
+
config.module.rules.push({
|
|
116
|
+
test: /\.global.styl$/,
|
|
117
|
+
use: [
|
|
118
|
+
STYLE_LOADER,
|
|
119
|
+
CSS_LOADER({ modules: false }),
|
|
120
|
+
POST_CSS_LOADER,
|
|
121
|
+
STYLUS_LOADER
|
|
122
|
+
]
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
config.resolve.extensions.push('.ts', '.tsx', '.styl');
|
|
126
|
+
|
|
127
|
+
return config;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
module.exports = buildConfig;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import OrderOverviewItem from '../../../../source/components/Checkout/OrderOverviewItem/OrderOverviewItem';
|
|
4
|
+
|
|
5
|
+
describe('OrderOverviewItem', () => {
|
|
6
|
+
it('renders the component with the correct data', () => {
|
|
7
|
+
const fields = {
|
|
8
|
+
title: 'Test Title',
|
|
9
|
+
oneLineRate: '10',
|
|
10
|
+
additionalTitle: 'Additional Title',
|
|
11
|
+
content: [
|
|
12
|
+
{
|
|
13
|
+
rate: '5',
|
|
14
|
+
fieldName: 'Field Name'
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
rate: '15'
|
|
18
|
+
};
|
|
19
|
+
const activeStep = 1;
|
|
20
|
+
const handleClick = jest.fn();
|
|
21
|
+
render(
|
|
22
|
+
<OrderOverviewItem
|
|
23
|
+
fields={fields}
|
|
24
|
+
activeStep={activeStep}
|
|
25
|
+
handleStep={handleClick}
|
|
26
|
+
titleClassName="test-title-class"
|
|
27
|
+
fieldClassName="test-field-class"
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
// Test that the correct elements are rendered with the correct values
|
|
31
|
+
expect(screen.getByText(fields.title)).toBeInTheDocument();
|
|
32
|
+
expect(screen.getByText(fields.oneLineRate)).toBeInTheDocument();
|
|
33
|
+
expect(screen.getByText(fields.additionalTitle)).toBeInTheDocument();
|
|
34
|
+
expect(screen.getByText(fields.content[0].rate)).toBeInTheDocument();
|
|
35
|
+
// Test that the correct classes are applied
|
|
36
|
+
expect(screen.getByText(fields.title)).toHaveClass('test-title-class');
|
|
37
|
+
expect(screen.getByText(fields.oneLineRate)).toHaveClass('test-field-class');
|
|
38
|
+
// Test that the edit icon is clickable and calls the handleStep function
|
|
39
|
+
expect(screen.getByTestId('editIcon')).toBeInTheDocument();
|
|
40
|
+
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
});
|