@blaze-cms/react-page-builder 0.141.0-core-styles.21 → 0.141.0-core-styles.23
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 +22 -0
- package/lib/components/ContentGroup/ContentGroupTabs.js +10 -8
- package/lib/components/ContentGroup/ContentGroupTabs.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/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 +8 -10
- package/lib/variants/ThumbnailCarousel/ThumbnailCarousel.js.map +1 -1
- package/lib/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js +1 -5
- package/lib/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js.map +1 -1
- package/lib/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js +10 -23
- package/lib/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js.map +1 -1
- package/lib/variants/ThumbnailCarousel/index.js +15 -3
- package/lib/variants/ThumbnailCarousel/index.js.map +1 -1
- package/lib/variants/ThumbnailCarousel/useThumbnailCarousel.js +13 -9
- package/lib/variants/ThumbnailCarousel/useThumbnailCarousel.js.map +1 -1
- package/lib/variants/index.js +10 -0
- package/lib/variants/index.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/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/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 +8 -10
- package/lib-es/variants/ThumbnailCarousel/ThumbnailCarousel.js.map +1 -1
- package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js +1 -5
- package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js.map +1 -1
- package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js +10 -23
- package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js.map +1 -1
- package/lib-es/variants/ThumbnailCarousel/index.js +2 -2
- package/lib-es/variants/ThumbnailCarousel/index.js.map +1 -1
- package/lib-es/variants/ThumbnailCarousel/useThumbnailCarousel.js +13 -8
- package/lib-es/variants/ThumbnailCarousel/useThumbnailCarousel.js.map +1 -1
- package/lib-es/variants/index.js +10 -0
- package/lib-es/variants/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/ContentGroup/ContentGroupTabs.js +11 -8
- 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/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 +6 -10
- package/src/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js +4 -18
- package/src/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js +11 -25
- package/src/variants/ThumbnailCarousel/index.js +4 -2
- package/src/variants/ThumbnailCarousel/useThumbnailCarousel.js +13 -8
- package/src/variants/index.js +10 -0
- package/tests/unit/src/components/ContentGroup/__snapshots__/ContentGroupTabs.test.js.snap +2 -0
- package/tests/unit/src/components/Video/providers/__snapshots__/Default.test.js.snap +111 -108
- 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/__snapshots__/ThumbnailCarousel.test.js.snap +10 -15
|
@@ -3,159 +3,162 @@
|
|
|
3
3
|
exports[`Default provider component should render without throwing error and match snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<div
|
|
6
|
-
class="
|
|
7
|
-
role="region"
|
|
8
|
-
style="padding-top: 56.25%;"
|
|
9
|
-
tabindex="-1"
|
|
6
|
+
class="video__wrapper"
|
|
10
7
|
>
|
|
11
|
-
<video
|
|
12
|
-
class="video-react-video"
|
|
13
|
-
preload="none"
|
|
14
|
-
tabindex="-1"
|
|
15
|
-
>
|
|
16
|
-
<source
|
|
17
|
-
src="http://media.w3.org/2010/05/bunny/movie.mp4"
|
|
18
|
-
type="video/mp4"
|
|
19
|
-
/>
|
|
20
|
-
</video>
|
|
21
8
|
<div
|
|
22
|
-
class="video-react-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class="video-react-big-play-button video-react-big-play-button-left big-play-button-hide"
|
|
27
|
-
tabindex="0"
|
|
28
|
-
type="button"
|
|
9
|
+
class="video-react-controls-enabled video-react-paused video-react-fluid video-react-user-active video-react-workinghover video-react mocked-modifier"
|
|
10
|
+
role="region"
|
|
11
|
+
style="padding-top: 56.25%;"
|
|
12
|
+
tabindex="-1"
|
|
29
13
|
>
|
|
30
|
-
<
|
|
31
|
-
class="video-react-
|
|
14
|
+
<video
|
|
15
|
+
class="video-react-video"
|
|
16
|
+
preload="none"
|
|
17
|
+
tabindex="-1"
|
|
32
18
|
>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
19
|
+
<source
|
|
20
|
+
src="http://media.w3.org/2010/05/bunny/movie.mp4"
|
|
21
|
+
/>
|
|
22
|
+
</video>
|
|
23
|
+
<div
|
|
24
|
+
class="video-react-loading-spinner"
|
|
25
|
+
/>
|
|
39
26
|
<button
|
|
40
|
-
|
|
27
|
+
aria-live="polite"
|
|
28
|
+
class="video-react-big-play-button video-react-big-play-button-left big-play-button-hide"
|
|
41
29
|
tabindex="0"
|
|
42
30
|
type="button"
|
|
43
31
|
>
|
|
44
32
|
<span
|
|
45
33
|
class="video-react-control-text"
|
|
46
34
|
>
|
|
47
|
-
Play
|
|
35
|
+
Play Video
|
|
48
36
|
</span>
|
|
49
37
|
</button>
|
|
50
38
|
<div
|
|
51
|
-
class="video-react-
|
|
52
|
-
role="button"
|
|
53
|
-
tabindex="0"
|
|
39
|
+
class="video-react-control-bar video-react-control-bar-auto-hide"
|
|
54
40
|
>
|
|
41
|
+
<button
|
|
42
|
+
class="video-react-play-control video-react-control video-react-button video-react-paused"
|
|
43
|
+
tabindex="0"
|
|
44
|
+
type="button"
|
|
45
|
+
>
|
|
46
|
+
<span
|
|
47
|
+
class="video-react-control-text"
|
|
48
|
+
>
|
|
49
|
+
Play
|
|
50
|
+
</span>
|
|
51
|
+
</button>
|
|
55
52
|
<div
|
|
56
|
-
class="video-react-menu"
|
|
53
|
+
class="video-react-volume-menu-button-horizontal video-react-vol-3 video-react-volume-menu-button video-react-menu-button-inline video-react-control video-react-button video-react-menu-button"
|
|
54
|
+
role="button"
|
|
55
|
+
tabindex="0"
|
|
57
56
|
>
|
|
58
57
|
<div
|
|
59
|
-
class="video-react-menu
|
|
58
|
+
class="video-react-menu"
|
|
60
59
|
>
|
|
61
60
|
<div
|
|
62
|
-
|
|
63
|
-
aria-valuemax="100"
|
|
64
|
-
aria-valuemin="0"
|
|
65
|
-
aria-valuenow="100.00"
|
|
66
|
-
aria-valuetext="100.00%"
|
|
67
|
-
class="video-react-volume-bar video-react-slider-bar video-react-slider-horizontal video-react-slider"
|
|
68
|
-
role="slider"
|
|
69
|
-
tabindex="0"
|
|
61
|
+
class="video-react-menu-content"
|
|
70
62
|
>
|
|
71
63
|
<div
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
aria-label="volume level"
|
|
65
|
+
aria-valuemax="100"
|
|
66
|
+
aria-valuemin="0"
|
|
67
|
+
aria-valuenow="100.00"
|
|
68
|
+
aria-valuetext="100.00%"
|
|
69
|
+
class="video-react-volume-bar video-react-slider-bar video-react-slider-horizontal video-react-slider"
|
|
70
|
+
role="slider"
|
|
71
|
+
tabindex="0"
|
|
74
72
|
>
|
|
75
|
-
<
|
|
76
|
-
class="video-react-
|
|
77
|
-
|
|
73
|
+
<div
|
|
74
|
+
class="video-react-volume-level"
|
|
75
|
+
style="width: 100.00%;"
|
|
76
|
+
>
|
|
77
|
+
<span
|
|
78
|
+
class="video-react-control-text"
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
78
81
|
</div>
|
|
79
82
|
</div>
|
|
80
83
|
</div>
|
|
81
84
|
</div>
|
|
82
|
-
</div>
|
|
83
|
-
<div
|
|
84
|
-
class="video-react-current-time video-react-time-control video-react-control"
|
|
85
|
-
>
|
|
86
85
|
<div
|
|
87
|
-
|
|
88
|
-
class="video-react-current-time-display"
|
|
86
|
+
class="video-react-current-time video-react-time-control video-react-control"
|
|
89
87
|
>
|
|
90
|
-
<
|
|
91
|
-
|
|
88
|
+
<div
|
|
89
|
+
aria-live="off"
|
|
90
|
+
class="video-react-current-time-display"
|
|
92
91
|
>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
dir="ltr"
|
|
101
|
-
>
|
|
102
|
-
<div>
|
|
103
|
-
<span>
|
|
104
|
-
/
|
|
105
|
-
</span>
|
|
92
|
+
<span
|
|
93
|
+
class="video-react-control-text"
|
|
94
|
+
>
|
|
95
|
+
Current Time
|
|
96
|
+
</span>
|
|
97
|
+
0:00
|
|
98
|
+
</div>
|
|
106
99
|
</div>
|
|
107
|
-
</div>
|
|
108
|
-
<div
|
|
109
|
-
class="video-react-duration video-react-time-control video-react-control"
|
|
110
|
-
>
|
|
111
100
|
<div
|
|
112
|
-
|
|
113
|
-
|
|
101
|
+
class="video-react-time-control video-react-time-divider"
|
|
102
|
+
dir="ltr"
|
|
114
103
|
>
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
</
|
|
120
|
-
0:00
|
|
104
|
+
<div>
|
|
105
|
+
<span>
|
|
106
|
+
/
|
|
107
|
+
</span>
|
|
108
|
+
</div>
|
|
121
109
|
</div>
|
|
122
|
-
</div>
|
|
123
|
-
<div
|
|
124
|
-
class="video-react-progress-control video-react-control"
|
|
125
|
-
>
|
|
126
110
|
<div
|
|
127
|
-
|
|
128
|
-
aria-valuemax="100"
|
|
129
|
-
aria-valuemin="0"
|
|
130
|
-
aria-valuenow="NaN"
|
|
131
|
-
aria-valuetext="0:00"
|
|
132
|
-
class="video-react-progress-holder video-react-slider-horizontal video-react-slider"
|
|
133
|
-
role="slider"
|
|
134
|
-
tabindex="0"
|
|
111
|
+
class="video-react-duration video-react-time-control video-react-control"
|
|
135
112
|
>
|
|
136
113
|
<div
|
|
137
|
-
|
|
138
|
-
|
|
114
|
+
aria-live="off"
|
|
115
|
+
class="video-react-duration-display"
|
|
139
116
|
>
|
|
140
117
|
<span
|
|
141
118
|
class="video-react-control-text"
|
|
142
119
|
>
|
|
143
|
-
|
|
120
|
+
Duration Time
|
|
144
121
|
</span>
|
|
122
|
+
0:00
|
|
145
123
|
</div>
|
|
146
124
|
</div>
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
class="video-react-icon-fullscreen video-react-fullscreen-control video-react-control video-react-button video-react-icon"
|
|
150
|
-
tabindex="0"
|
|
151
|
-
type="button"
|
|
152
|
-
>
|
|
153
|
-
<span
|
|
154
|
-
class="video-react-control-text"
|
|
125
|
+
<div
|
|
126
|
+
class="video-react-progress-control video-react-control"
|
|
155
127
|
>
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
128
|
+
<div
|
|
129
|
+
aria-label="video progress bar"
|
|
130
|
+
aria-valuemax="100"
|
|
131
|
+
aria-valuemin="0"
|
|
132
|
+
aria-valuenow="NaN"
|
|
133
|
+
aria-valuetext="0:00"
|
|
134
|
+
class="video-react-progress-holder video-react-slider-horizontal video-react-slider"
|
|
135
|
+
role="slider"
|
|
136
|
+
tabindex="0"
|
|
137
|
+
>
|
|
138
|
+
<div
|
|
139
|
+
class="video-react-play-progress video-react-slider-bar"
|
|
140
|
+
data-current-time="0:00"
|
|
141
|
+
>
|
|
142
|
+
<span
|
|
143
|
+
class="video-react-control-text"
|
|
144
|
+
>
|
|
145
|
+
Progress: NaN%
|
|
146
|
+
</span>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
<button
|
|
151
|
+
class="video-react-icon-fullscreen video-react-fullscreen-control video-react-control video-react-button video-react-icon"
|
|
152
|
+
tabindex="0"
|
|
153
|
+
type="button"
|
|
154
|
+
>
|
|
155
|
+
<span
|
|
156
|
+
class="video-react-control-text"
|
|
157
|
+
>
|
|
158
|
+
Non-Fullscreen
|
|
159
|
+
</span>
|
|
160
|
+
</button>
|
|
161
|
+
</div>
|
|
159
162
|
</div>
|
|
160
163
|
</div>
|
|
161
164
|
</DocumentFragment>
|
|
@@ -33,9 +33,14 @@ describe('variantHandler function', () => {
|
|
|
33
33
|
expect(entries.length).toEqual(2);
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
it('should
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
);
|
|
36
|
+
it('should call console.warn error if we try to add an object that has already been added', () => {
|
|
37
|
+
const { warn } = console;
|
|
38
|
+
// eslint-disable-next-line no-console
|
|
39
|
+
console.warn = jest.fn();
|
|
40
|
+
variantHandler.add('RandomVariant', () => <div />);
|
|
41
|
+
// eslint-disable-next-line no-console
|
|
42
|
+
expect(console.warn).toHaveBeenCalledWith('Variant already exists: RandomVariant');
|
|
43
|
+
// eslint-disable-next-line no-console
|
|
44
|
+
console.warn = warn;
|
|
40
45
|
});
|
|
41
46
|
});
|
|
@@ -0,0 +1,42 @@
|
|
|
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 LongformGallery from '../../../../../src/variants/LongformGallery/LongformGallery';
|
|
9
|
+
import { IMAGE_MOCKS } from './constants';
|
|
10
|
+
|
|
11
|
+
const mockedProps = {
|
|
12
|
+
imageIds: ['1', '2', '3'],
|
|
13
|
+
priorityLimit: [0]
|
|
14
|
+
};
|
|
15
|
+
const longFormTestId = 'longform-gallery';
|
|
16
|
+
|
|
17
|
+
describe('LongformGallery', () => {
|
|
18
|
+
it('renders LongformGallery without error', async () => {
|
|
19
|
+
const { asFragment } = render(
|
|
20
|
+
<MockedProvider mocks={IMAGE_MOCKS}>
|
|
21
|
+
<LongformGallery {...mockedProps} />
|
|
22
|
+
</MockedProvider>
|
|
23
|
+
);
|
|
24
|
+
await waitFor(() => {
|
|
25
|
+
expect(screen.getByTestId(longFormTestId)).toBeInTheDocument();
|
|
26
|
+
});
|
|
27
|
+
expect(asFragment()).toMatchSnapshot();
|
|
28
|
+
expect(screen.getByTestId(longFormTestId)).toBeInTheDocument();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('renders LongformGallery with two-group modifier if images length is 4', async () => {
|
|
32
|
+
const { asFragment } = render(
|
|
33
|
+
<MockedProvider mocks={IMAGE_MOCKS}>
|
|
34
|
+
<LongformGallery {...mockedProps} imageIds={['1', '2', '3', '4']} />
|
|
35
|
+
</MockedProvider>
|
|
36
|
+
);
|
|
37
|
+
await waitFor(() => {
|
|
38
|
+
expect(screen.getByTestId(longFormTestId)).toBeInTheDocument();
|
|
39
|
+
});
|
|
40
|
+
expect(asFragment()).toMatchSnapshot();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
6
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
7
|
+
import LongformGalleryImage from '../../../../../src/variants/LongformGallery/LongformGalleryImage';
|
|
8
|
+
|
|
9
|
+
const mockedProps = {
|
|
10
|
+
url: 'https://mock-url/image-id-1.jpg',
|
|
11
|
+
id: 'image-id-1',
|
|
12
|
+
caption: '',
|
|
13
|
+
altText: '',
|
|
14
|
+
priority: true,
|
|
15
|
+
className: 'longform-gallery__images__image main-image',
|
|
16
|
+
handleImageOnClick: jest.fn()
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
describe('LongformGalleryImage component', () => {
|
|
20
|
+
it('should be a function', () => {
|
|
21
|
+
expect(typeof LongformGalleryImage).toEqual('function');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('renders LongformGalleryImage component', () => {
|
|
25
|
+
const { asFragment } = render(<LongformGalleryImage {...mockedProps} />);
|
|
26
|
+
expect(asFragment()).toMatchSnapshot();
|
|
27
|
+
expect(screen.getByTestId('longform-gallery__images__image__container')).toBeInTheDocument();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('renders LongformGalleryImage component', () => {
|
|
31
|
+
const { asFragment } = render(
|
|
32
|
+
<LongformGalleryImage {...mockedProps} caption="some image caption" />
|
|
33
|
+
);
|
|
34
|
+
expect(asFragment()).toMatchSnapshot();
|
|
35
|
+
expect(screen.getByTestId('longform-gallery__images__image__details')).toBeInTheDocument();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('calls handleImageOnClick when image is clicked', () => {
|
|
39
|
+
render(<LongformGalleryImage {...mockedProps} />);
|
|
40
|
+
const image = screen.getByTestId('longform-gallery__images__image__container');
|
|
41
|
+
fireEvent.click(image);
|
|
42
|
+
expect(mockedProps.handleImageOnClick).toHaveBeenCalledWith(mockedProps.id);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`LongformGallery renders LongformGallery with two-group modifier if images length is 4 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="longform-gallery"
|
|
7
|
+
data-testid="longform-gallery"
|
|
8
|
+
>
|
|
9
|
+
<div
|
|
10
|
+
class="longform-gallery__images"
|
|
11
|
+
data-testid="grouped-images"
|
|
12
|
+
>
|
|
13
|
+
<div
|
|
14
|
+
class="longform-gallery__images__image main-image"
|
|
15
|
+
>
|
|
16
|
+
<div
|
|
17
|
+
class="longform-gallery__images__image__container"
|
|
18
|
+
data-testid="longform-gallery__images__image__container"
|
|
19
|
+
role="button"
|
|
20
|
+
/>
|
|
21
|
+
</div>
|
|
22
|
+
<div
|
|
23
|
+
class="longform-gallery__images__image main-image"
|
|
24
|
+
>
|
|
25
|
+
<div
|
|
26
|
+
class="longform-gallery__images__image__container"
|
|
27
|
+
data-testid="longform-gallery__images__image__container"
|
|
28
|
+
role="button"
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
<div
|
|
33
|
+
class="longform-gallery__images"
|
|
34
|
+
data-testid="grouped-images"
|
|
35
|
+
>
|
|
36
|
+
<div
|
|
37
|
+
class="longform-gallery__images__image main-image"
|
|
38
|
+
>
|
|
39
|
+
<div
|
|
40
|
+
class="longform-gallery__images__image__container"
|
|
41
|
+
data-testid="longform-gallery__images__image__container"
|
|
42
|
+
role="button"
|
|
43
|
+
/>
|
|
44
|
+
</div>
|
|
45
|
+
<div
|
|
46
|
+
class="longform-gallery__images__image main-image"
|
|
47
|
+
>
|
|
48
|
+
<div
|
|
49
|
+
class="longform-gallery__images__image__container"
|
|
50
|
+
data-testid="longform-gallery__images__image__container"
|
|
51
|
+
role="button"
|
|
52
|
+
/>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
</DocumentFragment>
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
exports[`LongformGallery renders LongformGallery without error 1`] = `
|
|
60
|
+
<DocumentFragment>
|
|
61
|
+
<div
|
|
62
|
+
class="longform-gallery"
|
|
63
|
+
data-testid="longform-gallery"
|
|
64
|
+
>
|
|
65
|
+
<div
|
|
66
|
+
class="longform-gallery__images"
|
|
67
|
+
data-testid="grouped-images"
|
|
68
|
+
>
|
|
69
|
+
<div
|
|
70
|
+
class="longform-gallery__images__image secondary-image"
|
|
71
|
+
>
|
|
72
|
+
<div
|
|
73
|
+
class="longform-gallery__images__image__container"
|
|
74
|
+
data-testid="longform-gallery__images__image__container"
|
|
75
|
+
role="button"
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
<div
|
|
79
|
+
class="longform-gallery__images__image secondary-image"
|
|
80
|
+
>
|
|
81
|
+
<div
|
|
82
|
+
class="longform-gallery__images__image__container"
|
|
83
|
+
data-testid="longform-gallery__images__image__container"
|
|
84
|
+
role="button"
|
|
85
|
+
/>
|
|
86
|
+
</div>
|
|
87
|
+
<div
|
|
88
|
+
class="longform-gallery__images__image secondary-image"
|
|
89
|
+
>
|
|
90
|
+
<div
|
|
91
|
+
class="longform-gallery__images__image__container"
|
|
92
|
+
data-testid="longform-gallery__images__image__container"
|
|
93
|
+
role="button"
|
|
94
|
+
/>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
</DocumentFragment>
|
|
99
|
+
`;
|
package/tests/unit/src/variants/LongFormGallery/__snapshots__/LongformGalleryImage.test.js.snap
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`LongformGalleryImage component renders LongformGalleryImage component 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="longform-gallery__images__image main-image"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
class="longform-gallery__images__image__container"
|
|
10
|
+
data-testid="longform-gallery__images__image__container"
|
|
11
|
+
role="button"
|
|
12
|
+
>
|
|
13
|
+
<img
|
|
14
|
+
alt=""
|
|
15
|
+
role="button"
|
|
16
|
+
src="https://mock-url/image-id-1.jpg"
|
|
17
|
+
/>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</DocumentFragment>
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
exports[`LongformGalleryImage component renders LongformGalleryImage component 2`] = `
|
|
24
|
+
<DocumentFragment>
|
|
25
|
+
<div
|
|
26
|
+
class="longform-gallery__images__image main-image"
|
|
27
|
+
>
|
|
28
|
+
<div
|
|
29
|
+
class="longform-gallery__images__image__container"
|
|
30
|
+
data-testid="longform-gallery__images__image__container"
|
|
31
|
+
role="button"
|
|
32
|
+
>
|
|
33
|
+
<img
|
|
34
|
+
alt=""
|
|
35
|
+
role="button"
|
|
36
|
+
src="https://mock-url/image-id-1.jpg"
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
<div
|
|
40
|
+
class="longform-gallery__images__image__details"
|
|
41
|
+
data-testid="longform-gallery__images__image__details"
|
|
42
|
+
>
|
|
43
|
+
<div
|
|
44
|
+
class="longform-gallery__images__image__details__caption"
|
|
45
|
+
>
|
|
46
|
+
some image caption
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
</DocumentFragment>
|
|
51
|
+
`;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { GET_IMAGES_QUERY } from '../../../../../src/variants/LongformGallery/constants';
|
|
2
|
+
|
|
3
|
+
const IMAGE_MOCKS = [
|
|
4
|
+
{
|
|
5
|
+
request: {
|
|
6
|
+
query: GET_IMAGES_QUERY,
|
|
7
|
+
variables: { where: { id: { _in: ['1', '2', '3'] } } }
|
|
8
|
+
},
|
|
9
|
+
result: {
|
|
10
|
+
data: {
|
|
11
|
+
getImages: [
|
|
12
|
+
{ id: '1', url: 'image1.jpg', caption: 'Caption 1', data: {} },
|
|
13
|
+
{ id: '2', url: 'image2.jpg', caption: 'Caption 2', data: {} },
|
|
14
|
+
{ id: '3', url: 'image3.jpg', caption: 'Caption 3', data: {} }
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
request: {
|
|
21
|
+
query: GET_IMAGES_QUERY,
|
|
22
|
+
variables: { where: { id: { _in: ['1', '2', '3', '4'] } } }
|
|
23
|
+
},
|
|
24
|
+
result: {
|
|
25
|
+
data: {
|
|
26
|
+
getImages: [
|
|
27
|
+
{ id: '1', url: 'image1.jpg', caption: 'Caption 1', data: {} },
|
|
28
|
+
{ id: '2', url: 'image2.jpg', caption: 'Caption 2', data: {} },
|
|
29
|
+
{ id: '3', url: 'image3.jpg', caption: 'Caption 3', data: {} },
|
|
30
|
+
{ id: '4', url: 'image4.jpg', caption: 'Caption 4', data: {} }
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
export { IMAGE_MOCKS };
|
|
@@ -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
|
+
});
|