@@ -8,24 +8,26 @@ define([
8
8
'use strict' ;
9
9
10
10
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 ( ) {
12
12
var el = document . createElement ( 'div' ) ;
13
13
14
14
spyOn ( window , 'jarallax' ) ;
15
15
16
- el . setAttribute ( 'data-enable-parallax' , 0 ) ;
16
+ el . setAttribute ( 'data-enable-parallax' , '0' ) ;
17
+ el . setAttribute ( 'data-background-type' , 'image' ) ;
17
18
18
19
rowWidgetInitializer ( undefined , el ) ;
19
20
20
21
expect ( window . jarallax ) . not . toHaveBeenCalled ( ) ;
21
22
} ) ;
22
23
23
- it ( 'Should call call jarallax if enableParallax === 1' , function ( ) {
24
+ it ( 'Should call call jarallax if enableParallax === 1 and image background ' , function ( ) {
24
25
var el = document . createElement ( 'div' ) ;
25
26
26
27
spyOn ( window , 'jarallax' ) ;
27
28
28
- el . setAttribute ( 'data-enable-parallax' , 1 ) ;
29
+ el . setAttribute ( 'data-enable-parallax' , '1' ) ;
30
+ el . setAttribute ( 'data-background-type' , 'image' ) ;
29
31
30
32
rowWidgetInitializer ( undefined , el ) ;
31
33
@@ -37,12 +39,13 @@ define([
37
39
38
40
spyOn ( window , 'jarallax' ) ;
39
41
40
- el . setAttribute ( 'data-enable-parallax' , 1 ) ;
42
+ el . setAttribute ( 'data-enable-parallax' , '1' ) ;
43
+ el . setAttribute ( 'data-background-type' , 'image' ) ;
41
44
42
45
el . style . backgroundPosition = '0px 50%' ;
43
46
el . style . backgroundRepeat = 'repeat' ;
44
47
el . style . backgroundSize = '100%' ;
45
- el . setAttribute ( 'data-parallax-speed' , 1 ) ;
48
+ el . setAttribute ( 'data-parallax-speed' , '1' ) ;
46
49
47
50
rowWidgetInitializer ( undefined , el ) ;
48
51
@@ -53,5 +56,61 @@ define([
53
56
speed : 1
54
57
} ) ;
55
58
} ) ;
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
+ } ) ;
56
115
} ) ;
57
116
} ) ;
0 commit comments