8
8
] , function ( clickEventBinderInitializerWidget , $ ) {
9
9
'use strict' ;
10
10
11
- var $el ,
12
- originalRedirectTo = clickEventBinderInitializerWidget . redirectTo ;
11
+ var $el ;
13
12
14
13
afterEach ( function ( ) {
15
14
if ( $el !== undefined ) {
@@ -18,9 +17,8 @@ define([
18
17
} ) ;
19
18
20
19
describe ( 'Magento_PageBuilder/js/widget/click-event-binder' , function ( ) {
21
- it ( 'Should not navigate away from page if it is missing href attribute' , function ( ) {
20
+ it ( 'Should not navigate away from page if it is missing data- href attribute' , function ( ) {
22
21
spyOn ( clickEventBinderInitializerWidget , 'redirectTo' ) ;
23
- spyOn ( window , 'open' ) ;
24
22
25
23
$el = $ (
26
24
'<div data-role="content-type">' +
@@ -38,12 +36,10 @@ define([
38
36
$el . find ( '.span-outside-inner-anchor' ) . click ( ) ;
39
37
40
38
expect ( clickEventBinderInitializerWidget . redirectTo ) . not . toHaveBeenCalled ( ) ;
41
- expect ( window . open ) . not . toHaveBeenCalled ( ) ;
42
39
} ) ;
43
40
44
- it ( 'Should not navigate away from page if href is javascript:void(0)' , function ( ) {
41
+ it ( 'Should not navigate away from page if data- href is javascript:void(0)' , function ( ) {
45
42
spyOn ( clickEventBinderInitializerWidget , 'redirectTo' ) ;
46
- spyOn ( window , 'open' ) ;
47
43
48
44
$el = $ (
49
45
'<div data-role="content-type">' +
@@ -61,12 +57,10 @@ define([
61
57
$el . find ( '.span-outside-inner-anchor' ) . click ( ) ;
62
58
63
59
expect ( clickEventBinderInitializerWidget . redirectTo ) . not . toHaveBeenCalled ( ) ;
64
- expect ( window . open ) . not . toHaveBeenCalled ( ) ;
65
60
} ) ;
66
61
67
62
it ( 'Should not navigate away from page if it is missing data-link-type attribute' , function ( ) {
68
63
spyOn ( clickEventBinderInitializerWidget , 'redirectTo' ) ;
69
- spyOn ( window , 'open' ) ;
70
64
71
65
$el = $ (
72
66
'<div data-role="content-type">' +
@@ -84,12 +78,10 @@ define([
84
78
$el . find ( '.span-outside-inner-anchor' ) . click ( ) ;
85
79
86
80
expect ( clickEventBinderInitializerWidget . redirectTo ) . not . toHaveBeenCalled ( ) ;
87
- expect ( window . open ) . not . toHaveBeenCalled ( ) ;
88
81
} ) ;
89
82
90
- it ( 'Should not navigate to simulated anchor\'s href if clicked inside of nested anchor' , function ( ) {
83
+ it ( 'Should not navigate to simulated anchor\'s data- href if clicked inside of nested anchor' , function ( ) {
91
84
spyOn ( clickEventBinderInitializerWidget , 'redirectTo' ) ;
92
- spyOn ( window , 'open' ) ;
93
85
94
86
$el = $ (
95
87
'<div data-role="content-type">' +
@@ -107,12 +99,10 @@ define([
107
99
$el . find ( '.inner-anchor' ) . click ( ) ;
108
100
109
101
expect ( clickEventBinderInitializerWidget . redirectTo ) . not . toHaveBeenCalled ( ) ;
110
- expect ( window . open ) . not . toHaveBeenCalled ( ) ;
111
102
} ) ;
112
103
113
- it ( 'Should navigate to simulated anchor\'s href if clicked outside of nested anchor' , function ( ) {
104
+ it ( 'Should navigate to simulated anchor\'s data- href if clicked outside of nested anchor' , function ( ) {
114
105
spyOn ( clickEventBinderInitializerWidget , 'redirectTo' ) ;
115
- spyOn ( window , 'open' ) ;
116
106
117
107
$el = $ (
118
108
'<div data-role="content-type">' +
@@ -130,13 +120,9 @@ define([
130
120
$el . find ( '.span-outside-inner-anchor' ) . click ( ) ;
131
121
132
122
expect ( clickEventBinderInitializerWidget . redirectTo ) . toHaveBeenCalledWith ( 'https://adobe.com' , '' ) ;
133
-
134
- originalRedirectTo ( 'https://adobe.com' , '' ) ;
135
- expect ( window . open ) . not . toHaveBeenCalled ( ) ;
136
123
} ) ;
137
124
138
- it ( 'Should call window.open if data-target is _blank' , function ( ) {
139
- spyOn ( window , 'open' ) ;
125
+ it ( 'Should call .redirectTo with _blank target if data-target is _blank' , function ( ) {
140
126
spyOn ( clickEventBinderInitializerWidget , 'redirectTo' ) ;
141
127
142
128
$el = $ (
@@ -155,9 +141,6 @@ define([
155
141
$el . find ( '.span-outside-inner-anchor' ) . click ( ) ;
156
142
157
143
expect ( clickEventBinderInitializerWidget . redirectTo ) . toHaveBeenCalledWith ( 'https://adobe.com' , '_blank' ) ;
158
-
159
- originalRedirectTo ( 'https://adobe.com' , '_blank' ) ;
160
- expect ( window . open ) . toHaveBeenCalledWith ( 'https://adobe.com' , '_blank' ) ;
161
144
} ) ;
162
145
} ) ;
163
146
} ) ;
0 commit comments