@bytebrand/fe-ui-core 4.8.55 → 4.8.57
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/media/locales/de/promoSlider.json +0 -1
- package/media/locales/en/promoSlider.json +0 -1
- package/package.json +120 -117
- package/source/components/AccordionWidget/AccordionWidget.styl +0 -1
- package/source/components/AccordionWidget/AccordionWidget.tsx +4 -8
- package/source/components/OfferPanel/OfferCheckboxGroup/CheckboxContainer.tsx +2 -2
- package/source/components/OfferPanel/OfferCheckboxGroup/OfferCheckboxGroup.styl +0 -24
- package/source/components/OfferPanel/OfferCheckboxGroup/OfferCheckboxGroup.tsx +1 -0
- package/source/components/OfferPanel/OfferPanel.tsx +1 -1
- package/source/components/VehicleDetailedSidebar/VehicleDetailedSidebar.tsx +11 -23
- package/source/components/VehicleDetailedSlider/VehicleDetailedSlider.tsx +6 -2
- package/source/components/VehicleDetailedSlider/partials/PriceData.tsx +9 -8
- package/source/components/VehicleSmallCard/VehicleData/VechiclePriceItem/VechiclePriceItem.styl +0 -5
- package/source/components/VehicleSmallCard/VehicleData/VechiclePriceItem/VechiclePriceItem.tsx +1 -3
- package/source/components/VehicleSmallCard/VehicleData/VehicleInfo/VehicleInfo.styl +1 -1
- package/source/components/VehicleSmallCard/VehicleData/VehicleInfo/VehicleInfo.tsx +11 -24
- package/source/components/VehicleSmallCard/VehicleData/VehiclePrice/VehiclePrice.styl +2 -3
- package/source/components/VehicleSmallCard/VehicleData/VehicleProperty/VehicleProperty.styl +1 -4
- package/source/components/VehicleSmallCard/VehicleData/VehicleProperty/VehicleProperty.tsx +2 -3
- package/source/components/VehicleSmallCard/VehicleData/VehicleTitle/VehicleTitle.tsx +1 -1
- package/source/components/VehicleSmallCard/VehicleSmallCard.tsx +3 -14
- package/source/components/_common/MaterialAccordionGroup/MaterialAccordionGroup.styled.tsx +1 -4
- package/source/components/_common/MaterialTooltip/MaterialTooltip.tsx +3 -4
- package/source/components/_common/withStats/withStats.styl +0 -10
- package/source/components/_common/withStats/withStats.tsx +11 -2
- package/source/framework/DataTransformers.ts +0 -1
- package/source/framework/constants/common.ts +4 -8
- package/source/framework/types/types.ts +0 -1
- package/source/framework/vehiclesProps/decoratedLightProps.tsx +12 -48
- package/source/framework/vehiclesProps/decoratedProps.tsx +8 -35
- package/source/locales/data.ts +0 -3
- package/.husky/pre-push +0 -4
- package/.storybook/addons.js +0 -4
- package/.storybook/config.js +0 -64
- package/.storybook/postcss.config.js +0 -6
- package/.storybook/preview-head.html +0 -10
- package/.storybook/webpack.config.js +0 -130
- package/__tests__/components/Checkout/OrderOverviewItem/OrderOverviewItem.test.tsx +0 -42
- package/__tests__/components/Checkout/PaymentTypeCard/PaymentTypeCard.test.tsx +0 -50
- package/__tests__/components/Checkout/RadioGroup.test.tsx +0 -95
- package/__tests__/components/Checkout/ServiceCardWrapper.test.tsx +0 -53
- package/__tests__/components/Checkout/Switcher.test.tsx +0 -43
- package/__tests__/components/UserDasboardPage/sections/CheckoutSection/CheckoutSection.test.tsx +0 -613
- package/__tests__/components/UserDasboardPage/sections/FavoriteSection/FavoriteSection.test.tsx +0 -335
- package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/AdditionalOrderInfo.test.tsx +0 -127
- package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/OrderStatusCar.test.tsx +0 -58
- package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/OrderStatusCard.test.tsx +0 -74
- package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/OrderStatusSection.test.tsx +0 -62
- package/__tests__/components/UserDasboardPage/sections/RequestedCarsSection/RequestedCarsSection.test.tsx +0 -117
- package/__tests__/components/Vehicle/VehicleFormattedPrice/VehicleFormattedPrice.test.tsx +0 -58
- package/__tests__/components/VehicleSmallCard/VehicleInfo.test.tsx +0 -88
- package/__tests__/components/VehicleSmallCard/VehicleTitle.test.tsx +0 -91
- package/__tests__/components/_common/Badge/Badge.test.tsx +0 -15
- package/__tests__/components/_common/IconSVG/IconSVG.test.tsx +0 -23
- package/__tests__/components/_common/Image/Image.test.tsx +0 -82
- package/__tests__/components/_common/MaterialAutocomplete/MaterialAutocomplete.test.tsx +0 -49
- package/__tests__/components/_common/MaterialDatePicker/MaterialDatePicker.test.tsx +0 -54
- package/__tests__/components/_common/MaterialField/MaterialField.test.tsx +0 -58
- package/__tests__/components/_common/StarButton/StarButton.test.tsx +0 -46
- package/__tests__/mockedData/financingConfig.js +0 -202
- package/__tests__/mockedData/mockedPendingRequestedCar.js +0 -69
- package/__tests__/utils/CommonUtils/addPrefixToKeys.test.ts +0 -18
- package/__tests__/utils/CommonUtils/arrToObj.test.js +0 -32
- package/__tests__/utils/CommonUtils/checkRangeValuesOnEqual.test.ts +0 -17
- package/__tests__/utils/CommonUtils/fixNumber.test.ts +0 -20
- package/__tests__/utils/CommonUtils/formatMileage.test.ts +0 -8
- package/__tests__/utils/CommonUtils/getChipFilterValue.test.ts +0 -22
- package/__tests__/utils/CommonUtils/getFormattedNumber.test.ts +0 -19
- package/__tests__/utils/CommonUtils/getFormattedPrice.test.ts +0 -19
- package/__tests__/utils/CommonUtils/getGroupValuesForQuery.test.ts +0 -51
- package/__tests__/utils/CommonUtils/getOfferSliders.test.ts +0 -64
- package/__tests__/utils/CommonUtils/getPriceRating.test.ts +0 -26
- package/__tests__/utils/CommonUtils/getPriceRatingConfig.test.ts +0 -33
- package/__tests__/utils/CommonUtils/preloadNearbyImages.test.ts +0 -9
- package/__tests__/utils/CommonUtils/sliceLessThan.test.ts +0 -23
- package/__tests__/utils/CommonUtils/sliceMoreThan.test.ts +0 -23
- package/source/components/AdvantageItem/AdvantageItem.story.js +0 -23
- package/source/components/Alternative/Dealer.story.js +0 -32
- package/source/components/Alternative/Dealer.story.styl +0 -3
- package/source/components/Breadcrumbs/Breadcrumbs.story.js +0 -40
- package/source/components/Breadcrumbs/FirstInfoBlock/FirstInfoBlock.story.js +0 -45
- package/source/components/Checkout/OrderOverviewItem/OrderOverviewItem.story.js +0 -243
- package/source/components/Checkout/OrderOverviewItem/OrderOverviewItem.story.styl +0 -21
- package/source/components/Checkout/RadioCards/RadioGroupCheckout.story.js +0 -105
- package/source/components/Checkout/RadioCards/RadioGroupCheckout.story.styl +0 -37
- package/source/components/Checkout/Switcher/Switcher.story.js +0 -41
- package/source/components/Checkout/Switcher/Switcher.story.styl +0 -2
- package/source/components/CompactSearchWidget/CompactSearchWidget.story.js +0 -187
- package/source/components/ContactForm/ContactForm.story.js +0 -94
- package/source/components/ContactForm/ContactForm.story.styl +0 -0
- package/source/components/ContactInfo/ContactInfo.story.js +0 -58
- package/source/components/CustomerQuote/CustomerQuote.story.js +0 -41
- package/source/components/CustomerQuotesSlider/CustomerQuotesSlider.story.js +0 -73
- package/source/components/CustomerQuotesSlider/CustomerQuotesSlider.story.styl +0 -5
- package/source/components/FormattedNumber/FormattedNumber.story.js +0 -114
- package/source/components/InfoBlocks/InfoBlockWrapper.story.js +0 -101
- package/source/components/InfoBlocks/InfoBlockWrapper.story.styl +0 -46
- package/source/components/OfferPanel/AboAccordion/AboFaq/AboFaq.story.js +0 -97
- package/source/components/OfferPanel/OfferPanel.story.js +0 -139
- package/source/components/OfferPanel/RangeGroup/RangeGroup.story.js +0 -35
- package/source/components/OfferPanel/RangeGroup/RangeGroup.story.styl +0 -3
- package/source/components/PriceRating/PriceRating.story.js +0 -39
- package/source/components/PriceRating/PriceRating.story.styl +0 -2
- package/source/components/PriceRatingDetailed/PriceRatingDetailed.story.js +0 -78
- package/source/components/PriceRatingDetailed/PriceRatingDetailed.story.styl +0 -11
- package/source/components/RateSearchValue/RateSearchValue.story.js +0 -78
- package/source/components/RateSearchValue/RateSearchValue.story.styl +0 -2
- package/source/components/RateSearchWidget/RateSearchWidget.story.js +0 -57
- package/source/components/RateSearchWidget/RateSearchWidget.story.styl +0 -12
- package/source/components/SearchFilters/FiltersFactory.story.js +0 -273
- package/source/components/SearchPage/Filters/MakeModel/MakeModel.story.js +0 -12
- package/source/components/SearchWidget/BasicDataWidget/BasicDataWidget.story.js +0 -834
- package/source/components/SearchWidget/BasicDataWidget/BasicDataWidget.story.styl +0 -40
- package/source/components/SearchWidget/SearchWidget.story.js +0 -191
- package/source/components/SearchWidget/SearchWidget.story.styl +0 -6
- package/source/components/Stepper/Stepper.story.js +0 -119
- package/source/components/Stepper/Stepper.story.styl +0 -41
- package/source/components/Theme.story.js +0 -36
- package/source/components/Theme.story.styl +0 -85
- package/source/components/TickerText/TickerText.story.js +0 -17
- package/source/components/UserDashboardPage/sections/OrderStatusSection/OrderStatusSection.story.js +0 -95
- package/source/components/UserDashboardPage/sections/RequestedCarsSection/RequestedCarsSection.story.js +0 -97
- package/source/components/Vehicle/VehicleConsumption/VehicleConsumption.story.js +0 -31
- package/source/components/Vehicle/VehicleFormattedPrice/VehicleFormattedPrice.story.js +0 -247
- package/source/components/VehicleCompared/CompareGeneral/CompareGeneral.story.js +0 -30
- package/source/components/VehicleCompared/ComparePrice/ComparePrice.story.js +0 -18
- package/source/components/VehicleCompared/CompareTitle/CompareTitle.story.js +0 -19
- package/source/components/VehicleDetailedSidebar/VehicleDetailedSidebar.story.js +0 -44
- package/source/components/VehicleDetailedSlider/VehicleDetailedSlider.story.js +0 -120
- package/source/components/VehiclePromoSlider/VehiclePromoInfo/VehiclePromoInfo.story.js +0 -42
- package/source/components/VehiclePromoSlider/VehiclePromoSlide/VehiclePromoSlide.story.js +0 -62
- package/source/components/VehiclePromoSlider/VehiclePromoSlider.story.js +0 -42
- package/source/components/VehicleSmallCard/VehicleSmallCard.story.js +0 -412
- package/source/components/VehicleSmallCard/VehicleSmallCard.story.styl +0 -56
- package/source/components/VehicleSmallCardForDealerships/VehicleSmallCardForDealerships.story.js +0 -199
- package/source/components/VehicleSmallCardForDealerships/VehicleSmallCardForDealerships.story.styl +0 -40
- package/source/components/_common/Accordion/Accordion.story.js +0 -36
- package/source/components/_common/Badge/Badge.story.js +0 -27
- package/source/components/_common/Badge/Badge.story.styl +0 -5
- package/source/components/_common/Bubble/Bubble.story.js +0 -52
- package/source/components/_common/Button/Button.story.js +0 -52
- package/source/components/_common/Button/Button.story.styl +0 -5
- package/source/components/_common/ButtonOld/Button.story.js +0 -54
- package/source/components/_common/ButtonOld/Button.story.styl +0 -5
- package/source/components/_common/Checkbox/Checkbox.story.js +0 -85
- package/source/components/_common/Checkbox/Checkbox.story.styl +0 -14
- package/source/components/_common/CheckboxMaterial/CheckboxMaterial.story.js +0 -126
- package/source/components/_common/CheckboxMaterial/CheckboxMaterial.story.styl +0 -14
- package/source/components/_common/Chip/Chip.story.js +0 -43
- package/source/components/_common/ChipList/ChipList.story.js +0 -36
- package/source/components/_common/DropDown/DropDown.story.js +0 -35
- package/source/components/_common/ExpandablePanel/ExpandablePanel.story.js +0 -41
- package/source/components/_common/Histogram/Histogram.story.js +0 -51
- package/source/components/_common/IconSVG/IconSVG.story.js +0 -21
- package/source/components/_common/IconSVG/IconSVG.story.styl +0 -25
- package/source/components/_common/Image/Image.story.js +0 -142
- package/source/components/_common/Image/Image.story.styl +0 -18
- package/source/components/_common/ImagesSet/ImagesSet.story.js +0 -34
- package/source/components/_common/ImagesSet/ImagesSet.story.styl +0 -4
- package/source/components/_common/Loader/Loader.story.js +0 -21
- package/source/components/_common/MaterialAccordionGroup/MaterialAccordionGroup.story.js +0 -49
- package/source/components/_common/MaterialDatePicker/MaterialDatePicker.story.js +0 -45
- package/source/components/_common/MaterialDatePicker/MaterialDatePicker.story.styl +0 -6
- package/source/components/_common/MaterialField/MaterialField.story.js +0 -87
- package/source/components/_common/MaterialField/MaterialField.story.styl +0 -34
- package/source/components/_common/MaterialSelect/MaterialSelect.story.js +0 -52
- package/source/components/_common/MaterialSelect/MaterialSelect.story.styl +0 -6
- package/source/components/_common/MaterialStepButton/MaterialStepButton.story.js +0 -47
- package/source/components/_common/MaterialStepButton/MaterialStepButton.story.styl +0 -6
- package/source/components/_common/MaterialSwitch/MaterialSwitch.story.js +0 -17
- package/source/components/_common/MaterialTooltip/MaterialTooltip.story.js +0 -10
- package/source/components/_common/Modal/Modal.story.js +0 -37
- package/source/components/_common/MuiGroupedSelect/MuiGroupedSelect.story.js +0 -21
- package/source/components/_common/PropertySelector/PSGroup.story.js +0 -93
- package/source/components/_common/PropertySelector/PSGroup.story.styl +0 -25
- package/source/components/_common/PropertySelector/ProperySelector.story.js +0 -83
- package/source/components/_common/Radio/FormRadioGroup.story.js +0 -28
- package/source/components/_common/Radio/FormRadioGroup.story.styl +0 -2
- package/source/components/_common/Radio/Radio.story.js +0 -54
- package/source/components/_common/Radio/RadioGroup.story.js +0 -90
- package/source/components/_common/Radio/RadioGroup.story.styl +0 -39
- package/source/components/_common/Range/Range.story.js +0 -46
- package/source/components/_common/Range/Range.story.styl +0 -5
- package/source/components/_common/SliderArrow/SliderArrow.story.js +0 -18
- package/source/components/_common/Tabs/Tabs.story.js +0 -56
- package/source/components/_common/TimePicker/TimePicker.story.js +0 -37
- package/source/components/_common/Tooltip/Tooltip.story.js +0 -28
- package/source/components/_common/UserMenu/MaterialMenu.story.js +0 -73
- package/source/components/_common/VehicleSlider/VehicleSlider.story.js +0 -99
- package/source/components/_common/VehicleSlider/VehicleSlider.story.styl +0 -0
- package/source/components/_common/withLabel/withLabel.story.js +0 -62
- package/source/components/_common/withPopover/withPopover.story.js +0 -48
- package/source/components/_common/withPopover/withPopover.story.styl +0 -54
- package/source/components/_common/withStats/withStats.story.js +0 -75
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { fireEvent, getByTestId, render, screen } from '@testing-library/react';
|
|
2
|
-
// import userEvent from '@testing-library/user-event';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import RequestedCarsSection from '../../../../../source/components/UserDashboardPage/sections/RequestedCarsSection/RequestedCarsSection';
|
|
5
|
-
|
|
6
|
-
const t = (phrase: string | string[], options: object) => {
|
|
7
|
-
if (options) {
|
|
8
|
-
const value = Object.values(options).map((option) => option);
|
|
9
|
-
return `${phrase} ${value}`;
|
|
10
|
-
}
|
|
11
|
-
return phrase;
|
|
12
|
-
};
|
|
13
|
-
interface IWithRouter {
|
|
14
|
-
children?: JSX.Element;
|
|
15
|
-
link?: string;
|
|
16
|
-
}
|
|
17
|
-
const LinkRouter = ({ children, link } :IWithRouter) => {
|
|
18
|
-
return (
|
|
19
|
-
<a href={link} >
|
|
20
|
-
{ children }
|
|
21
|
-
</a>
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const requestedCars = [
|
|
26
|
-
{
|
|
27
|
-
car: {
|
|
28
|
-
_id: '28121b1a-398c-4e9c-9097-51be545817c5',
|
|
29
|
-
mainData: {
|
|
30
|
-
make: 'Volvo',
|
|
31
|
-
model: 'CX95',
|
|
32
|
-
subModel: 'Test123'
|
|
33
|
-
},
|
|
34
|
-
metaData: {
|
|
35
|
-
mainImageId: 'RQ_mHNek5hIk'
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
buyingType: 'leasing',
|
|
39
|
-
selfPickup: true,
|
|
40
|
-
paybackPeriod: 24,
|
|
41
|
-
monthlyInstallment: 2000,
|
|
42
|
-
request: '010203555',
|
|
43
|
-
currentSalesPrice: 50000
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
car: {
|
|
47
|
-
_id: '1234567890',
|
|
48
|
-
mainData: {
|
|
49
|
-
make: 'Volvo',
|
|
50
|
-
model: 'CX90',
|
|
51
|
-
subModel: 'Test155'
|
|
52
|
-
},
|
|
53
|
-
metaData: {
|
|
54
|
-
mainImageId: 'main image id'
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
buyingType: 'financing',
|
|
58
|
-
selfPickup: false,
|
|
59
|
-
paybackPeriod: 24,
|
|
60
|
-
monthlyInstallment: 1000,
|
|
61
|
-
request: '010203123',
|
|
62
|
-
currentSalesPrice: 20000
|
|
63
|
-
}
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
const mockProps = {
|
|
67
|
-
t,
|
|
68
|
-
LinkRouter,
|
|
69
|
-
requestedCars,
|
|
70
|
-
getSupportedImageFormat: jest.fn(),
|
|
71
|
-
redirectToCar: jest.fn(),
|
|
72
|
-
// tslint:disable-next-line:object-shorthand-properties-first
|
|
73
|
-
initHotjar: () => {}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
describe('RequestedCarsSection', () => {
|
|
77
|
-
it('renders correctly', () => {
|
|
78
|
-
const { container } = render(<RequestedCarsSection {...mockProps as any} />);
|
|
79
|
-
expect(container).toBeInTheDocument();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('should display correct car data', () => {
|
|
83
|
-
const { container } = render(<RequestedCarsSection {...mockProps as any} />);
|
|
84
|
-
const requestedCars = mockProps.requestedCars;
|
|
85
|
-
requestedCars.forEach((element) => {
|
|
86
|
-
expect(container).toHaveTextContent(element.buyingType);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
it('should display correct car make and model', () => {
|
|
90
|
-
const { getByText } = render(<RequestedCarsSection {...mockProps as any} />);
|
|
91
|
-
const requestedCars = mockProps.requestedCars;
|
|
92
|
-
requestedCars.forEach((element) => {
|
|
93
|
-
expect(getByText(`${element.car.mainData.make} ${element.car.mainData.model}`)).toBeInTheDocument();
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
it('should display correct car subModel', () => {
|
|
97
|
-
const { getByText } = render(<RequestedCarsSection {...mockProps as any} />);
|
|
98
|
-
const requestedCars = mockProps.requestedCars;
|
|
99
|
-
requestedCars.forEach((element) => {
|
|
100
|
-
expect(getByText(`${element.car.mainData.subModel}`)).toBeInTheDocument();
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
it('should display correct car request number', () => {
|
|
104
|
-
const { getByText } = render(<RequestedCarsSection {...mockProps as any} />);
|
|
105
|
-
const requestedCars = mockProps.requestedCars;
|
|
106
|
-
requestedCars.forEach((element) => {
|
|
107
|
-
expect(getByText(`${element.request}`)).toBeInTheDocument();
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
it('calls redirectToCar with car ID on button click', () => {
|
|
111
|
-
const { getByTestId } = render(<RequestedCarsSection {...mockProps as any} />);
|
|
112
|
-
const carWrapper = getByTestId(mockProps.requestedCars[0].car._id);
|
|
113
|
-
fireEvent.click(carWrapper);
|
|
114
|
-
expect(mockProps.redirectToCar).toHaveBeenCalledTimes(1);
|
|
115
|
-
expect(mockProps.redirectToCar).toHaveBeenCalledWith(mockProps.requestedCars[0].car._id); // assert the correct car ID
|
|
116
|
-
});
|
|
117
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, cleanup, screen } from '@testing-library/react';
|
|
3
|
-
import VehicleFormattedPrice, { IVehiclePriceProps } from '../../../../source/components/Vehicle/VehicleFormattedPrice/VehicleFormattedPrice';
|
|
4
|
-
import FormattedNumber from '../../../../source/components/FormattedNumber/FormattedNumber';
|
|
5
|
-
|
|
6
|
-
const mockPropsForFormattedNumber = {
|
|
7
|
-
value: 99,
|
|
8
|
-
toRound: false,
|
|
9
|
-
disableFormatting: false,
|
|
10
|
-
numbersAfterDot: 0,
|
|
11
|
-
className: '',
|
|
12
|
-
afterCommaClassName: '',
|
|
13
|
-
beforeCommaClassName: ''
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const VehicleFormattedPriceProps: IVehiclePriceProps = {
|
|
17
|
-
price: 1234.56,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
describe('VehicleFormattedPrice', () => {
|
|
21
|
-
it('render VehicleFormattedPrice component', () => {
|
|
22
|
-
const { container } = render(<FormattedNumber {...mockPropsForFormattedNumber} />);
|
|
23
|
-
expect(container.firstChild).toBeTruthy();
|
|
24
|
-
});
|
|
25
|
-
// TODO:value incorrect
|
|
26
|
-
// it('renders the formatted number correctly', () => {
|
|
27
|
-
// render(<VehicleFormattedPrice {...VehicleFormattedPriceProps} price={1234.56} />);
|
|
28
|
-
// const formattedNumber = screen.getByText('1234.56');
|
|
29
|
-
// expect(formattedNumber).toBeInTheDocument();
|
|
30
|
-
// });
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
it('renders the unit correctly when provided', () => {
|
|
34
|
-
render(<VehicleFormattedPrice {...VehicleFormattedPriceProps} unit="USD" />);
|
|
35
|
-
const unit = screen.getByText('USD');
|
|
36
|
-
expect(unit).toBeInTheDocument();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('renders the postfix correctly when provided', () => {
|
|
40
|
-
render(<VehicleFormattedPrice {...VehicleFormattedPriceProps} postfix="1,3" />);
|
|
41
|
-
const postfix = screen.getByText('1,3');
|
|
42
|
-
expect(postfix).toBeInTheDocument();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('renders the unit monthly correctly when provided', () => {
|
|
46
|
-
render(<VehicleFormattedPrice {...VehicleFormattedPriceProps} unit="€" monthly="mtl" />);
|
|
47
|
-
const unit = screen.getByText('€');
|
|
48
|
-
const monthly = screen.getByText('/mtl');
|
|
49
|
-
expect(unit).toBeInTheDocument();
|
|
50
|
-
expect(monthly).toBeInTheDocument();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('renders the sub correctly when provided', () => {
|
|
54
|
-
render(<VehicleFormattedPrice {...VehicleFormattedPriceProps} sub="VAT included" />);
|
|
55
|
-
const sub = screen.getByText('VAT included');
|
|
56
|
-
expect(sub).toBeInTheDocument();
|
|
57
|
-
});
|
|
58
|
-
});
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { fireEvent, render } from '@testing-library/react';
|
|
3
|
-
import VehicleInfo from '../../../source/components/VehicleSmallCard/VehicleData/VehicleInfo/VehicleInfo';
|
|
4
|
-
import { IVehicleInfo } from '../../../source/framework/types/types';
|
|
5
|
-
|
|
6
|
-
const defaultProps: IVehicleInfo = {
|
|
7
|
-
t: jest.fn(), // mock translation function
|
|
8
|
-
mlCurrentSalesPricePredicted: 30000,
|
|
9
|
-
i18nPrefixForPriceRating: 'common:',
|
|
10
|
-
vehicleComponentName: 'search',
|
|
11
|
-
combineRefAlternative: false,
|
|
12
|
-
language: 'en',
|
|
13
|
-
url: '/vehicle',
|
|
14
|
-
target: '_self',
|
|
15
|
-
rel: 'noopener noreferrer',
|
|
16
|
-
regDate: 20210101,
|
|
17
|
-
linkTag: 'a',
|
|
18
|
-
routeObj: {},
|
|
19
|
-
gearbox: 'Automatic',
|
|
20
|
-
numberOfPreviousOwners: 2,
|
|
21
|
-
usageType: 'Used',
|
|
22
|
-
condition: 'Good',
|
|
23
|
-
damaged: false,
|
|
24
|
-
driveType: 'AWD',
|
|
25
|
-
environmentEmissions: { co2: 123 },
|
|
26
|
-
common: {
|
|
27
|
-
currentSalesPrice: 235,
|
|
28
|
-
},
|
|
29
|
-
mileage: '7.5',
|
|
30
|
-
consumption: {
|
|
31
|
-
fuel: 'Gasoline',
|
|
32
|
-
consumptionCombined: 7.5,
|
|
33
|
-
consumptionPowerCombined: 9.1,
|
|
34
|
-
},
|
|
35
|
-
location: {
|
|
36
|
-
city: 'Lviv',
|
|
37
|
-
street: 'street',
|
|
38
|
-
zipCode: 55555
|
|
39
|
-
},
|
|
40
|
-
offer: 'Offer',
|
|
41
|
-
engineData: {
|
|
42
|
-
power: '200hp',
|
|
43
|
-
cylinder: '8',
|
|
44
|
-
fuelType: 'Gasoline',
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
describe('VehicleInfo', () => {
|
|
49
|
-
beforeEach(() => {
|
|
50
|
-
jest.clearAllMocks();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('renders without crashing with default props', () => {
|
|
54
|
-
render(<VehicleInfo {...defaultProps} />);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('renders the link with the correct href', () => {
|
|
58
|
-
const { getByRole } = render(<VehicleInfo {...defaultProps} url="/vehicles/123" />);
|
|
59
|
-
expect(getByRole('link')).toHaveAttribute('href', '/vehicles/123');
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// it('renders the correct main properties for comparable cars', () => {
|
|
63
|
-
// const { getByText } = render(<VehicleInfo {...defaultProps} vehicleComponentName="comparable" />);
|
|
64
|
-
// expect(getByText('Fuel Type')).toBeInTheDocument();
|
|
65
|
-
// expect(getByText('Consumption Combined (l/100km)')).toBeInTheDocument();
|
|
66
|
-
// expect(getByText('Power')).toBeInTheDocument();
|
|
67
|
-
// });
|
|
68
|
-
|
|
69
|
-
// it('renders the correct main properties for landing cars', () => {
|
|
70
|
-
// const { getByText } = render(<VehicleInfo {...defaultProps} vehicleComponentName="landing" />);
|
|
71
|
-
// expect(getByText('Mileage')).toBeInTheDocument();
|
|
72
|
-
// expect(getByText('First Registration')).toBeInTheDocument();
|
|
73
|
-
// expect(getByText('Fuel Type')).toBeInTheDocument();
|
|
74
|
-
// });
|
|
75
|
-
|
|
76
|
-
// it('renders the correct main properties for SRL', () => {
|
|
77
|
-
// const { getByText } = render(<VehicleInfo {...defaultProps} vehicleComponentName="myVehicles" />);
|
|
78
|
-
// expect(getByText('Mileage')).toBeInTheDocument();
|
|
79
|
-
// expect(getByText('First Registration')).toBeInTheDocument();
|
|
80
|
-
// expect(getByText('Drive type')).toBeInTheDocument();
|
|
81
|
-
// });
|
|
82
|
-
|
|
83
|
-
// it('renders the correct PriceRating component', () => {
|
|
84
|
-
// const { getByTestId } = render(<VehicleInfo {...defaultProps} />);
|
|
85
|
-
// expect(getByTestId('price-rating')).toBeInTheDocument();
|
|
86
|
-
// });
|
|
87
|
-
|
|
88
|
-
});
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { fireEvent, render } from '@testing-library/react';
|
|
3
|
-
import VehicleTitle from '../../../source/components/VehicleSmallCard/VehicleData/VehicleTitle/VehicleTitle';
|
|
4
|
-
import { IVehicleTitleProps } from '../../../source/framework/types/types';
|
|
5
|
-
|
|
6
|
-
const props: IVehicleTitleProps = {
|
|
7
|
-
onFavoriteClick: jest.fn(),
|
|
8
|
-
isCarInFavorite: false,
|
|
9
|
-
id: '123',
|
|
10
|
-
make: 'Toyota',
|
|
11
|
-
model: 'Camry',
|
|
12
|
-
subModel: 'subModelText',
|
|
13
|
-
option: 'option',
|
|
14
|
-
isSponsored: true,
|
|
15
|
-
combineRefAlternative: true,
|
|
16
|
-
vehicleComponentName: 'search',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
describe('VehicleTitle', () => {
|
|
20
|
-
beforeEach(() => {
|
|
21
|
-
jest.clearAllMocks();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should render VehicleTitle component with correct texts and styles', () => {
|
|
25
|
-
const { container, getByText } = render(<VehicleTitle {...props} />);
|
|
26
|
-
|
|
27
|
-
const infoSectionElement = container.querySelector('.infoSection');
|
|
28
|
-
const wrapTitlesElement = container.querySelector('.wrapTitles');
|
|
29
|
-
const optionTitleElement = container.querySelector('.optionTitle');
|
|
30
|
-
|
|
31
|
-
switch (props.vehicleComponentName) {
|
|
32
|
-
case 'search':
|
|
33
|
-
expect(infoSectionElement).toHaveClass('infoSectionSearch');
|
|
34
|
-
expect(wrapTitlesElement).toHaveClass('wrapTitlesSearch');
|
|
35
|
-
expect(optionTitleElement).toHaveClass('optionTitleSearch');
|
|
36
|
-
break;
|
|
37
|
-
case 'recently':
|
|
38
|
-
expect(infoSectionElement).toHaveClass('infoSectionRecently');
|
|
39
|
-
expect(wrapTitlesElement).toHaveClass('wrapTitlesRecently');
|
|
40
|
-
expect(optionTitleElement).toHaveClass('optionTitleRecently');
|
|
41
|
-
break;
|
|
42
|
-
case 'favorite':
|
|
43
|
-
expect(infoSectionElement).toHaveClass('infoSectionRecently');
|
|
44
|
-
expect(wrapTitlesElement).toHaveClass('wrapTitlesFavorite');
|
|
45
|
-
break;
|
|
46
|
-
case 'landing':
|
|
47
|
-
expect(infoSectionElement).toHaveClass('infoSectionRecently');
|
|
48
|
-
expect(wrapTitlesElement).toHaveClass('wrapTitlesRecently');
|
|
49
|
-
expect(optionTitleElement).toHaveClass('optionTitleRecently');
|
|
50
|
-
break;
|
|
51
|
-
case 'myVehicles':
|
|
52
|
-
expect(infoSectionElement).toHaveClass('infoSectionMyVehicles');
|
|
53
|
-
expect(wrapTitlesElement).toHaveClass('wrapTitlesSearch');
|
|
54
|
-
expect(optionTitleElement).toHaveClass('optionTitleSearch');
|
|
55
|
-
break;
|
|
56
|
-
case 'main':
|
|
57
|
-
expect(infoSectionElement).toHaveClass('infoSectionRecently');
|
|
58
|
-
expect(wrapTitlesElement).toHaveClass('wrapTitlesRecently');
|
|
59
|
-
expect(optionTitleElement).toHaveClass('optionTitleRecently');
|
|
60
|
-
break;
|
|
61
|
-
default:
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (props.combineRefAlternative) {
|
|
66
|
-
expect(optionTitleElement).toHaveClass('optionTitleIsAlternative');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
expect(getByText('Toyota Camry')).toBeInTheDocument();
|
|
70
|
-
expect(getByText('subModelText')).toBeInTheDocument();
|
|
71
|
-
expect(getByText('option')).toBeInTheDocument();
|
|
72
|
-
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('render StarButton when combineRefAlternative is false', () => {
|
|
76
|
-
const { container } = render(<VehicleTitle {...props} combineRefAlternative={false} showFavoriteStar={true} />);
|
|
77
|
-
expect(container.querySelector('.starButton')).toBeInTheDocument();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('should call onFavoriteClick handler when clicking on StarButton', () => {
|
|
81
|
-
|
|
82
|
-
const { container } = render(<VehicleTitle {...props} combineRefAlternative={false} showFavoriteStar={true} />);
|
|
83
|
-
|
|
84
|
-
fireEvent.click(container.querySelector('svg'));
|
|
85
|
-
expect(props.onFavoriteClick).toHaveBeenCalledTimes(1);
|
|
86
|
-
expect(props.onFavoriteClick).toHaveBeenCalledWith(
|
|
87
|
-
expect.objectContaining({ type: 'click' }),
|
|
88
|
-
props.id
|
|
89
|
-
);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import Badge from '../../../../source/components/_common/Badge/Badge';
|
|
4
|
-
|
|
5
|
-
describe('Badge', () => {
|
|
6
|
-
const textToRender = 'Test Text';
|
|
7
|
-
|
|
8
|
-
it('renders without crashing and shows the correct text', () => {
|
|
9
|
-
const type = 'green';
|
|
10
|
-
const { getByText } = render(<Badge type={type}>{textToRender}</Badge>);
|
|
11
|
-
const renderedText = getByText(textToRender);
|
|
12
|
-
|
|
13
|
-
expect(renderedText).toBeInTheDocument();
|
|
14
|
-
});
|
|
15
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import IconSVG from '../../../../source/components/_common/IconSVG/IconSVG';
|
|
4
|
-
|
|
5
|
-
describe('IconSVG component', () => {
|
|
6
|
-
it('should render the SVG icon when a valid name prop is passed', () => {
|
|
7
|
-
const { container } = render(<IconSVG name='Search' />);
|
|
8
|
-
const svgIcon = container.querySelector('svg');
|
|
9
|
-
expect(svgIcon).toBeDefined();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('should not render anything when an invalid name prop is passed', () => {
|
|
13
|
-
const { container } = render(<IconSVG name='nonexistenticon' />);
|
|
14
|
-
const svgIcon = container.querySelector('svg');
|
|
15
|
-
expect(svgIcon).toBeNull();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should apply custom dimensions when customDimensions prop is false', () => {
|
|
19
|
-
const { container } = render(<IconSVG name="search" customDimensions={false} />);
|
|
20
|
-
const svgIcon = container.querySelector('svg');
|
|
21
|
-
expect(svgIcon).toHaveAttribute('style', 'width: 1.5rem; height: auto;');
|
|
22
|
-
});
|
|
23
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, fireEvent, waitFor } from '@testing-library/react';
|
|
3
|
-
import ImageComponent from '../../../../source/components/_common/Image/Image';
|
|
4
|
-
import styles from '../../../../source/components/_common/Image/Image.styl';
|
|
5
|
-
|
|
6
|
-
const mockProps = {
|
|
7
|
-
src: 'https://via.placeholder.com/300',
|
|
8
|
-
srcSmall: 'https://via.placeholder.com/15',
|
|
9
|
-
srcLarge: 'https://via.placeholder.com/1500',
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
describe('ImageComponent', () => {
|
|
14
|
-
|
|
15
|
-
it('loads the image correctly', async () => {
|
|
16
|
-
const { container } = render(
|
|
17
|
-
<ImageComponent src={mockProps.src} />,
|
|
18
|
-
);
|
|
19
|
-
const imgElement = container.querySelector('img') as HTMLImageElement;
|
|
20
|
-
expect(imgElement).toBeInTheDocument();
|
|
21
|
-
await expect(imgElement).toHaveProperty('src', mockProps.src);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('ImageComponent renders correctly', () => {
|
|
25
|
-
const { getByRole, container } = render(<ImageComponent src={mockProps.src} />);
|
|
26
|
-
|
|
27
|
-
const imgElem = getByRole('img');
|
|
28
|
-
const divContainer = container.firstChild;
|
|
29
|
-
|
|
30
|
-
expect(imgElem).toBeInTheDocument();
|
|
31
|
-
expect(divContainer).toHaveClass('container')
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('renders without errors', async () => {
|
|
35
|
-
const { container } = render(<ImageComponent {...mockProps} />);
|
|
36
|
-
|
|
37
|
-
expect(container).toBeInTheDocument();
|
|
38
|
-
|
|
39
|
-
// Wait for the image to load
|
|
40
|
-
const imgEl = await waitFor(() => container.querySelector('img'));
|
|
41
|
-
expect(imgEl).toBeInTheDocument();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('shows the loader before image is loaded', () => {
|
|
45
|
-
const { getByText } = render(
|
|
46
|
-
<ImageComponent src={mockProps.src} withLoader />,
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
getByText(/loading/i);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('calls onClick handler when image is clicked', async () => {
|
|
53
|
-
const handleClick = jest.fn();
|
|
54
|
-
const { container } = render(<ImageComponent {...mockProps} onClick={handleClick} />);
|
|
55
|
-
|
|
56
|
-
// Wait for the image to load
|
|
57
|
-
const imgEl = await waitFor(() => container.querySelector('img'));
|
|
58
|
-
fireEvent.click(imgEl);
|
|
59
|
-
|
|
60
|
-
expect(handleClick).toHaveBeenCalledTimes(1);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('sets height and width correctly', () => {
|
|
64
|
-
const { container } = render(<ImageComponent src={mockProps.src} width={100} height={100} />);
|
|
65
|
-
|
|
66
|
-
expect(container.firstChild).toHaveStyle('width: 100px;');
|
|
67
|
-
expect(container.firstChild).toHaveStyle('height: 100px;');
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('ImageComponent state works correctly', () => {
|
|
71
|
-
const { getByRole } = render(
|
|
72
|
-
<ImageComponent src={mockProps.src} />
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
const imgElem = getByRole('img');
|
|
76
|
-
|
|
77
|
-
expect(imgElem).not.toHaveClass(styles.loaded);
|
|
78
|
-
fireEvent.load(imgElem);
|
|
79
|
-
expect(imgElem).toHaveClass(styles.loaded);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render, fireEvent } from "@testing-library/react";
|
|
3
|
-
import MaterialAutocomplete from "../../../../source/components/_common/MaterialAutocomplete/MaterialAutocomplete";
|
|
4
|
-
let value: any = null;
|
|
5
|
-
const setValue = jest.fn();
|
|
6
|
-
const materialAutocompleteProps = {
|
|
7
|
-
onChange: setValue,
|
|
8
|
-
label: 'test label',
|
|
9
|
-
value: value,
|
|
10
|
-
error: false,
|
|
11
|
-
required: true,
|
|
12
|
-
items: [
|
|
13
|
-
{ value: '+49', label: '+49', icon: 'de' },
|
|
14
|
-
{ value: '+43', label: '+43', icon: 'at' }
|
|
15
|
-
],
|
|
16
|
-
listWithImage: 'true'
|
|
17
|
-
}
|
|
18
|
-
describe('MaterialAutocomplete', () => {
|
|
19
|
-
it('renders component without errors', () => {
|
|
20
|
-
const { container, getByRole, getByText } = render(<MaterialAutocomplete {...materialAutocompleteProps} />)
|
|
21
|
-
expect(container).toBeInTheDocument();
|
|
22
|
-
const input = getByRole('combobox');
|
|
23
|
-
const button = getByRole('button');
|
|
24
|
-
fireEvent.click(button);
|
|
25
|
-
const listItem = getByText('+43');
|
|
26
|
-
fireEvent.click(listItem);
|
|
27
|
-
expect(input).toHaveAttribute('value', '+43');
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('renders component, open list and choose any option from list', () => {
|
|
31
|
-
const { getByRole, getByText } = render(<MaterialAutocomplete {...materialAutocompleteProps} />)
|
|
32
|
-
const input = getByRole('combobox');
|
|
33
|
-
const button = getByRole('button');
|
|
34
|
-
fireEvent.click(button);
|
|
35
|
-
const listItem = getByText('+43');
|
|
36
|
-
fireEvent.click(listItem);
|
|
37
|
-
expect(input).toHaveAttribute('value', '+43');
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
it('renders component, open list and check if we have icons in list, when "listWithImage: true"', () => {
|
|
41
|
-
const { getByRole, container } = render(<MaterialAutocomplete {...materialAutocompleteProps} />)
|
|
42
|
-
const button = getByRole('button');
|
|
43
|
-
fireEvent.click(button);
|
|
44
|
-
const iconDe = container.querySelector('[id="flag-icons-de"]');
|
|
45
|
-
const iconAt = container.querySelector('[id="flag-icons-at"]');
|
|
46
|
-
expect(iconDe).toBeInTheDocument();
|
|
47
|
-
expect(iconAt).toBeInTheDocument();
|
|
48
|
-
})
|
|
49
|
-
})
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { fireEvent } from '@testing-library/dom';
|
|
4
|
-
import MaterialDatePicker from '../../../../source/components/_common/MaterialDatePicker/MaterialDatePicker';
|
|
5
|
-
|
|
6
|
-
describe('MaterialDatePicker', () => {
|
|
7
|
-
it('renders without crashing', () => {
|
|
8
|
-
render(<MaterialDatePicker onChange={() => {}} t={(key) => key} />);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('displays the label when provided', () => {
|
|
12
|
-
const label = 'Select Date';
|
|
13
|
-
render(<MaterialDatePicker label={label} onChange={() => {}} t={(key) => key} />);
|
|
14
|
-
expect(screen.getByLabelText(label)).toBeInTheDocument();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('calls the onChange function when a date is selected', async () => {
|
|
18
|
-
const handleChange = jest.fn();
|
|
19
|
-
const handleOpen = jest.fn();
|
|
20
|
-
const handleAccept = jest.fn();
|
|
21
|
-
const handleBlur = jest.fn();
|
|
22
|
-
const { getByText, container } = render(
|
|
23
|
-
<MaterialDatePicker
|
|
24
|
-
onChange={handleChange}
|
|
25
|
-
onOpen={handleOpen}
|
|
26
|
-
onAccept={handleAccept}
|
|
27
|
-
onBlur={handleBlur}
|
|
28
|
-
t={(key) => key}
|
|
29
|
-
format={'dd.MM.yyyy'}
|
|
30
|
-
value={'2023-01-01'}
|
|
31
|
-
language='en'
|
|
32
|
-
label='test label'
|
|
33
|
-
placeholder='placeholder'
|
|
34
|
-
className='className'
|
|
35
|
-
minDate={new Date('01/01/1900')}
|
|
36
|
-
maxDate={new Date()}
|
|
37
|
-
size='medium'
|
|
38
|
-
error={false}
|
|
39
|
-
/>);
|
|
40
|
-
const input = screen.getByRole('textbox');
|
|
41
|
-
|
|
42
|
-
fireEvent.click(input);
|
|
43
|
-
fireEvent.click(getByText('2022'));
|
|
44
|
-
fireEvent.click(getByText('Apr'));
|
|
45
|
-
fireEvent.click(getByText('22'));
|
|
46
|
-
const okButton = screen.getByText('OK');
|
|
47
|
-
fireEvent.click(okButton);
|
|
48
|
-
fireEvent.focusOut(input);
|
|
49
|
-
|
|
50
|
-
expect(handleChange).toHaveBeenCalledTimes(3);
|
|
51
|
-
expect(handleOpen).toHaveBeenCalledTimes(1);
|
|
52
|
-
expect(handleBlur).toHaveBeenCalledTimes(1);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
-
import MaterialField from '../../../../source/components/_common/MaterialField/MaterialField';
|
|
4
|
-
|
|
5
|
-
describe('MaterialField', () => {
|
|
6
|
-
const props = {
|
|
7
|
-
label: 'Test Label',
|
|
8
|
-
value: 'Test Value',
|
|
9
|
-
onChange: jest.fn(),
|
|
10
|
-
disabled: false,
|
|
11
|
-
type: 'text',
|
|
12
|
-
autoComplete: 'off',
|
|
13
|
-
name: 'testName',
|
|
14
|
-
required: true,
|
|
15
|
-
multiline: false,
|
|
16
|
-
rows: 1,
|
|
17
|
-
placeholder: 'Test Placeholder'
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
it('renders the input element with the correct props', () => {
|
|
21
|
-
const { getByRole } = render(<MaterialField size='medium' {...props} />);
|
|
22
|
-
const inputElement = getByRole('textbox');
|
|
23
|
-
expect(inputElement).toBeInTheDocument();
|
|
24
|
-
expect(inputElement).toHaveAttribute('type', 'text');
|
|
25
|
-
expect(inputElement).toHaveAttribute('value', 'Test Value');
|
|
26
|
-
expect(inputElement).toHaveAttribute('name', 'testName');
|
|
27
|
-
expect(inputElement).toHaveAttribute('required');
|
|
28
|
-
expect(inputElement).toHaveAttribute('placeholder', 'Test Placeholder');
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('calls the onChange prop when the input value changes', () => {
|
|
32
|
-
const { getByRole } = render(<MaterialField size='medium' {...props} />);
|
|
33
|
-
const inputElement = getByRole('textbox');
|
|
34
|
-
fireEvent.change(inputElement, { target: { value: 'New Value' } });
|
|
35
|
-
expect(props.onChange).toHaveBeenCalledTimes(1);
|
|
36
|
-
expect(props.onChange).toHaveBeenCalledWith('New Value', 'testName', expect.anything());
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('toggles password visibility when the icon button is clicked', () => {
|
|
40
|
-
const passwordProps = {
|
|
41
|
-
...props,
|
|
42
|
-
type: 'password'
|
|
43
|
-
}
|
|
44
|
-
const { getByRole, getByPlaceholderText } = render(<MaterialField size='medium' {...passwordProps} />);
|
|
45
|
-
const iconButton = getByRole('button');
|
|
46
|
-
const inputElement = getByPlaceholderText('Test Placeholder');
|
|
47
|
-
fireEvent.click(iconButton);
|
|
48
|
-
expect(inputElement).toHaveAttribute('type', 'text');
|
|
49
|
-
|
|
50
|
-
fireEvent.click(iconButton);
|
|
51
|
-
|
|
52
|
-
expect(inputElement).toHaveAttribute('type', 'password');
|
|
53
|
-
|
|
54
|
-
fireEvent.click(iconButton);
|
|
55
|
-
|
|
56
|
-
expect(inputElement).toHaveAttribute('type', 'text');
|
|
57
|
-
});
|
|
58
|
-
});
|