@blaze-cms/react-page-builder 0.140.3 → 0.141.0-alpha.1
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/CHANGELOG.md +38 -0
- package/README.md +23 -0
- package/lib/components/BlazeLink.js +6 -2
- package/lib/components/BlazeLink.js.map +1 -1
- package/lib/components/Card/Card.js.map +1 -1
- package/lib/components/ContentGroup/ContentGroupTabs.js +10 -8
- package/lib/components/ContentGroup/ContentGroupTabs.js.map +1 -1
- package/lib/components/Image/ImageRender.js +4 -2
- package/lib/components/Image/ImageRender.js.map +1 -1
- package/lib/components/List/ListRender.js +10 -1
- package/lib/components/List/ListRender.js.map +1 -1
- package/lib/components/List/components/Header/ListHeader.js +5 -2
- package/lib/components/List/components/Header/ListHeader.js.map +1 -1
- package/lib/components/List/components/Pagination/Classic.js +2 -2
- package/lib/components/List/components/Pagination/Classic.js.map +1 -1
- package/lib/components/List/components/Pagination/LoadMore.js +2 -1
- package/lib/components/List/components/Pagination/LoadMore.js.map +1 -1
- package/lib/components/List/helpers/build-pagination-items.js +2 -1
- package/lib/components/List/helpers/build-pagination-items.js.map +1 -1
- package/lib/components/List/helpers/build-query-booster.js +57 -0
- package/lib/components/List/helpers/build-query-booster.js.map +1 -0
- package/lib/components/List/helpers/index.js +7 -0
- package/lib/components/List/helpers/index.js.map +1 -1
- package/lib/components/Menu/Menu.js +6 -6
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/MenuItem/MenuItem.js +2 -1
- package/lib/components/MenuItem/MenuItem.js.map +1 -1
- package/lib/components/SearchFilter/components/Select.js +1 -0
- package/lib/components/SearchFilter/components/Select.js.map +1 -1
- package/lib/components/SearchFilterSort/SearchFilterSort.js +1 -0
- package/lib/components/SearchFilterSort/SearchFilterSort.js.map +1 -1
- package/lib/components/SocialFollow/SFItem.js +4 -3
- package/lib/components/SocialFollow/SFItem.js.map +1 -1
- package/lib/components/Video/providers/Default.js +13 -7
- package/lib/components/Video/providers/Default.js.map +1 -1
- package/lib/components/Video/providers/get-provider.js +5 -0
- package/lib/components/Video/providers/get-provider.js.map +1 -1
- package/lib/hooks/helpers/getVariant.js.map +1 -1
- package/lib/hooks/index.js +7 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/use-app-sync-event-hook.js +31 -0
- package/lib/hooks/use-app-sync-event-hook.js.map +1 -0
- package/lib/utils/variant-handler.js +2 -1
- package/lib/utils/variant-handler.js.map +1 -1
- package/lib/variants/HeroImage/index.js +29 -0
- package/lib/variants/HeroImage/index.js.map +1 -0
- package/lib/variants/Infographic/Infographic.js +27 -0
- package/lib/variants/Infographic/Infographic.js.map +1 -0
- package/lib/variants/Infographic/index.js +41 -0
- package/lib/variants/Infographic/index.js.map +1 -0
- package/lib/variants/Infographic/useInfographic.js +43 -0
- package/lib/variants/Infographic/useInfographic.js.map +1 -0
- package/lib/variants/LongformGallery/LongformGallery.js +53 -0
- package/lib/variants/LongformGallery/LongformGallery.js.map +1 -0
- package/lib/variants/LongformGallery/LongformGalleryImage.js +71 -0
- package/lib/variants/LongformGallery/LongformGalleryImage.js.map +1 -0
- package/lib/variants/LongformGallery/constants.js +19 -0
- package/lib/variants/LongformGallery/constants.js.map +1 -0
- package/lib/variants/LongformGallery/helpers/index.js +29 -0
- package/lib/variants/LongformGallery/helpers/index.js.map +1 -0
- package/lib/variants/LongformGallery/helpers/parseImageData.js +42 -0
- package/lib/variants/LongformGallery/helpers/parseImageData.js.map +1 -0
- package/lib/variants/LongformGallery/helpers/separateImages.js +36 -0
- package/lib/variants/LongformGallery/helpers/separateImages.js.map +1 -0
- package/lib/variants/LongformGallery/helpers/shouldSkip.js +13 -0
- package/lib/variants/LongformGallery/helpers/shouldSkip.js.map +1 -0
- package/lib/variants/LongformGallery/index.js +43 -0
- package/lib/variants/LongformGallery/index.js.map +1 -0
- package/lib/variants/LongformGallery/useLongformGallery.js +58 -0
- package/lib/variants/LongformGallery/useLongformGallery.js.map +1 -0
- package/lib/variants/LongformRow/index.js +29 -0
- package/lib/variants/LongformRow/index.js.map +1 -0
- package/lib/variants/ParallaxImageTextRight/index.js +30 -0
- package/lib/variants/ParallaxImageTextRight/index.js.map +1 -0
- package/lib/variants/ThumbnailCarousel/ThumbnailCarousel.js +63 -0
- package/lib/variants/ThumbnailCarousel/ThumbnailCarousel.js.map +1 -0
- package/lib/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js +37 -0
- package/lib/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js.map +1 -0
- package/lib/variants/ThumbnailCarousel/ThumbnailImage/index.js +11 -0
- package/lib/variants/ThumbnailCarousel/ThumbnailImage/index.js.map +1 -0
- package/lib/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js +69 -0
- package/lib/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js.map +1 -0
- package/lib/variants/ThumbnailCarousel/index.js +41 -0
- package/lib/variants/ThumbnailCarousel/index.js.map +1 -0
- package/lib/variants/ThumbnailCarousel/useThumbnailCarousel.js +66 -0
- package/lib/variants/ThumbnailCarousel/useThumbnailCarousel.js.map +1 -0
- package/lib/variants/index.js +15 -1
- package/lib/variants/index.js.map +1 -1
- package/lib-es/components/BlazeLink.js +6 -2
- package/lib-es/components/BlazeLink.js.map +1 -1
- package/lib-es/components/Card/Card.js.map +1 -1
- package/lib-es/components/ContentGroup/ContentGroupTabs.js +10 -8
- package/lib-es/components/ContentGroup/ContentGroupTabs.js.map +1 -1
- package/lib-es/components/Image/ImageRender.js +4 -2
- package/lib-es/components/Image/ImageRender.js.map +1 -1
- package/lib-es/components/List/ListRender.js +11 -1
- package/lib-es/components/List/ListRender.js.map +1 -1
- package/lib-es/components/List/components/Header/ListHeader.js +5 -2
- package/lib-es/components/List/components/Header/ListHeader.js.map +1 -1
- package/lib-es/components/List/components/Pagination/Classic.js +2 -2
- package/lib-es/components/List/components/Pagination/Classic.js.map +1 -1
- package/lib-es/components/List/components/Pagination/LoadMore.js +2 -1
- package/lib-es/components/List/components/Pagination/LoadMore.js.map +1 -1
- package/lib-es/components/List/helpers/build-pagination-items.js +2 -1
- package/lib-es/components/List/helpers/build-pagination-items.js.map +1 -1
- package/lib-es/components/List/helpers/build-query-booster.js +41 -0
- package/lib-es/components/List/helpers/build-query-booster.js.map +1 -0
- package/lib-es/components/List/helpers/index.js +1 -0
- package/lib-es/components/List/helpers/index.js.map +1 -1
- package/lib-es/components/Menu/Menu.js +6 -6
- package/lib-es/components/Menu/Menu.js.map +1 -1
- package/lib-es/components/MenuItem/MenuItem.js +2 -1
- package/lib-es/components/MenuItem/MenuItem.js.map +1 -1
- package/lib-es/components/SearchFilter/components/Select.js +1 -0
- package/lib-es/components/SearchFilter/components/Select.js.map +1 -1
- package/lib-es/components/SearchFilterSort/SearchFilterSort.js +1 -0
- package/lib-es/components/SearchFilterSort/SearchFilterSort.js.map +1 -1
- package/lib-es/components/SocialFollow/SFItem.js +4 -3
- package/lib-es/components/SocialFollow/SFItem.js.map +1 -1
- package/lib-es/components/Video/providers/Default.js +14 -7
- package/lib-es/components/Video/providers/Default.js.map +1 -1
- package/lib-es/components/Video/providers/get-provider.js +2 -1
- package/lib-es/components/Video/providers/get-provider.js.map +1 -1
- package/lib-es/hooks/helpers/getVariant.js.map +1 -1
- package/lib-es/hooks/index.js +1 -0
- package/lib-es/hooks/index.js.map +1 -1
- package/lib-es/hooks/use-app-sync-event-hook.js +25 -0
- package/lib-es/hooks/use-app-sync-event-hook.js.map +1 -0
- package/lib-es/utils/variant-handler.js +2 -1
- package/lib-es/utils/variant-handler.js.map +1 -1
- package/lib-es/variants/HeroImage/index.js +10 -0
- package/lib-es/variants/HeroImage/index.js.map +1 -0
- package/lib-es/variants/Infographic/Infographic.js +20 -0
- package/lib-es/variants/Infographic/Infographic.js.map +1 -0
- package/lib-es/variants/Infographic/index.js +10 -0
- package/lib-es/variants/Infographic/index.js.map +1 -0
- package/lib-es/variants/Infographic/useInfographic.js +23 -0
- package/lib-es/variants/Infographic/useInfographic.js.map +1 -0
- package/lib-es/variants/LongformGallery/LongformGallery.js +40 -0
- package/lib-es/variants/LongformGallery/LongformGallery.js.map +1 -0
- package/lib-es/variants/LongformGallery/LongformGalleryImage.js +59 -0
- package/lib-es/variants/LongformGallery/LongformGalleryImage.js.map +1 -0
- package/lib-es/variants/LongformGallery/constants.js +18 -0
- package/lib-es/variants/LongformGallery/constants.js.map +1 -0
- package/lib-es/variants/LongformGallery/helpers/index.js +5 -0
- package/lib-es/variants/LongformGallery/helpers/index.js.map +1 -0
- package/lib-es/variants/LongformGallery/helpers/parseImageData.js +26 -0
- package/lib-es/variants/LongformGallery/helpers/parseImageData.js.map +1 -0
- package/lib-es/variants/LongformGallery/helpers/separateImages.js +25 -0
- package/lib-es/variants/LongformGallery/helpers/separateImages.js.map +1 -0
- package/lib-es/variants/LongformGallery/helpers/shouldSkip.js +3 -0
- package/lib-es/variants/LongformGallery/helpers/shouldSkip.js.map +1 -0
- package/lib-es/variants/LongformGallery/index.js +12 -0
- package/lib-es/variants/LongformGallery/index.js.map +1 -0
- package/lib-es/variants/LongformGallery/useLongformGallery.js +47 -0
- package/lib-es/variants/LongformGallery/useLongformGallery.js.map +1 -0
- package/lib-es/variants/LongformRow/index.js +10 -0
- package/lib-es/variants/LongformRow/index.js.map +1 -0
- package/lib-es/variants/ParallaxImageTextRight/index.js +11 -0
- package/lib-es/variants/ParallaxImageTextRight/index.js.map +1 -0
- package/lib-es/variants/ThumbnailCarousel/ThumbnailCarousel.js +49 -0
- package/lib-es/variants/ThumbnailCarousel/ThumbnailCarousel.js.map +1 -0
- package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js +30 -0
- package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js.map +1 -0
- package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/index.js +3 -0
- package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/index.js.map +1 -0
- package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js +62 -0
- package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js.map +1 -0
- package/lib-es/variants/ThumbnailCarousel/index.js +10 -0
- package/lib-es/variants/ThumbnailCarousel/index.js.map +1 -0
- package/lib-es/variants/ThumbnailCarousel/useThumbnailCarousel.js +47 -0
- package/lib-es/variants/ThumbnailCarousel/useThumbnailCarousel.js.map +1 -0
- package/lib-es/variants/index.js +14 -1
- package/lib-es/variants/index.js.map +1 -1
- package/package.json +7 -7
- package/src/components/BlazeLink.js +23 -4
- package/src/components/Card/Card.js +0 -1
- package/src/components/ContentGroup/ContentGroupTabs.js +11 -8
- package/src/components/Image/ImageRender.js +4 -2
- package/src/components/List/ListRender.js +11 -1
- package/src/components/List/components/Header/ListHeader.js +7 -4
- package/src/components/List/components/Pagination/Classic.js +2 -2
- package/src/components/List/components/Pagination/LoadMore.js +7 -2
- package/src/components/List/helpers/build-pagination-items.js +2 -1
- package/src/components/List/helpers/build-query-booster.js +35 -0
- package/src/components/List/helpers/index.js +1 -0
- package/src/components/Menu/Menu.js +6 -7
- package/src/components/MenuItem/MenuItem.js +5 -2
- package/src/components/SearchFilter/components/Select.js +1 -0
- package/src/components/SearchFilterSort/SearchFilterSort.js +1 -0
- package/src/components/SocialFollow/SFItem.js +8 -2
- package/src/components/Video/providers/Default.js +12 -6
- package/src/components/Video/providers/get-provider.js +2 -1
- package/src/hooks/helpers/getVariant.js +1 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/use-app-sync-event-hook.js +19 -0
- package/src/utils/variant-handler.js +2 -1
- package/src/variants/HeroImage/index.js +8 -0
- package/src/variants/Infographic/Infographic.js +14 -0
- package/src/variants/Infographic/index.js +12 -0
- package/src/variants/Infographic/useInfographic.js +18 -0
- package/src/variants/LongformGallery/LongformGallery.js +47 -0
- package/src/variants/LongformGallery/LongformGalleryImage.js +65 -0
- package/src/variants/LongformGallery/constants.js +21 -0
- package/src/variants/LongformGallery/helpers/index.js +5 -0
- package/src/variants/LongformGallery/helpers/parseImageData.js +25 -0
- package/src/variants/LongformGallery/helpers/separateImages.js +38 -0
- package/src/variants/LongformGallery/helpers/shouldSkip.js +3 -0
- package/src/variants/LongformGallery/index.js +13 -0
- package/src/variants/LongformGallery/useLongformGallery.js +41 -0
- package/src/variants/LongformRow/index.js +8 -0
- package/src/variants/ParallaxImageTextRight/index.js +9 -0
- package/src/variants/ThumbnailCarousel/ThumbnailCarousel.js +51 -0
- package/src/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js +26 -0
- package/src/variants/ThumbnailCarousel/ThumbnailImage/index.js +3 -0
- package/src/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js +61 -0
- package/src/variants/ThumbnailCarousel/index.js +12 -0
- package/src/variants/ThumbnailCarousel/useThumbnailCarousel.js +42 -0
- package/src/variants/index.js +15 -1
- package/tests/unit/src/components/Breadcrumb/__snapshots__/Breadcrumb.test.js.snap +3 -0
- package/tests/unit/src/components/Button.test.js +2 -2
- package/tests/unit/src/components/Card/__snapshots__/Card.test.js.snap +13 -0
- package/tests/unit/src/components/Card/__snapshots__/CardContainer.test.js.snap +8 -0
- package/tests/unit/src/components/ContentGroup/__snapshots__/ContentGroupTabs.test.js.snap +2 -0
- package/tests/unit/src/components/Image/GlobalLightbox/__snapshots__/GlobalLightbox.test.js.snap +1 -0
- package/tests/unit/src/components/Image/__snapshots__/Image.test.js.snap +3 -0
- package/tests/unit/src/components/Image/__snapshots__/ImageFactory.test.js.snap +4 -0
- package/tests/unit/src/components/List/ListRender.test.js +9 -0
- package/tests/unit/src/components/List/components/Header/__snapshots__/ListHeader.test.js.snap +5 -0
- package/tests/unit/src/components/List/components/Pagination/__snapshots__/Classic.test.js.snap +8 -2
- package/tests/unit/src/components/List/components/Pagination/__snapshots__/ListPagination.test.js.snap +5 -1
- package/tests/unit/src/components/List/components/Pagination/__snapshots__/LoadMore.test.js.snap +1 -1
- package/tests/unit/src/components/List/helpers/__snapshots__/build-pagination-items.test.js.snap +21 -0
- package/tests/unit/src/components/List/helpers/build-query-booster.test.js +33 -0
- package/tests/unit/src/components/MenuItem/__snapshots__/MenuItem.test.js.snap +3 -0
- package/tests/unit/src/components/PlaceholderIcon/__snapshots__/index.test.js.snap +3 -1
- package/tests/unit/src/components/SearchFilter/components/__snapshots__/Select.test.js.snap +5 -3
- package/tests/unit/src/components/SearchFilterSort/__snapshots__/SearchFilterSort.test.js.snap +2 -1
- package/tests/unit/src/components/SocialFollow/__snapshots__/SFItem.test.js.snap +2 -2
- package/tests/unit/src/components/SocialFollow/__snapshots__/SocialFollow.test.js.snap +2 -6
- package/tests/unit/src/components/TextBlock/__snapshots__/TextBlock.test.js.snap +4 -0
- package/tests/unit/src/components/Video/providers/__snapshots__/Default.test.js.snap +111 -108
- package/tests/unit/src/components/__snapshots__/BlazeLink.test.js.snap +1 -1
- package/tests/unit/src/components/__snapshots__/Button.test.js.snap +1 -0
- package/tests/unit/src/helpers/__snapshots__/parse-textBlock.test.js.snap +1 -0
- package/tests/unit/src/helpers/parse-textBlock.test.js +3 -1
- package/tests/unit/src/hooks/use-app-sync-evet-hook.test.js +50 -0
- package/tests/unit/src/utils/variant-handler.test.js +9 -4
- package/tests/unit/src/variants/LongFormGallery/LongformGallery.test.js +42 -0
- package/tests/unit/src/variants/LongFormGallery/LongformGalleryImage.test.js +44 -0
- package/tests/unit/src/variants/LongFormGallery/__snapshots__/LongformGallery.test.js.snap +99 -0
- package/tests/unit/src/variants/LongFormGallery/__snapshots__/LongformGalleryImage.test.js.snap +51 -0
- package/tests/unit/src/variants/LongFormGallery/constants.js +37 -0
- package/tests/unit/src/variants/LongFormGallery/helpers/parseImageData.test.js +53 -0
- package/tests/unit/src/variants/LongFormGallery/helpers/separateImages.test.js +52 -0
- package/tests/unit/src/variants/LongFormGallery/helpers/shouldSkip.test.js +23 -0
- package/tests/unit/src/variants/LongFormGallery/useLongformGallery.test.js +36 -0
- package/tests/unit/src/variants/ThumbnailCarousel/ThumbnailCarousel.test.js +29 -0
- package/tests/unit/src/variants/ThumbnailCarousel/ThumbnailImage.test.js +45 -0
- package/tests/unit/src/variants/ThumbnailCarousel/__snapshots__/ThumbnailCarousel.test.js.snap +71 -0
- package/tests/unit/src/variants/ThumbnailCarousel/__snapshots__/ThumbnailImage.test.js.snap +19 -0
- package/tests/unit/src/variants/ThumbnailCarousel/mocks.js +64 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { parseImageData } from '../../../../../../src/variants/LongformGallery/helpers';
|
|
2
|
+
|
|
3
|
+
describe('parseImageData', () => {
|
|
4
|
+
const mockImage = {
|
|
5
|
+
id: '1',
|
|
6
|
+
url: 'image.jpg',
|
|
7
|
+
data: {
|
|
8
|
+
caption: 'Image Caption'
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
it('parses image data with caption when shouldDisplayCaption is true', () => {
|
|
13
|
+
const parsedData = parseImageData(mockImage, 0, 2, true);
|
|
14
|
+
|
|
15
|
+
expect(parsedData).toEqual({
|
|
16
|
+
id: '1',
|
|
17
|
+
url: 'image.jpg',
|
|
18
|
+
caption: 'Image Caption',
|
|
19
|
+
priority: true,
|
|
20
|
+
altText: '',
|
|
21
|
+
credits: '',
|
|
22
|
+
hrefUrl: ''
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('parses image data without caption when shouldDisplayCaption is false', () => {
|
|
27
|
+
const parsedData = parseImageData(mockImage, 0, 2, false);
|
|
28
|
+
|
|
29
|
+
expect(parsedData).toEqual({
|
|
30
|
+
id: '1',
|
|
31
|
+
url: 'image.jpg',
|
|
32
|
+
caption: '',
|
|
33
|
+
priority: true,
|
|
34
|
+
altText: '',
|
|
35
|
+
credits: '',
|
|
36
|
+
hrefUrl: ''
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('parses image data with default values when data is undefined', () => {
|
|
41
|
+
const parsedData = parseImageData({ id: '1', url: 'image.jpg' }, 0, 2, true);
|
|
42
|
+
|
|
43
|
+
expect(parsedData).toEqual({
|
|
44
|
+
id: '1',
|
|
45
|
+
url: 'image.jpg',
|
|
46
|
+
caption: '',
|
|
47
|
+
priority: true,
|
|
48
|
+
altText: '',
|
|
49
|
+
credits: '',
|
|
50
|
+
hrefUrl: ''
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { separateImages } from '../../../../../../src/variants/LongformGallery/helpers';
|
|
2
|
+
|
|
3
|
+
describe('separateImages', () => {
|
|
4
|
+
const mockImages = [
|
|
5
|
+
{ id: '1', url: 'image1.jpg', data: { caption: 'Caption 1' } },
|
|
6
|
+
{ id: '2', url: 'image2.jpg', data: { caption: 'Caption 2' } },
|
|
7
|
+
{ id: '3', url: 'image3.jpg', data: { caption: 'Caption 3' } }
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
it('returns empty arrays for undefined or empty images', () => {
|
|
11
|
+
const result = separateImages(undefined, 2);
|
|
12
|
+
expect(result).toEqual([]);
|
|
13
|
+
|
|
14
|
+
const resultEmptyArray = separateImages([], 2, true);
|
|
15
|
+
expect(resultEmptyArray).toEqual([]);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('returns grouped images i narrays', () => {
|
|
19
|
+
const groupedImages = separateImages(mockImages, 2, true);
|
|
20
|
+
|
|
21
|
+
expect(groupedImages).toHaveLength(1);
|
|
22
|
+
expect(groupedImages[0]).toHaveLength(3);
|
|
23
|
+
expect(groupedImages[0][0]).toEqual({
|
|
24
|
+
id: '1',
|
|
25
|
+
url: 'image1.jpg',
|
|
26
|
+
caption: 'Caption 1',
|
|
27
|
+
priority: true,
|
|
28
|
+
altText: '',
|
|
29
|
+
credits: '',
|
|
30
|
+
hrefUrl: ''
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
expect(groupedImages[0][1]).toEqual({
|
|
34
|
+
id: '2',
|
|
35
|
+
url: 'image2.jpg',
|
|
36
|
+
caption: 'Caption 2',
|
|
37
|
+
priority: true,
|
|
38
|
+
altText: '',
|
|
39
|
+
credits: '',
|
|
40
|
+
hrefUrl: ''
|
|
41
|
+
});
|
|
42
|
+
expect(groupedImages[0][2]).toEqual({
|
|
43
|
+
id: '3',
|
|
44
|
+
url: 'image3.jpg',
|
|
45
|
+
caption: 'Caption 3',
|
|
46
|
+
priority: false,
|
|
47
|
+
altText: '',
|
|
48
|
+
credits: '',
|
|
49
|
+
hrefUrl: ''
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { shouldSkip } from '../../../../../../src/variants/LongformGallery/helpers';
|
|
2
|
+
|
|
3
|
+
describe('shouldSkip', () => {
|
|
4
|
+
it('returns true when ids is undefined', () => {
|
|
5
|
+
const result = shouldSkip(undefined);
|
|
6
|
+
expect(result).toBe(true);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('returns true when ids is an empty array', () => {
|
|
10
|
+
const result = shouldSkip([]);
|
|
11
|
+
expect(result).toBe(true);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('returns false when ids is a non-empty array', () => {
|
|
15
|
+
const result = shouldSkip(['1', '2', '3']);
|
|
16
|
+
expect(result).toBe(false);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('returns false when ids is a non-array value', () => {
|
|
20
|
+
const result = shouldSkip('not an array');
|
|
21
|
+
expect(result).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { renderHook } from '@testing-library/react-hooks';
|
|
6
|
+
import { MockedProvider } from '@apollo/client/testing';
|
|
7
|
+
import useLongformGallery from '../../../../../src/variants/LongformGallery/useLongformGallery';
|
|
8
|
+
import { IMAGE_MOCKS } from './constants';
|
|
9
|
+
|
|
10
|
+
describe('useLongformGallery', () => {
|
|
11
|
+
it('returns data, loading, error, mainImages, secondaryImages, and handleImageOnClick', async () => {
|
|
12
|
+
const { result, waitForNextUpdate } = renderHook(
|
|
13
|
+
() =>
|
|
14
|
+
useLongformGallery({
|
|
15
|
+
imageIds: ['1', '2', '3'],
|
|
16
|
+
enableLightbox: true,
|
|
17
|
+
toggleModal: jest.fn(),
|
|
18
|
+
handleSelectedImage: jest.fn()
|
|
19
|
+
}),
|
|
20
|
+
{
|
|
21
|
+
wrapper: ({ children }) => <MockedProvider mocks={IMAGE_MOCKS}>{children}</MockedProvider>
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
expect(result.current.data).toBeUndefined();
|
|
26
|
+
expect(result.current.loading).toBe(true);
|
|
27
|
+
expect(result.current.error).toBeUndefined();
|
|
28
|
+
expect(result.current.groupedImages).toEqual([]);
|
|
29
|
+
|
|
30
|
+
await waitForNextUpdate();
|
|
31
|
+
|
|
32
|
+
expect(result.current.loading).toBe(false);
|
|
33
|
+
expect(result.current.error).toBeUndefined();
|
|
34
|
+
expect(result.current.groupedImages).toHaveLength(1);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
6
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
7
|
+
import { MockedProvider } from '@apollo/client/testing';
|
|
8
|
+
import ThumbnailCarousel from '../../../../../src/variants/ThumbnailCarousel/ThumbnailCarousel';
|
|
9
|
+
import IMAGE_MOCKS from './mocks';
|
|
10
|
+
|
|
11
|
+
const mockedProps = {
|
|
12
|
+
imageIds: ['1', '2', '3'],
|
|
13
|
+
priorityLimit: 0
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
describe('ThumbnailCarousel component', () => {
|
|
17
|
+
it('renders ThumbnailCarousel without error', async () => {
|
|
18
|
+
const { asFragment } = render(
|
|
19
|
+
<MockedProvider mocks={IMAGE_MOCKS}>
|
|
20
|
+
<ThumbnailCarousel {...mockedProps} />
|
|
21
|
+
</MockedProvider>
|
|
22
|
+
);
|
|
23
|
+
await waitFor(() => {
|
|
24
|
+
expect(screen.getAllByTestId('thumbnail-image')[0]).toBeInTheDocument();
|
|
25
|
+
});
|
|
26
|
+
expect(asFragment()).toMatchSnapshot();
|
|
27
|
+
expect(screen.getByTestId('thumbnail-carousel')).toBeInTheDocument();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
6
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
7
|
+
import { MockedProvider } from '@apollo/client/testing';
|
|
8
|
+
import ThumbnailImage from '../../../../../src/variants/ThumbnailCarousel/ThumbnailImage';
|
|
9
|
+
import IMAGE_MOCKS from './mocks';
|
|
10
|
+
|
|
11
|
+
describe('ThumbnailImage component', () => {
|
|
12
|
+
const mockedProps = {
|
|
13
|
+
imageId: '1',
|
|
14
|
+
enableLightbox: false,
|
|
15
|
+
toggleModal: () => {},
|
|
16
|
+
handleSelectedImage: () => {},
|
|
17
|
+
priority: 0,
|
|
18
|
+
selectedImageId: '1',
|
|
19
|
+
handleOnClick: () => {}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
it('renders ThumbnailImage without error', async () => {
|
|
23
|
+
const { asFragment } = render(
|
|
24
|
+
<MockedProvider mocks={IMAGE_MOCKS}>
|
|
25
|
+
<ThumbnailImage {...mockedProps} />
|
|
26
|
+
</MockedProvider>
|
|
27
|
+
);
|
|
28
|
+
await waitFor(() => {
|
|
29
|
+
expect(screen.getByTestId('thumbnail-image')).toBeInTheDocument();
|
|
30
|
+
});
|
|
31
|
+
expect(asFragment()).toMatchSnapshot();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should render error message if query fails', async () => {
|
|
35
|
+
const { asFragment } = render(
|
|
36
|
+
<MockedProvider mocks={IMAGE_MOCKS}>
|
|
37
|
+
<ThumbnailImage {...mockedProps} imageId="6" />
|
|
38
|
+
</MockedProvider>
|
|
39
|
+
);
|
|
40
|
+
await waitFor(() => {
|
|
41
|
+
expect(screen.getByText('Oops something went wrong')).toBeInTheDocument();
|
|
42
|
+
});
|
|
43
|
+
expect(asFragment()).toMatchSnapshot();
|
|
44
|
+
});
|
|
45
|
+
});
|
package/tests/unit/src/variants/ThumbnailCarousel/__snapshots__/ThumbnailCarousel.test.js.snap
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ThumbnailCarousel component renders ThumbnailCarousel without error 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="thumbnail-carousel"
|
|
7
|
+
data-testid="thumbnail-carousel"
|
|
8
|
+
>
|
|
9
|
+
<div
|
|
10
|
+
class="thumbnail-carousel__main_image_container"
|
|
11
|
+
>
|
|
12
|
+
<div
|
|
13
|
+
class="thumbnail-carousel__main_image_container__button"
|
|
14
|
+
id="previous-button"
|
|
15
|
+
role="button"
|
|
16
|
+
>
|
|
17
|
+
<div
|
|
18
|
+
class="arrow arrow--left"
|
|
19
|
+
/>
|
|
20
|
+
</div>
|
|
21
|
+
<div
|
|
22
|
+
class="thumbnail-carousel-image"
|
|
23
|
+
data-testid="thumbnail-image"
|
|
24
|
+
role="button"
|
|
25
|
+
>
|
|
26
|
+
<span>
|
|
27
|
+
<img
|
|
28
|
+
alt=""
|
|
29
|
+
role="button"
|
|
30
|
+
src="image1.jpg"
|
|
31
|
+
/>
|
|
32
|
+
</span>
|
|
33
|
+
</div>
|
|
34
|
+
<div
|
|
35
|
+
class="thumbnail-carousel__main_image_container__button next"
|
|
36
|
+
id="next-button"
|
|
37
|
+
role="button"
|
|
38
|
+
>
|
|
39
|
+
<div
|
|
40
|
+
class="arrow arrow--right"
|
|
41
|
+
/>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
<div
|
|
45
|
+
class="thumbnail-carousel__list"
|
|
46
|
+
>
|
|
47
|
+
<div
|
|
48
|
+
class="thumbnail-carousel-image thumbnail-carousel-image--selected"
|
|
49
|
+
data-testid="thumbnail-image"
|
|
50
|
+
role="button"
|
|
51
|
+
>
|
|
52
|
+
<span />
|
|
53
|
+
</div>
|
|
54
|
+
<div
|
|
55
|
+
class="thumbnail-carousel-image"
|
|
56
|
+
data-testid="thumbnail-image"
|
|
57
|
+
role="button"
|
|
58
|
+
>
|
|
59
|
+
<span />
|
|
60
|
+
</div>
|
|
61
|
+
<div
|
|
62
|
+
class="thumbnail-carousel-image"
|
|
63
|
+
data-testid="thumbnail-image"
|
|
64
|
+
role="button"
|
|
65
|
+
>
|
|
66
|
+
<span />
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</DocumentFragment>
|
|
71
|
+
`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ThumbnailImage component renders ThumbnailImage without error 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="thumbnail-carousel-image thumbnail-carousel-image--selected"
|
|
7
|
+
data-testid="thumbnail-image"
|
|
8
|
+
role="button"
|
|
9
|
+
>
|
|
10
|
+
<span />
|
|
11
|
+
</div>
|
|
12
|
+
</DocumentFragment>
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
exports[`ThumbnailImage component should render error message if query fails 1`] = `
|
|
16
|
+
<DocumentFragment>
|
|
17
|
+
Oops something went wrong
|
|
18
|
+
</DocumentFragment>
|
|
19
|
+
`;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { getFileById } from '../../../../../src/application/query';
|
|
2
|
+
|
|
3
|
+
const IMAGE_MOCKS = [
|
|
4
|
+
{
|
|
5
|
+
request: {
|
|
6
|
+
query: getFileById,
|
|
7
|
+
variables: { id: '1' }
|
|
8
|
+
},
|
|
9
|
+
result: {
|
|
10
|
+
data: {
|
|
11
|
+
getFile: { id: '1', url: 'image1.jpg', caption: 'Caption 1', data: {} }
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
request: {
|
|
17
|
+
query: getFileById,
|
|
18
|
+
variables: { id: '2' }
|
|
19
|
+
},
|
|
20
|
+
result: {
|
|
21
|
+
data: {
|
|
22
|
+
getFile: { id: '2', url: 'image2.jpg', caption: 'Caption 2', data: {} }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
request: {
|
|
28
|
+
query: getFileById,
|
|
29
|
+
variables: { id: '3' }
|
|
30
|
+
},
|
|
31
|
+
result: {
|
|
32
|
+
data: {
|
|
33
|
+
getFile: { id: '3', url: 'image3.jpg', caption: 'Caption 3', data: {} }
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
request: {
|
|
39
|
+
query: getFileById,
|
|
40
|
+
variables: { id: '6' }
|
|
41
|
+
},
|
|
42
|
+
error: {
|
|
43
|
+
message: 'Oops something went wrong'
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// {
|
|
47
|
+
// request: {
|
|
48
|
+
// query: getFiles,
|
|
49
|
+
// variables: { where: { id: { _in: ['1', '2', '3', '4'] } } }
|
|
50
|
+
// },
|
|
51
|
+
// result: {
|
|
52
|
+
// data: {
|
|
53
|
+
// getImages: [
|
|
54
|
+
// { id: '1', url: 'image1.jpg', caption: 'Caption 1', data: {} },
|
|
55
|
+
// { id: '2', url: 'image2.jpg', caption: 'Caption 2', data: {} },
|
|
56
|
+
// { id: '3', url: 'image3.jpg', caption: 'Caption 3', data: {} },
|
|
57
|
+
// { id: '4', url: 'image4.jpg', caption: 'Caption 4', data: {} }
|
|
58
|
+
// ]
|
|
59
|
+
// }
|
|
60
|
+
// }
|
|
61
|
+
// }
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
export default IMAGE_MOCKS;
|