3
3
* See COPYING.txt for license details.
4
4
*/
5
5
define ( [
6
- 'Magento_PageBuilder/js/widget/bind- click-to-data-link-element ' ,
6
+ 'Magento_PageBuilder/js/widget/click-event-binder ' ,
7
7
'jquery'
8
- ] , function ( bindClickToLinkInitializerWidget , $ ) {
8
+ ] , function ( clickEventBinderInitializerWidget , $ ) {
9
9
'use strict' ;
10
10
11
11
var $el ,
12
- originalRedirectTo = bindClickToLinkInitializerWidget . redirectTo ;
12
+ originalRedirectTo = clickEventBinderInitializerWidget . redirectTo ;
13
13
14
14
afterEach ( function ( ) {
15
15
if ( $el !== undefined ) {
16
16
$el . remove ( ) ;
17
17
}
18
18
} ) ;
19
19
20
- describe ( 'Magento_PageBuilder/js/widget/bind- click-to-data-link-element ' , function ( ) {
20
+ describe ( 'Magento_PageBuilder/js/widget/click-event-binder ' , function ( ) {
21
21
it ( 'Should not navigate away from page if it is missing href attribute' , function ( ) {
22
- spyOn ( bindClickToLinkInitializerWidget , 'redirectTo' ) ;
22
+ spyOn ( clickEventBinderInitializerWidget , 'redirectTo' ) ;
23
23
spyOn ( window , 'open' ) ;
24
24
25
25
$el = $ (
@@ -33,16 +33,16 @@ define([
33
33
34
34
$el . appendTo ( 'body' ) ;
35
35
36
- bindClickToLinkInitializerWidget ( null , $el ) ;
36
+ clickEventBinderInitializerWidget ( null , $el ) ;
37
37
38
38
$el . find ( '.span-outside-inner-anchor' ) . click ( ) ;
39
39
40
- expect ( bindClickToLinkInitializerWidget . redirectTo ) . not . toHaveBeenCalled ( ) ;
40
+ expect ( clickEventBinderInitializerWidget . redirectTo ) . not . toHaveBeenCalled ( ) ;
41
41
expect ( window . open ) . not . toHaveBeenCalled ( ) ;
42
42
} ) ;
43
43
44
44
it ( 'Should not navigate away from page if href is javascript:void(0)' , function ( ) {
45
- spyOn ( bindClickToLinkInitializerWidget , 'redirectTo' ) ;
45
+ spyOn ( clickEventBinderInitializerWidget , 'redirectTo' ) ;
46
46
spyOn ( window , 'open' ) ;
47
47
48
48
$el = $ (
@@ -56,16 +56,16 @@ define([
56
56
57
57
$el . appendTo ( 'body' ) ;
58
58
59
- bindClickToLinkInitializerWidget ( null , $el ) ;
59
+ clickEventBinderInitializerWidget ( null , $el ) ;
60
60
61
61
$el . find ( '.span-outside-inner-anchor' ) . click ( ) ;
62
62
63
- expect ( bindClickToLinkInitializerWidget . redirectTo ) . not . toHaveBeenCalled ( ) ;
63
+ expect ( clickEventBinderInitializerWidget . redirectTo ) . not . toHaveBeenCalled ( ) ;
64
64
expect ( window . open ) . not . toHaveBeenCalled ( ) ;
65
65
} ) ;
66
66
67
67
it ( 'Should not navigate away from page if it is missing data-link-type attribute' , function ( ) {
68
- spyOn ( bindClickToLinkInitializerWidget , 'redirectTo' ) ;
68
+ spyOn ( clickEventBinderInitializerWidget , 'redirectTo' ) ;
69
69
spyOn ( window , 'open' ) ;
70
70
71
71
$el = $ (
@@ -79,16 +79,16 @@ define([
79
79
80
80
$el . appendTo ( 'body' ) ;
81
81
82
- bindClickToLinkInitializerWidget ( null , $el ) ;
82
+ clickEventBinderInitializerWidget ( null , $el ) ;
83
83
84
84
$el . find ( '.span-outside-inner-anchor' ) . click ( ) ;
85
85
86
- expect ( bindClickToLinkInitializerWidget . redirectTo ) . not . toHaveBeenCalled ( ) ;
86
+ expect ( clickEventBinderInitializerWidget . redirectTo ) . not . toHaveBeenCalled ( ) ;
87
87
expect ( window . open ) . not . toHaveBeenCalled ( ) ;
88
88
} ) ;
89
89
90
90
it ( 'Should not navigate to simulated anchor\'s href if clicked inside of nested anchor' , function ( ) {
91
- spyOn ( bindClickToLinkInitializerWidget , 'redirectTo' ) ;
91
+ spyOn ( clickEventBinderInitializerWidget , 'redirectTo' ) ;
92
92
spyOn ( window , 'open' ) ;
93
93
94
94
$el = $ (
@@ -102,16 +102,16 @@ define([
102
102
103
103
$el . appendTo ( 'body' ) ;
104
104
105
- bindClickToLinkInitializerWidget ( null , $el ) ;
105
+ clickEventBinderInitializerWidget ( null , $el ) ;
106
106
107
107
$el . find ( '.inner-anchor' ) . click ( ) ;
108
108
109
- expect ( bindClickToLinkInitializerWidget . redirectTo ) . not . toHaveBeenCalled ( ) ;
109
+ expect ( clickEventBinderInitializerWidget . redirectTo ) . not . toHaveBeenCalled ( ) ;
110
110
expect ( window . open ) . not . toHaveBeenCalled ( ) ;
111
111
} ) ;
112
112
113
113
it ( 'Should navigate to simulated anchor\'s href if clicked outside of nested anchor' , function ( ) {
114
- spyOn ( bindClickToLinkInitializerWidget , 'redirectTo' ) ;
114
+ spyOn ( clickEventBinderInitializerWidget , 'redirectTo' ) ;
115
115
spyOn ( window , 'open' ) ;
116
116
117
117
$el = $ (
@@ -125,19 +125,19 @@ define([
125
125
126
126
$el . appendTo ( 'body' ) ;
127
127
128
- bindClickToLinkInitializerWidget ( null , $el ) ;
128
+ clickEventBinderInitializerWidget ( null , $el ) ;
129
129
130
130
$el . find ( '.span-outside-inner-anchor' ) . click ( ) ;
131
131
132
- expect ( bindClickToLinkInitializerWidget . redirectTo ) . toHaveBeenCalledWith ( 'https://adobe.com' , '' ) ;
132
+ expect ( clickEventBinderInitializerWidget . redirectTo ) . toHaveBeenCalledWith ( 'https://adobe.com' , '' ) ;
133
133
134
134
originalRedirectTo ( 'https://adobe.com' , '' ) ;
135
135
expect ( window . open ) . not . toHaveBeenCalled ( ) ;
136
136
} ) ;
137
137
138
138
it ( 'Should call window.open if target is _blank' , function ( ) {
139
139
spyOn ( window , 'open' ) ;
140
- spyOn ( bindClickToLinkInitializerWidget , 'redirectTo' ) ;
140
+ spyOn ( clickEventBinderInitializerWidget , 'redirectTo' ) ;
141
141
142
142
$el = $ (
143
143
'<div data-role="content-type">' +
@@ -150,11 +150,11 @@ define([
150
150
151
151
$el . appendTo ( 'body' ) ;
152
152
153
- bindClickToLinkInitializerWidget ( null , $el ) ;
153
+ clickEventBinderInitializerWidget ( null , $el ) ;
154
154
155
155
$el . find ( '.span-outside-inner-anchor' ) . click ( ) ;
156
156
157
- expect ( bindClickToLinkInitializerWidget . redirectTo ) . toHaveBeenCalledWith ( 'https://adobe.com' , '_blank' ) ;
157
+ expect ( clickEventBinderInitializerWidget . redirectTo ) . toHaveBeenCalledWith ( 'https://adobe.com' , '_blank' ) ;
158
158
159
159
originalRedirectTo ( 'https://adobe.com' , '_blank' ) ;
160
160
expect ( window . open ) . toHaveBeenCalledWith ( 'https://adobe.com' , '_blank' ) ;
0 commit comments