@@ -20,7 +20,7 @@ define([
2020 } ,
2121 defaultContext = require . s . contexts . _ ,
2222 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 ] ,
23+ menuItem = $ ( '<li class="level0"><a href="http://localhost.com/cat1.html">Cat1</a></li>' ) [ 0 ] ,
2424
2525 /**
2626 * Create context object.
@@ -107,14 +107,14 @@ define([
107107 } ) ;
108108
109109 it ( 'Check _getCategoryCrumb call' , function ( ) {
110- var item = $ ( '<a href="http://localhost.com/cat1.html" id="ui-id-3" >Cat1</a>' ) ;
110+ var item = $ ( '<a href="http://localhost.com/cat1.html">Cat1</a>' ) ;
111111
112112 expect ( widget ) . toBeDefined ( ) ;
113113 expect ( widget ) . toEqual ( jasmine . any ( Function ) ) ;
114114 expect ( widget . prototype . _getCategoryCrumb ) . toBeDefined ( ) ;
115115 expect ( widget . prototype . _getCategoryCrumb ( item ) ) . toEqual ( jasmine . objectContaining (
116116 {
117- 'name' : 'category3 ' ,
117+ 'name' : 'category ' ,
118118 'label' : 'Cat1' ,
119119 'link' : 'http://localhost.com/cat1.html'
120120 }
@@ -223,7 +223,7 @@ define([
223223 expect ( result . length ) . toBe ( 1 ) ;
224224 expect ( result [ 0 ] ) . toEqual ( jasmine . objectContaining (
225225 {
226- 'name' : 'category3 ' ,
226+ 'name' : 'category ' ,
227227 'label' : 'Cat1' ,
228228 'link' : 'http://localhost.com/cat1.html'
229229 }
@@ -234,10 +234,10 @@ define([
234234 var result ,
235235 menuItems = $ (
236236 '<li class="level0 nav-1">' +
237- '<a href="http://localhost.com/cat1.html" id="ui-id-3" >cat1</a>' +
237+ '<a href="http://localhost.com/cat1.html">cat1</a>' +
238238 '<ul>' +
239239 '<li class="level1 nav-1-1">' +
240- '<a href="http://localhost.com/cat1/cat21.html" id="ui-id-9" >cat21</a>' +
240+ '<a href="http://localhost.com/cat1/cat21.html">cat21</a>' +
241241 '</li>' +
242242 '</ul>' +
243243 '</li>'
@@ -253,59 +253,17 @@ define([
253253
254254 context = createContext ( widget . prototype ) ;
255255 getParentMenuHandler = widget . prototype . _getParentMenuItem . bind ( context ) ;
256- result = getParentMenuHandler ( $ ( '#ui-id-9 ' ) ) ;
256+ result = getParentMenuHandler ( $ ( '[href="http://localhost.com/cat1/cat21.html"] ' ) ) ;
257257
258258 expect ( result ) . toBeDefined ( ) ;
259259 expect ( result . length ) . toBe ( 1 ) ;
260260 expect ( result [ 0 ] . tagName . toLowerCase ( ) ) . toEqual ( 'a' ) ;
261- expect ( result . attr ( 'id ' ) ) . toEqual ( 'ui-id-3 ' ) ;
261+ expect ( result . attr ( 'href ' ) ) . toEqual ( 'http://localhost.com/cat1.html ' ) ;
262262
263- result = getParentMenuHandler ( $ ( '#ui-id-3 ' ) ) ;
263+ result = getParentMenuHandler ( $ ( '[href="http://localhost.com/cat1.html"] ' ) ) ;
264264
265265 expect ( result ) . toBeNull ( ) ;
266266 } ) ;
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- } ) ;
309267 } ) ;
310268 } ) ;
311269} ) ;
0 commit comments