@@ -17,7 +17,7 @@ define([
17
17
} ) ;
18
18
19
19
describe ( 'Magento_PageBuilder/js/widget/show-on-hover' , function ( ) {
20
- it ( 'Should call hover twice if both data attributes match config value' , function ( ) {
20
+ it ( 'Should call "on" four times if both data attributes match config value' , function ( ) {
21
21
var config = {
22
22
dataRole : 'thing' ,
23
23
buttonSelector : '.button-selector' ,
@@ -37,14 +37,16 @@ define([
37
37
38
38
el . appendTo ( 'body' ) ;
39
39
40
- spyOn ( $ . fn , 'hover ' ) ;
40
+ spyOn ( $ . fn , 'on ' ) ;
41
41
42
42
showOnHoverInitializerWidget ( config ) ;
43
43
44
- expect ( $ . fn . hover ) . toHaveBeenCalledTimes ( 2 ) ;
44
+ expect ( $ . fn . on ) . toHaveBeenCalledWith ( 'mouseenter' , jasmine . any ( Function ) ) ;
45
+ expect ( $ . fn . on ) . toHaveBeenCalledWith ( 'mouseleave' , jasmine . any ( Function ) ) ;
46
+ expect ( $ . fn . on ) . toHaveBeenCalledTimes ( 4 ) ;
45
47
} ) ;
46
48
47
- it ( 'Should call hover zero times if no data attributes match config value' , function ( ) {
49
+ it ( 'Should call "on" zero times if no data attributes match config value' , function ( ) {
48
50
var config = {
49
51
dataRole : 'thing' ,
50
52
buttonSelector : '.button-selector' ,
@@ -64,14 +66,15 @@ define([
64
66
65
67
el . appendTo ( 'body' ) ;
66
68
67
- spyOn ( $ . fn , 'hover ' ) ;
69
+ spyOn ( $ . fn , 'on ' ) ;
68
70
69
71
showOnHoverInitializerWidget ( config ) ;
70
72
71
- expect ( $ . fn . hover ) . not . toHaveBeenCalled ( ) ;
73
+ expect ( $ . fn . on ) . not . toHaveBeenCalledWith ( 'mouseenter' , jasmine . any ( Function ) ) ;
74
+ expect ( $ . fn . on ) . not . toHaveBeenCalledWith ( 'mouseleave' , jasmine . any ( Function ) ) ;
72
75
} ) ;
73
76
74
- it ( 'Should call hover one time if only data-show-overlay matches config value' , function ( ) {
77
+ it ( 'Should call "on" twice if only data-show-overlay matches config value' , function ( ) {
75
78
var config = {
76
79
dataRole : 'thing' ,
77
80
buttonSelector : '.button-selector' ,
@@ -91,14 +94,16 @@ define([
91
94
92
95
el . appendTo ( 'body' ) ;
93
96
94
- spyOn ( $ . fn , 'hover ' ) ;
97
+ spyOn ( $ . fn , 'on ' ) ;
95
98
96
99
showOnHoverInitializerWidget ( config ) ;
97
100
98
- expect ( $ . fn . hover ) . toHaveBeenCalledTimes ( 1 ) ;
101
+ expect ( $ . fn . on ) . toHaveBeenCalledWith ( 'mouseenter' , jasmine . any ( Function ) ) ;
102
+ expect ( $ . fn . on ) . toHaveBeenCalledWith ( 'mouseleave' , jasmine . any ( Function ) ) ;
103
+ expect ( $ . fn . on ) . toHaveBeenCalledTimes ( 2 ) ;
99
104
} ) ;
100
105
101
- it ( 'Should call hover one time if only data-show-button matches config value' , function ( ) {
106
+ it ( 'Should call "on" twice if only data-show-button matches config value' , function ( ) {
102
107
var config = {
103
108
dataRole : 'thing' ,
104
109
buttonSelector : '.button-selector' ,
@@ -118,14 +123,16 @@ define([
118
123
119
124
el . appendTo ( 'body' ) ;
120
125
121
- spyOn ( $ . fn , 'hover ' ) ;
126
+ spyOn ( $ . fn , 'on ' ) ;
122
127
123
128
showOnHoverInitializerWidget ( config ) ;
124
129
125
- expect ( $ . fn . hover ) . toHaveBeenCalledTimes ( 1 ) ;
130
+ expect ( $ . fn . on ) . toHaveBeenCalledWith ( 'mouseenter' , jasmine . any ( Function ) ) ;
131
+ expect ( $ . fn . on ) . toHaveBeenCalledWith ( 'mouseleave' , jasmine . any ( Function ) ) ;
132
+ expect ( $ . fn . on ) . toHaveBeenCalledTimes ( 2 ) ;
126
133
} ) ;
127
134
128
- it ( 'Should call hover zero times if data-content-type does not match config value' , function ( ) {
135
+ it ( 'Should call "on" zero times if data-content-type does not match config value' , function ( ) {
129
136
var config = {
130
137
dataRole : 'thing2' ,
131
138
buttonSelector : '.button-selector' ,
@@ -145,11 +152,12 @@ define([
145
152
146
153
el . appendTo ( 'body' ) ;
147
154
148
- spyOn ( $ . fn , 'hover ' ) ;
155
+ spyOn ( $ . fn , 'on ' ) ;
149
156
150
157
showOnHoverInitializerWidget ( config ) ;
151
158
152
- expect ( $ . fn . hover ) . not . toHaveBeenCalled ( ) ;
159
+ expect ( $ . fn . on ) . not . toHaveBeenCalledWith ( 'mouseenter' , jasmine . any ( Function ) ) ;
160
+ expect ( $ . fn . on ) . not . toHaveBeenCalledWith ( 'mouseleave' , jasmine . any ( Function ) ) ;
153
161
} ) ;
154
162
} ) ;
155
163
} ) ;
0 commit comments