@jetshop/ui 6.3.8-alpha.32 → 6.3.8
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/Accordion/Accordion.d.ts +33 -0
- package/Accordion/Accordion.js +59 -0
- package/Accordion/Accordion.js.map +1 -0
- package/Auth/FormFields/CountriesInput.d.ts +16 -0
- package/Auth/FormFields/CountriesInput.js +28 -0
- package/Auth/FormFields/CountriesInput.js.map +1 -0
- package/Auth/LogInBehavior.d.ts +22 -0
- package/Auth/LogInBehavior.js +24 -0
- package/Auth/LogInBehavior.js.map +1 -0
- package/Auth/LogInFormProvider.d.ts +7 -0
- package/Auth/LogInFormProvider.js +70 -0
- package/Auth/LogInFormProvider.js.map +1 -0
- package/Auth/LogOut.d.ts +10 -0
- package/Auth/LogOut.js +24 -0
- package/Auth/LogOut.js.map +1 -0
- package/Auth/logInValidator.d.ts +10 -0
- package/Auth/logInValidator.js +16 -0
- package/Auth/logInValidator.js.map +1 -0
- package/Breadcrumbs/Breadcrumbs.d.ts +14 -0
- package/Breadcrumbs/Breadcrumbs.js +84 -0
- package/Breadcrumbs/Breadcrumbs.js.map +1 -0
- package/Breadcrumbs/getParentsOrCanonicalRoute.d.ts +3 -0
- package/Breadcrumbs/getParentsOrCanonicalRoute.js +14 -0
- package/Breadcrumbs/getParentsOrCanonicalRoute.js.map +1 -0
- package/Breadcrumbs/index.d.ts +1 -0
- package/Breadcrumbs/index.js +2 -0
- package/Breadcrumbs/index.js.map +1 -0
- package/Breakpoints.d.ts +12 -0
- package/Breakpoints.js +36 -0
- package/Breakpoints.js.map +1 -0
- package/Button/Button.d.ts +14 -0
- package/Button/Button.js +60 -0
- package/Button/Button.js.map +1 -0
- package/Button/SecondaryButton.d.ts +2 -0
- package/Button/SecondaryButton.js +9 -0
- package/Button/SecondaryButton.js.map +1 -0
- package/Button/TrendButton.d.ts +2 -0
- package/Button/TrendButton.js +8 -0
- package/Button/TrendButton.js.map +1 -0
- package/Button/index.d.ts +4 -0
- package/Button/index.js +5 -0
- package/Button/index.js.map +1 -0
- package/CategoryLink.d.ts +11 -0
- package/CategoryLink.js +49 -0
- package/CategoryLink.js.map +1 -0
- package/ChannelSelector/ChannelListItem.d.ts +10 -0
- package/ChannelSelector/ChannelListItem.js +51 -0
- package/ChannelSelector/ChannelListItem.js.map +1 -0
- package/ChannelSelector/ChannelSelector.d.ts +63 -0
- package/ChannelSelector/ChannelSelector.js +80 -0
- package/ChannelSelector/ChannelSelector.js.map +1 -0
- package/ChannelSelector/ChannelSelectorButtons.d.ts +2 -0
- package/ChannelSelector/ChannelSelectorButtons.js +20 -0
- package/ChannelSelector/ChannelSelectorButtons.js.map +1 -0
- package/ChannelSelector/Channels.d.ts +17 -0
- package/ChannelSelector/Channels.js +12 -0
- package/ChannelSelector/Channels.js.map +1 -0
- package/ChannelSelector/LargeSelector.d.ts +3 -0
- package/ChannelSelector/LargeSelector.js +67 -0
- package/ChannelSelector/LargeSelector.js.map +1 -0
- package/ChannelSelector/MiniSelector.d.ts +4 -0
- package/ChannelSelector/MiniSelector.js +58 -0
- package/ChannelSelector/MiniSelector.js.map +1 -0
- package/ChannelSelector/Region.d.ts +28 -0
- package/ChannelSelector/Region.js +21 -0
- package/ChannelSelector/Region.js.map +1 -0
- package/ChannelSelector/groupBy.d.ts +7 -0
- package/ChannelSelector/groupBy.js +16 -0
- package/ChannelSelector/groupBy.js.map +1 -0
- package/Checkbox/Checkbox.d.ts +14 -0
- package/Checkbox/Checkbox.js +70 -0
- package/Checkbox/Checkbox.js.map +1 -0
- package/Checkbox/CheckboxGroup.d.ts +27 -0
- package/Checkbox/CheckboxGroup.js +22 -0
- package/Checkbox/CheckboxGroup.js.map +1 -0
- package/Checkbox/index.d.ts +2 -0
- package/Checkbox/index.js +3 -0
- package/Checkbox/index.js.map +1 -0
- package/ContentPageLink.d.ts +11 -0
- package/ContentPageLink.js +46 -0
- package/ContentPageLink.js.map +1 -0
- package/ContentRenderer.d.ts +9 -0
- package/ContentRenderer.js +36 -0
- package/ContentRenderer.js.map +1 -0
- package/DropdownMenu/Button.d.ts +7 -0
- package/DropdownMenu/Button.js +33 -0
- package/DropdownMenu/Button.js.map +1 -0
- package/DropdownMenu/DropdownMenu.d.ts +21 -0
- package/DropdownMenu/DropdownMenu.js +72 -0
- package/DropdownMenu/DropdownMenu.js.map +1 -0
- package/DropdownMenu/Item.d.ts +13 -0
- package/DropdownMenu/Item.js +48 -0
- package/DropdownMenu/Item.js.map +1 -0
- package/DropdownMenu/Items.d.ts +16 -0
- package/DropdownMenu/Items.js +53 -0
- package/DropdownMenu/Items.js.map +1 -0
- package/DropdownMenu/index.d.ts +4 -0
- package/DropdownMenu/index.js +5 -0
- package/DropdownMenu/index.js.map +1 -0
- package/ErrorBoundary/Generic.d.ts +18 -0
- package/ErrorBoundary/Generic.js +69 -0
- package/ErrorBoundary/Generic.js.map +1 -0
- package/ErrorBoundary/PassThrough.d.ts +3 -0
- package/ErrorBoundary/PassThrough.js +7 -0
- package/ErrorBoundary/PassThrough.js.map +1 -0
- package/Gallery/Gallery.d.ts +39 -0
- package/Gallery/Gallery.js +121 -0
- package/Gallery/Gallery.js.map +1 -0
- package/Gallery/constructGallery.d.ts +15 -0
- package/Gallery/constructGallery.js +40 -0
- package/Gallery/constructGallery.js.map +1 -0
- package/Image/BaseImage.d.ts +39 -0
- package/Image/BaseImage.js +192 -0
- package/Image/BaseImage.js.map +1 -0
- package/Image/Fallback.d.ts +5 -0
- package/Image/Fallback.js +4 -0
- package/Image/Fallback.js.map +1 -0
- package/Image/FlightImage.d.ts +51 -0
- package/Image/FlightImage.js +59 -0
- package/Image/FlightImage.js.map +1 -0
- package/Image/Image.d.ts +2 -0
- package/Image/Image.js +3 -0
- package/Image/Image.js.map +1 -0
- package/Image/index.d.ts +1 -0
- package/Image/index.js +2 -0
- package/Image/index.js.map +1 -0
- package/Image/useConstructImage.d.ts +49 -0
- package/Image/useConstructImage.js +122 -0
- package/Image/useConstructImage.js.map +1 -0
- package/Image/utils/aspectRatioToFraction.d.ts +2 -0
- package/Image/utils/aspectRatioToFraction.js +11 -0
- package/Image/utils/aspectRatioToFraction.js.map +1 -0
- package/Image/utils/getFullUrl.d.ts +6 -0
- package/Image/utils/getFullUrl.js +18 -0
- package/Image/utils/getFullUrl.js.map +1 -0
- package/Image/utils/getImageWidth.d.ts +1 -0
- package/Image/utils/getImageWidth.js +12 -0
- package/Image/utils/getImageWidth.js.map +1 -0
- package/Image/utils/getImageWidths.d.ts +2 -0
- package/Image/utils/getImageWidths.js +21 -0
- package/Image/utils/getImageWidths.js.map +1 -0
- package/Image/utils/getLQIP.d.ts +8 -0
- package/Image/utils/getLQIP.js +20 -0
- package/Image/utils/getLQIP.js.map +1 -0
- package/Image/utils/getLargestSize.d.ts +7 -0
- package/Image/utils/getLargestSize.js +17 -0
- package/Image/utils/getLargestSize.js.map +1 -0
- package/Image/utils/getSizeForBreakpoint.d.ts +2 -0
- package/Image/utils/getSizeForBreakpoint.js +16 -0
- package/Image/utils/getSizeForBreakpoint.js.map +1 -0
- package/Image/utils/getSizesMap.d.ts +2 -0
- package/Image/utils/getSizesMap.js +35 -0
- package/Image/utils/getSizesMap.js.map +1 -0
- package/Image/utils/getSmallestSize.d.ts +2 -0
- package/Image/utils/getSmallestSize.js +12 -0
- package/Image/utils/getSmallestSize.js.map +1 -0
- package/Image/utils/getSrcSetFromWidths.d.ts +10 -0
- package/Image/utils/getSrcSetFromWidths.js +9 -0
- package/Image/utils/getSrcSetFromWidths.js.map +1 -0
- package/Image/utils/getSrcWithParams.d.ts +3 -0
- package/Image/utils/getSrcWithParams.js +29 -0
- package/Image/utils/getSrcWithParams.js.map +1 -0
- package/Image/utils/paddingForAspectRatio.d.ts +1 -0
- package/Image/utils/paddingForAspectRatio.js +6 -0
- package/Image/utils/paddingForAspectRatio.js.map +1 -0
- package/Image/utils/remToPx.d.ts +1 -0
- package/Image/utils/remToPx.js +2 -0
- package/Image/utils/remToPx.js.map +1 -0
- package/Image/utils/sizeToNumber.d.ts +2 -0
- package/Image/utils/sizeToNumber.js +27 -0
- package/Image/utils/sizeToNumber.js.map +1 -0
- package/Input/Input.d.ts +6 -0
- package/Input/Input.js +45 -0
- package/Input/Input.js.map +1 -0
- package/Input/index.d.ts +3 -0
- package/Input/index.js +4 -0
- package/Input/index.js.map +1 -0
- package/JetshopText.d.ts +3 -0
- package/JetshopText.js +13 -0
- package/JetshopText.js.map +1 -0
- package/Loading/LoadingBar.d.ts +8 -0
- package/Loading/LoadingBar.js +58 -0
- package/Loading/LoadingBar.js.map +1 -0
- package/Loading/LoadingLine.d.ts +31 -0
- package/Loading/LoadingLine.js +26 -0
- package/Loading/LoadingLine.js.map +1 -0
- package/Loading/NetworkStatusNotifier.d.ts +6 -0
- package/Loading/NetworkStatusNotifier.js +8 -0
- package/Loading/NetworkStatusNotifier.js.map +1 -0
- package/Menu/MenuContainer.d.ts +28 -0
- package/Menu/MenuContainer.js +46 -0
- package/Menu/MenuContainer.js.map +1 -0
- package/Menu/RecursiveTree.d.ts +28 -0
- package/Menu/RecursiveTree.js +91 -0
- package/Menu/RecursiveTree.js.map +1 -0
- package/Modal/Drawer/Drawer.d.ts +12 -0
- package/Modal/Drawer/Drawer.js +31 -0
- package/Modal/Drawer/Drawer.js.map +1 -0
- package/Modal/Drawer/DrawerTarget.d.ts +6 -0
- package/Modal/Drawer/DrawerTarget.js +12 -0
- package/Modal/Drawer/DrawerTarget.js.map +1 -0
- package/Modal/Drawer/DrawerTrigger.d.ts +11 -0
- package/Modal/Drawer/DrawerTrigger.js +16 -0
- package/Modal/Drawer/DrawerTrigger.js.map +1 -0
- package/Modal/Drawer/index.d.ts +3 -0
- package/Modal/Drawer/index.js +4 -0
- package/Modal/Drawer/index.js.map +1 -0
- package/Modal/Flyout/FlyoutTarget.d.ts +10 -0
- package/Modal/Flyout/FlyoutTarget.js +15 -0
- package/Modal/Flyout/FlyoutTarget.js.map +1 -0
- package/Modal/Flyout/FlyoutTrigger.d.ts +15 -0
- package/Modal/Flyout/FlyoutTrigger.js +18 -0
- package/Modal/Flyout/FlyoutTrigger.js.map +1 -0
- package/Modal/Flyout/index.d.ts +2 -0
- package/Modal/Flyout/index.js +3 -0
- package/Modal/Flyout/index.js.map +1 -0
- package/Modal/ModalContext.d.ts +26 -0
- package/Modal/ModalContext.js +9 -0
- package/Modal/ModalContext.js.map +1 -0
- package/Modal/ModalProvider.d.ts +5 -0
- package/Modal/ModalProvider.js +83 -0
- package/Modal/ModalProvider.js.map +1 -0
- package/Modal/ModalRoot.d.ts +3 -0
- package/Modal/ModalRoot.js +44 -0
- package/Modal/ModalRoot.js.map +1 -0
- package/Modal/ModalTrigger.d.ts +9 -0
- package/Modal/ModalTrigger.js +9 -0
- package/Modal/ModalTrigger.js.map +1 -0
- package/Pagination/Pagination.d.ts +7 -0
- package/Pagination/Pagination.js +23 -0
- package/Pagination/Pagination.js.map +1 -0
- package/Pagination/PaginationBehaviour.d.ts +52 -0
- package/Pagination/PaginationBehaviour.js +68 -0
- package/Pagination/PaginationBehaviour.js.map +1 -0
- package/Pagination/index.d.ts +2 -0
- package/Pagination/index.js +3 -0
- package/Pagination/index.js.map +1 -0
- package/Pagination/usePagination.d.ts +15 -0
- package/Pagination/usePagination.js +46 -0
- package/Pagination/usePagination.js.map +1 -0
- package/PreOrderDateSelector/PreOrderDateSelector.d.ts +23 -0
- package/PreOrderDateSelector/PreOrderDateSelector.js +74 -0
- package/PreOrderDateSelector/PreOrderDateSelector.js.map +1 -0
- package/PreOrderDateSelector/index.d.ts +2 -0
- package/PreOrderDateSelector/index.js +3 -0
- package/PreOrderDateSelector/index.js.map +1 -0
- package/Price/Currency.d.ts +9 -0
- package/Price/Currency.js +11 -0
- package/Price/Currency.js.map +1 -0
- package/Price/Price.d.ts +44 -0
- package/Price/Price.js +74 -0
- package/Price/Price.js.map +1 -0
- package/Price/index.d.ts +1 -0
- package/Price/index.js +2 -0
- package/Price/index.js.map +1 -0
- package/ProductLink.d.ts +23 -0
- package/ProductLink.js +88 -0
- package/ProductLink.js.map +1 -0
- package/ProductList/Badges.d.ts +6 -0
- package/ProductList/Badges.js +56 -0
- package/ProductList/Badges.js.map +1 -0
- package/ProductList/GridProduct.d.ts +24 -0
- package/ProductList/GridProduct.js +58 -0
- package/ProductList/GridProduct.js.map +1 -0
- package/ProductList/ProductGrid.d.ts +16 -0
- package/ProductList/ProductGrid.js +30 -0
- package/ProductList/ProductGrid.js.map +1 -0
- package/ProductList/ProductImage.d.ts +12 -0
- package/ProductList/ProductImage.js +21 -0
- package/ProductList/ProductImage.js.map +1 -0
- package/ProductSpecifications/ProductSpecifications.d.ts +8 -0
- package/ProductSpecifications/ProductSpecifications.js +78 -0
- package/ProductSpecifications/ProductSpecifications.js.map +1 -0
- package/ScrollRestorationHandler/ScrollRestorationHandler.d.ts +8 -0
- package/ScrollRestorationHandler/ScrollRestorationHandler.js +17 -0
- package/ScrollRestorationHandler/ScrollRestorationHandler.js.map +1 -0
- package/ScrollRestorationHandler/index.d.ts +1 -0
- package/ScrollRestorationHandler/index.js +2 -0
- package/ScrollRestorationHandler/index.js.map +1 -0
- package/ScrollRestorationHandler/isInIgnoredRouteTypes.d.ts +8 -0
- package/ScrollRestorationHandler/isInIgnoredRouteTypes.js +8 -0
- package/ScrollRestorationHandler/isInIgnoredRouteTypes.js.map +1 -0
- package/ScrollRestorationHandler/useScrollRestore.d.ts +9 -0
- package/ScrollRestorationHandler/useScrollRestore.js +20 -0
- package/ScrollRestorationHandler/useScrollRestore.js.map +1 -0
- package/Search/SearchAutoCompleteContainer.d.ts +45 -0
- package/Search/SearchAutoCompleteContainer.js +172 -0
- package/Search/SearchAutoCompleteContainer.js.map +1 -0
- package/Search/SearchField.d.ts +26 -0
- package/Search/SearchField.js +98 -0
- package/Search/SearchField.js.map +1 -0
- package/Search/SearchPage/PageOf.d.ts +5 -0
- package/Search/SearchPage/PageOf.js +7 -0
- package/Search/SearchPage/PageOf.js.map +1 -0
- package/Search/SearchPage/SearchMeta.d.ts +16 -0
- package/Search/SearchPage/SearchMeta.js +20 -0
- package/Search/SearchPage/SearchMeta.js.map +1 -0
- package/Search/SearchPage/SearchPageBehaviour.d.ts +19 -0
- package/Search/SearchPage/SearchPageBehaviour.js +75 -0
- package/Search/SearchPage/SearchPageBehaviour.js.map +1 -0
- package/Search/SuggestedTerm.d.ts +16 -0
- package/Search/SuggestedTerm.js +35 -0
- package/Search/SuggestedTerm.js.map +1 -0
- package/Search/index.d.ts +1 -0
- package/Search/index.js +2 -0
- package/Search/index.js.map +1 -0
- package/Select/Components.d.ts +28 -0
- package/Select/Components.js +91 -0
- package/Select/Components.js.map +1 -0
- package/Select/SelectComponents/Quantity.d.ts +5 -0
- package/Select/SelectComponents/Quantity.js +8 -0
- package/Select/SelectComponents/Quantity.js.map +1 -0
- package/Select/index.d.ts +5 -0
- package/Select/index.js +2 -0
- package/Select/index.js.map +1 -0
- package/SortOrder/SortOrder.d.ts +16 -0
- package/SortOrder/SortOrder.js +33 -0
- package/SortOrder/SortOrder.js.map +1 -0
- package/SortOrder/SortOrderDropdown.d.ts +9 -0
- package/SortOrder/SortOrderDropdown.js +25 -0
- package/SortOrder/SortOrderDropdown.js.map +1 -0
- package/SortOrder/SortOrderList.d.ts +7 -0
- package/SortOrder/SortOrderList.js +17 -0
- package/SortOrder/SortOrderList.js.map +1 -0
- package/StartPageRenderer/StartPageRenderer.d.ts +17 -0
- package/StartPageRenderer/StartPageRenderer.js +52 -0
- package/StartPageRenderer/StartPageRenderer.js.map +1 -0
- package/StartPageRenderer/index.d.ts +1 -0
- package/StartPageRenderer/index.js +2 -0
- package/StartPageRenderer/index.js.map +1 -0
- package/Stock/StockStatusContainer.d.ts +21 -0
- package/Stock/StockStatusContainer.js +45 -0
- package/Stock/StockStatusContainer.js.map +1 -0
- package/Text/Text.d.ts +11 -0
- package/Text/Text.js +22 -0
- package/Text/Text.js.map +1 -0
- package/Text/index.d.ts +3 -0
- package/Text/index.js +4 -0
- package/Text/index.js.map +1 -0
- package/Theme/createTheme.d.ts +16 -0
- package/Theme/createTheme.js +5 -0
- package/Theme/createTheme.js.map +1 -0
- package/Theme/cssReset.d.ts +1 -0
- package/Theme/cssReset.js +160 -0
- package/Theme/cssReset.js.map +1 -0
- package/Theme/normalizeCss.d.ts +1 -0
- package/Theme/normalizeCss.js +357 -0
- package/Theme/normalizeCss.js.map +1 -0
- package/Theme/sanitizeCss.d.ts +1 -0
- package/Theme/sanitizeCss.js +572 -0
- package/Theme/sanitizeCss.js.map +1 -0
- package/WindowGrid/WindowGrid.d.ts +11 -0
- package/WindowGrid/WindowGrid.js +58 -0
- package/WindowGrid/WindowGrid.js.map +1 -0
- package/WindowGrid/index.d.ts +1 -0
- package/WindowGrid/index.js +2 -0
- package/WindowGrid/index.js.map +1 -0
- package/WindowGrid/useResizeObserver.d.ts +3 -0
- package/WindowGrid/useResizeObserver.js +14 -0
- package/WindowGrid/useResizeObserver.js.map +1 -0
- package/WindowGrid/useScrollWithWindow.d.ts +12 -0
- package/WindowGrid/useScrollWithWindow.js +39 -0
- package/WindowGrid/useScrollWithWindow.js.map +1 -0
- package/fuzzySearch/fuzzySearch.d.ts +8 -0
- package/fuzzySearch/fuzzySearch.js +43 -0
- package/fuzzySearch/fuzzySearch.js.map +1 -0
- package/fuzzySearch/index.d.ts +1 -0
- package/fuzzySearch/index.js +2 -0
- package/fuzzySearch/index.js.map +1 -0
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +3 -0
- package/hooks/index.js.map +1 -0
- package/hooks/useOnClickOutside.d.ts +6 -0
- package/hooks/useOnClickOutside.js +17 -0
- package/hooks/useOnClickOutside.js.map +1 -0
- package/hooks/useOnEsc.d.ts +4 -0
- package/hooks/useOnEsc.js +17 -0
- package/hooks/useOnEsc.js.map +1 -0
- package/package.json +2 -2
- package/utils/breakpoints.d.ts +23 -0
- package/utils/breakpoints.js +94 -0
- package/utils/breakpoints.js.map +1 -0
- package/utils/callAllEventHandlers.d.ts +5 -0
- package/utils/callAllEventHandlers.js +9 -0
- package/utils/callAllEventHandlers.js.map +1 -0
- package/utils/text.d.ts +1 -0
- package/utils/text.js +23 -0
- package/utils/text.js.map +1 -0
- package/utils/theme.d.ts +3 -0
- package/utils/theme.js +5 -0
- package/utils/theme.js.map +1 -0
- package/utils/useHoverIntent.d.ts +10 -0
- package/utils/useHoverIntent.js +78 -0
- package/utils/useHoverIntent.js.map +1 -0
- package/utils/usePropsOfType.d.ts +11 -0
- package/utils/usePropsOfType.js +18 -0
- package/utils/usePropsOfType.js.map +1 -0
- package/withFlightUI.d.ts +17 -0
- package/withFlightUI.js +20 -0
- package/withFlightUI.js.map +1 -0
- package/CloudflareImage/FlightImage.test.js +0 -277
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
import { ChannelProvider } from '@jetshop/core/components/ChannelContext';
|
|
2
|
-
import t from '@jetshop/intl';
|
|
3
|
-
import testImage from '@jetshop/ui/test-utils/fixtures/test-image.png';
|
|
4
|
-
import { fireEvent, queryByText, render } from '@testing-library/react';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { useInView } from 'react-intersection-observer';
|
|
7
|
-
import Image from './FlightImage';
|
|
8
|
-
import { ChannelHandler } from '@jetshop/core/ChannelHandler/ChannelHandler';
|
|
9
|
-
import { selectedChannel, channels } from '@jetshop/core/test-utils/variables';
|
|
10
|
-
import { ConfigProvider } from '@jetshop/core/components/ConfigProvider';
|
|
11
|
-
import mockShopConfig from '@jetshop/core/test-utils/mockShopConfig';
|
|
12
|
-
|
|
13
|
-
// Mock intersection observer so we can always return true/false
|
|
14
|
-
jest.mock('react-intersection-observer');
|
|
15
|
-
// Suppress warnings from translations
|
|
16
|
-
jest.mock('@jetshop/intl');
|
|
17
|
-
t.mockImplementation((t) => t);
|
|
18
|
-
|
|
19
|
-
// browser mocks
|
|
20
|
-
global.IntersectionObserver = jest.fn(function () {
|
|
21
|
-
this.observe = jest.fn();
|
|
22
|
-
this.unobserve = jest.fn();
|
|
23
|
-
this.disconnect = jest.fn();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const transparent =
|
|
27
|
-
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';
|
|
28
|
-
|
|
29
|
-
global.__IN_SERVER__ = false;
|
|
30
|
-
|
|
31
|
-
describe('Hooks image component', () => {
|
|
32
|
-
describe('on initial load', () => {
|
|
33
|
-
beforeAll(() => {
|
|
34
|
-
useInView.mockImplementation(() => [null, false]);
|
|
35
|
-
});
|
|
36
|
-
it('renders a lqip version of the image by default', () => {
|
|
37
|
-
const { placeholderImage } = setup();
|
|
38
|
-
|
|
39
|
-
const src = placeholderImage.getAttribute('src');
|
|
40
|
-
|
|
41
|
-
expect(src).toEqual(expect.stringContaining('sigma=2.5'));
|
|
42
|
-
expect(src).toEqual(expect.stringContaining('minampl=0.5'));
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('sets the lqip to the smallest of the calculated sizes', () => {
|
|
46
|
-
const { placeholderImage } = setup({ sizes: [0.5, 0.85, 1] });
|
|
47
|
-
// Should be 160
|
|
48
|
-
// The smallest breakpoint is 20rem, which is 360px.
|
|
49
|
-
// 0.5 x 360 = 160
|
|
50
|
-
|
|
51
|
-
const src = placeholderImage.getAttribute('src');
|
|
52
|
-
|
|
53
|
-
expect(src).toEqual(expect.stringContaining('width=160'));
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('does not render an lqip if critical is true', () => {
|
|
57
|
-
const { placeholderImage } = setup({ critical: true });
|
|
58
|
-
|
|
59
|
-
const src = placeholderImage.getAttribute('src');
|
|
60
|
-
|
|
61
|
-
// Sets the src to transaprent data image instead
|
|
62
|
-
expect(src).toEqual(expect.stringContaining('data:image'));
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('accepts sizes as pixel values', () => {
|
|
66
|
-
const { placeholderImage } = setup({ sizes: [123] });
|
|
67
|
-
|
|
68
|
-
const src = placeholderImage.getAttribute('src');
|
|
69
|
-
|
|
70
|
-
expect(src).toEqual(expect.stringContaining('width=123'));
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('sets opacity to 0.6 while image has not loaded', () => {
|
|
74
|
-
const { placeholderImage } = setup();
|
|
75
|
-
|
|
76
|
-
expect(placeholderImage).toHaveStyle('opacity: 0.6');
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
describe('sets the sizing method', () => {
|
|
81
|
-
it('to thumbnail if no aspect ratio is provided', () => {
|
|
82
|
-
const { placeholderImage } = setup();
|
|
83
|
-
});
|
|
84
|
-
it('to fit if an aspect ratio is provided', () => {
|
|
85
|
-
const { placeholderImage } = setup({ aspect: '1:1' });
|
|
86
|
-
|
|
87
|
-
expect(placeholderImage.getAttribute('src')).toEqual(
|
|
88
|
-
expect.stringContaining('&height=320')
|
|
89
|
-
);
|
|
90
|
-
expect(placeholderImage.getAttribute('src')).toEqual(
|
|
91
|
-
expect.stringContaining('&width=320')
|
|
92
|
-
);
|
|
93
|
-
});
|
|
94
|
-
it('to crop if crop prop is true', () => {
|
|
95
|
-
const { placeholderImage } = setup({ aspect: '1:1', crop: true });
|
|
96
|
-
|
|
97
|
-
expect(placeholderImage.getAttribute('src')).toEqual(
|
|
98
|
-
expect.stringContaining('&method=crop')
|
|
99
|
-
);
|
|
100
|
-
});
|
|
101
|
-
it('warns if gravity is provided without crop', () => {
|
|
102
|
-
console.warn = jest.fn();
|
|
103
|
-
setup({ aspect: '1:1', crop: false, gravity: 'north' });
|
|
104
|
-
expect(console.warn).toHaveBeenCalled();
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
describe('when image is in view', () => {
|
|
109
|
-
beforeAll(() => {
|
|
110
|
-
useInView.mockImplementation(() => [null, true]);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('renders full image', () => {
|
|
114
|
-
const { image } = setup({
|
|
115
|
-
imageSrc: testImage
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
expect(image).toHaveAttribute('src', 'test-image.png');
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('applies the given alt as an aria-label', () => {
|
|
122
|
-
const { image } = setup({
|
|
123
|
-
alt: 'test alt'
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
expect(image).toHaveAttribute('alt', 'test alt');
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('defaults aspect to 1:1', () => {
|
|
130
|
-
const { imageContainer } = setup();
|
|
131
|
-
|
|
132
|
-
expect(imageContainer).toHaveStyle('padding-bottom : 100%');
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('sets aspect ratio using padding if aspect is passed', () => {
|
|
136
|
-
const { imageContainer } = setup({ aspect: '3:2' });
|
|
137
|
-
|
|
138
|
-
expect(imageContainer).toHaveStyle('padding-bottom : 66.6667%');
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('defaults to background-size contain', () => {
|
|
142
|
-
const { image } = setup();
|
|
143
|
-
|
|
144
|
-
expect(image).toHaveStyle('object-fit : contain');
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('sets background-size to cover if `cover` is passed', () => {
|
|
148
|
-
const { image } = setup({ cover: true });
|
|
149
|
-
|
|
150
|
-
expect(image).toHaveStyle('object-fit : cover');
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('sets up image to fill available space if `fillAvailableSpace` is passed', () => {
|
|
154
|
-
const { image } = setup({ fillAvailableSpace: true });
|
|
155
|
-
|
|
156
|
-
expect(image).toHaveStyle('object-fit : cover');
|
|
157
|
-
expect(image).toHaveStyle('padding-top : 0');
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('sets opacity to 1 when image loads', () => {
|
|
161
|
-
const { image } = setup();
|
|
162
|
-
fireEvent.load(image);
|
|
163
|
-
|
|
164
|
-
expect(image).toHaveStyle('opacity: 1');
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it('fades lqip when image loads', () => {
|
|
168
|
-
const { image, placeholderImage } = setup();
|
|
169
|
-
fireEvent.load(image);
|
|
170
|
-
|
|
171
|
-
expect(placeholderImage).toHaveStyle('opacity: 0');
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
test('sets quality to quality prop', () => {
|
|
175
|
-
const { image } = setup({ quality: 1 });
|
|
176
|
-
|
|
177
|
-
expect(image.getAttribute('srcSet')).toEqual(
|
|
178
|
-
expect.stringContaining('&quality=1')
|
|
179
|
-
);
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
describe('when there is an image error', () => {
|
|
184
|
-
beforeAll(() => {
|
|
185
|
-
useInView.mockImplementation(() => [null, true]);
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it('renders default error', () => {
|
|
189
|
-
const { image, getByText } = setup();
|
|
190
|
-
fireEvent.error(image);
|
|
191
|
-
|
|
192
|
-
expect(getByText('Image Not Found'));
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('renders error component', () => {
|
|
196
|
-
const { image, getByText, container } = setup({
|
|
197
|
-
error: () => <div>some error found</div>
|
|
198
|
-
});
|
|
199
|
-
fireEvent.error(image);
|
|
200
|
-
|
|
201
|
-
expect(getByText('some error found'));
|
|
202
|
-
expect(queryByText(container, 'Image Not Found')).not.toBeInTheDocument();
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
describe('when image url is falsy', () => {
|
|
207
|
-
it('renders a transparent background image when null', () => {
|
|
208
|
-
const { image } = setup({ falsySrc: true, imageSrc: null });
|
|
209
|
-
|
|
210
|
-
expect(image).toHaveAttribute(`src`, transparent);
|
|
211
|
-
expect(image).toHaveStyle('opacity : 1');
|
|
212
|
-
});
|
|
213
|
-
it('renders a transparent background image when undefined', () => {
|
|
214
|
-
const { image } = setup({ falsySrc: true, imageSrc: undefined });
|
|
215
|
-
|
|
216
|
-
expect(image).toHaveAttribute(`src`, transparent);
|
|
217
|
-
expect(image).toHaveStyle('opacity: 1');
|
|
218
|
-
});
|
|
219
|
-
it('renders nothing and warns if false', () => {
|
|
220
|
-
console.warn = jest.fn();
|
|
221
|
-
const { image } = setup({ falsySrc: true, imageSrc: false });
|
|
222
|
-
|
|
223
|
-
expect(image).not.toBeInTheDocument();
|
|
224
|
-
expect(console.warn).toHaveBeenCalled();
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it('renders a webp and jpeg source', () => {
|
|
229
|
-
const { imageContainer } = setup();
|
|
230
|
-
|
|
231
|
-
const sources = imageContainer.querySelectorAll('source');
|
|
232
|
-
expect(sources.length).toBe(2);
|
|
233
|
-
expect(sources[0]).toHaveAttribute('type', 'image/webp');
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
function setup({
|
|
238
|
-
imageSrc,
|
|
239
|
-
falsySrc = false,
|
|
240
|
-
error,
|
|
241
|
-
alt,
|
|
242
|
-
sizes,
|
|
243
|
-
aspect,
|
|
244
|
-
cover,
|
|
245
|
-
...rest
|
|
246
|
-
} = {}) {
|
|
247
|
-
const channelHandler = new ChannelHandler({
|
|
248
|
-
selectedChannel,
|
|
249
|
-
channels
|
|
250
|
-
});
|
|
251
|
-
const utils = render(
|
|
252
|
-
<ChannelProvider channelHandler={channelHandler}>
|
|
253
|
-
<ConfigProvider config={mockShopConfig}>
|
|
254
|
-
<Image
|
|
255
|
-
src={falsySrc ? imageSrc : imageSrc || 'default.png'}
|
|
256
|
-
error={error}
|
|
257
|
-
alt={alt}
|
|
258
|
-
sizes={sizes}
|
|
259
|
-
aspect={aspect}
|
|
260
|
-
cover={cover}
|
|
261
|
-
{...rest}
|
|
262
|
-
/>
|
|
263
|
-
</ConfigProvider>
|
|
264
|
-
</ChannelProvider>
|
|
265
|
-
);
|
|
266
|
-
|
|
267
|
-
return {
|
|
268
|
-
...utils,
|
|
269
|
-
image: utils.container.querySelector('[data-flight-image] img'),
|
|
270
|
-
placeholderImage: utils.container.querySelector(
|
|
271
|
-
'[data-flight-image-placeholder] img'
|
|
272
|
-
),
|
|
273
|
-
imageContainer: utils.container.querySelector(
|
|
274
|
-
'[data-flight-image-container]'
|
|
275
|
-
)
|
|
276
|
-
};
|
|
277
|
-
}
|