@@ -13,14 +13,13 @@ define([
13
13
14
14
var injector = new Squire ( ) ,
15
15
widget ,
16
- parentWidget ,
17
16
menuContainer ,
18
17
mocks = {
19
18
'Magento_Theme/js/model/breadcrumb-list' : jasmine . createSpyObj ( [ 'push' ] )
20
19
} ,
21
20
defaultContext = require . s . contexts . _ ,
22
21
menuSelector = '[data-action="navigation"] > ul' ,
23
- menuItem = $ ( '<li class="level0"><a href="http://localhost.com/cat1.html" id="ui-id-3" >Cat1</a></li>' ) [ 0 ] ,
22
+ menuItem = $ ( '<li class="level0"><a href="http://localhost.com/cat1.html">Cat1</a></li>' ) [ 0 ] ,
24
23
25
24
/**
26
25
* Create context object.
@@ -44,7 +43,6 @@ define([
44
43
'Magento_Theme/js/view/breadcrumbs'
45
44
] , function ( mixin , breadcrumb ) {
46
45
widget = mixin ( breadcrumb ) ;
47
- parentWidget = breadcrumb ;
48
46
done ( ) ;
49
47
}
50
48
) ;
@@ -107,14 +105,14 @@ define([
107
105
} ) ;
108
106
109
107
it ( 'Check _getCategoryCrumb call' , function ( ) {
110
- var item = $ ( '<a href="http://localhost.com/cat1.html" id="ui-id-3" >Cat1</a>' ) ;
108
+ var item = $ ( '<a href="http://localhost.com/cat1.html">Cat1</a>' ) ;
111
109
112
110
expect ( widget ) . toBeDefined ( ) ;
113
111
expect ( widget ) . toEqual ( jasmine . any ( Function ) ) ;
114
112
expect ( widget . prototype . _getCategoryCrumb ) . toBeDefined ( ) ;
115
113
expect ( widget . prototype . _getCategoryCrumb ( item ) ) . toEqual ( jasmine . objectContaining (
116
114
{
117
- 'name' : 'category3 ' ,
115
+ 'name' : 'category ' ,
118
116
'label' : 'Cat1' ,
119
117
'link' : 'http://localhost.com/cat1.html'
120
118
}
@@ -223,7 +221,7 @@ define([
223
221
expect ( result . length ) . toBe ( 1 ) ;
224
222
expect ( result [ 0 ] ) . toEqual ( jasmine . objectContaining (
225
223
{
226
- 'name' : 'category3 ' ,
224
+ 'name' : 'category ' ,
227
225
'label' : 'Cat1' ,
228
226
'link' : 'http://localhost.com/cat1.html'
229
227
}
@@ -234,10 +232,10 @@ define([
234
232
var result ,
235
233
menuItems = $ (
236
234
'<li class="level0 nav-1">' +
237
- '<a href="http://localhost.com/cat1.html" id="ui-id-3" >cat1</a>' +
235
+ '<a href="http://localhost.com/cat1.html">cat1</a>' +
238
236
'<ul>' +
239
237
'<li class="level1 nav-1-1">' +
240
- '<a href="http://localhost.com/cat1/cat21.html" id="ui-id-9" >cat21</a>' +
238
+ '<a href="http://localhost.com/cat1/cat21.html">cat21</a>' +
241
239
'</li>' +
242
240
'</ul>' +
243
241
'</li>'
@@ -253,59 +251,17 @@ define([
253
251
254
252
context = createContext ( widget . prototype ) ;
255
253
getParentMenuHandler = widget . prototype . _getParentMenuItem . bind ( context ) ;
256
- result = getParentMenuHandler ( $ ( '#ui-id-9 ' ) ) ;
254
+ result = getParentMenuHandler ( $ ( '[href="http://localhost.com/cat1/cat21.html"] ' ) ) ;
257
255
258
256
expect ( result ) . toBeDefined ( ) ;
259
257
expect ( result . length ) . toBe ( 1 ) ;
260
258
expect ( result [ 0 ] . tagName . toLowerCase ( ) ) . toEqual ( 'a' ) ;
261
- expect ( result . attr ( 'id ' ) ) . toEqual ( 'ui-id-3 ' ) ;
259
+ expect ( result . attr ( 'href ' ) ) . toEqual ( 'http://localhost.com/cat1.html ' ) ;
262
260
263
- result = getParentMenuHandler ( $ ( '#ui-id-3 ' ) ) ;
261
+ result = getParentMenuHandler ( $ ( '[href="http://localhost.com/cat1.html"] ' ) ) ;
264
262
265
263
expect ( result ) . toBeNull ( ) ;
266
264
} ) ;
267
-
268
- it ( 'Check _init event binding' , function ( ) {
269
- var context ,
270
- initMethod ;
271
-
272
- expect ( parentWidget ) . toBeDefined ( ) ;
273
- expect ( parentWidget ) . toEqual ( jasmine . any ( Function ) ) ;
274
-
275
- context = createContext ( widget . prototype ) ;
276
- initMethod = widget . prototype . _init . bind ( context ) ;
277
-
278
- spyOn ( parentWidget . prototype , '_init' ) ;
279
- spyOn ( widget . prototype , '_on' ) . and . returnValue ( widget ) ;
280
-
281
- initMethod ( ) ;
282
-
283
- expect ( parentWidget . prototype . _init ) . not . toHaveBeenCalled ( ) ;
284
- expect ( widget . prototype . _on ) . toHaveBeenCalledWith (
285
- jasmine . objectContaining ( {
286
- selector : menuSelector
287
- } ) ,
288
- {
289
- 'menucreate' : jasmine . any ( Function )
290
- }
291
- ) ;
292
- } ) ;
293
-
294
- it ( 'Check parent _init call' , function ( ) {
295
- var context ,
296
- initMethod ;
297
-
298
- expect ( parentWidget ) . toBeDefined ( ) ;
299
- expect ( parentWidget ) . toEqual ( jasmine . any ( Function ) ) ;
300
-
301
- context = createContext ( widget . prototype ) ;
302
- initMethod = widget . prototype . _init . bind ( context ) ;
303
- spyOn ( parentWidget . prototype , '_init' ) ;
304
-
305
- jQuery ( menuSelector ) . attr ( 'data-mage-menu' , '<li></li>' ) ;
306
- initMethod ( ) ;
307
- expect ( parentWidget . prototype . _init ) . toHaveBeenCalled ( ) ;
308
- } ) ;
309
265
} ) ;
310
266
} ) ;
311
267
} ) ;
0 commit comments