Skip to content

Commit f89ebab

Browse files
committed
PB-95: Video background for Row
1 parent 5bbe897 commit f89ebab

File tree

1 file changed

+65
-6
lines changed
  • dev/tests/js/jasmine/tests/app/code/Magento/PageBuilder/view/frontend/web/js/content-type/row/appearance/default

1 file changed

+65
-6
lines changed

dev/tests/js/jasmine/tests/app/code/Magento/PageBuilder/view/frontend/web/js/content-type/row/appearance/default/widget.test.js

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,26 @@ define([
88
'use strict';
99

1010
describe('Magento_PageBuilder/js/content-type/row/appearance/default/widget', function () {
11-
it('Should call not call jarallax if enableParallax !== 1', function () {
11+
it('Should not call jarallax if enableParallax !== 1 and image background', function () {
1212
var el = document.createElement('div');
1313

1414
spyOn(window, 'jarallax');
1515

16-
el.setAttribute('data-enable-parallax', 0);
16+
el.setAttribute('data-enable-parallax', '0');
17+
el.setAttribute('data-background-type', 'image');
1718

1819
rowWidgetInitializer(undefined, el);
1920

2021
expect(window.jarallax).not.toHaveBeenCalled();
2122
});
2223

23-
it('Should call call jarallax if enableParallax === 1', function () {
24+
it('Should call call jarallax if enableParallax === 1 and image background', function () {
2425
var el = document.createElement('div');
2526

2627
spyOn(window, 'jarallax');
2728

28-
el.setAttribute('data-enable-parallax', 1);
29+
el.setAttribute('data-enable-parallax', '1');
30+
el.setAttribute('data-background-type', 'image');
2931

3032
rowWidgetInitializer(undefined, el);
3133

@@ -37,12 +39,13 @@ define([
3739

3840
spyOn(window, 'jarallax');
3941

40-
el.setAttribute('data-enable-parallax', 1);
42+
el.setAttribute('data-enable-parallax', '1');
43+
el.setAttribute('data-background-type', 'image');
4144

4245
el.style.backgroundPosition = '0px 50%';
4346
el.style.backgroundRepeat = 'repeat';
4447
el.style.backgroundSize = '100%';
45-
el.setAttribute('data-parallax-speed', 1);
48+
el.setAttribute('data-parallax-speed', '1');
4649

4750
rowWidgetInitializer(undefined, el);
4851

@@ -53,5 +56,61 @@ define([
5356
speed: 1
5457
});
5558
});
59+
60+
it('Should call jarallax if video background and enableParallax === 1', function () {
61+
var el = document.createElement('div');
62+
63+
spyOn(window, 'jarallax');
64+
65+
el.setAttribute('data-enable-parallax', '1');
66+
el.setAttribute('data-background-type', 'video');
67+
68+
rowWidgetInitializer(undefined, el);
69+
70+
expect(window.jarallax).toHaveBeenCalled();
71+
});
72+
73+
it('Should call jarallax if video background and parallax not enabled with speed = 1', function () {
74+
var el = document.createElement('div');
75+
76+
spyOn(window, 'jarallax');
77+
78+
el.setAttribute('data-enable-parallax', '0');
79+
el.setAttribute('data-background-type', 'video');
80+
81+
rowWidgetInitializer(undefined, el);
82+
83+
expect(window.jarallax).toHaveBeenCalledWith(el, {
84+
speed: 1,
85+
imgSrc: undefined,
86+
videoLoop: undefined,
87+
videoPlayOnlyVisible: undefined,
88+
disableVideo: false
89+
});
90+
});
91+
92+
it('Should call jarallax on element based on its data if video background', function () {
93+
var el = document.createElement('div');
94+
95+
spyOn(window, 'jarallax');
96+
97+
el.setAttribute('data-enable-parallax', '1');
98+
el.setAttribute('data-background-type', 'video');
99+
el.setAttribute('data-enable-parallax', '1');
100+
el.setAttribute('data-video-fallback-src', '/image/test.jpg');
101+
el.setAttribute('data-video-loop', 'true');
102+
el.setAttribute('data-video-play-only-visible', 'false');
103+
el.setAttribute('data-parallax-speed', '0.3');
104+
105+
rowWidgetInitializer(undefined, el);
106+
107+
expect(window.jarallax).toHaveBeenCalledWith(el, {
108+
speed: 0.3,
109+
imgSrc: '/image/test.jpg',
110+
videoLoop: true,
111+
videoPlayOnlyVisible: false,
112+
disableVideo: false
113+
});
114+
});
56115
});
57116
});

0 commit comments

Comments
 (0)