Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,6 @@ define([
menuContainer: '[data-action="navigation"] > ul'
},

/** @inheritdoc */
_init: function () {
var menu,
originalInit = this._super.bind(this);

// render breadcrumbs after navigation menu is loaded.
menu = $(this.options.menuContainer).data('mageMenu');

if (typeof menu === 'undefined') {
$(this.options.menuContainer).on('menucreate', function () {
originalInit();
});
} else {
this._super();
}
},

/** @inheritdoc */
_render: function () {
this._appendCatalogCrumbs();
Expand Down Expand Up @@ -89,14 +72,10 @@ define([
* @private
*/
_getCategoryCrumb: function (menuItem) {
var categoryId = /(\d+)/i.exec(menuItem.attr('id'))[0],
categoryName = menuItem.text(),
categoryUrl = menuItem.attr('href');

return {
'name': 'category' + categoryId,
'label': categoryName,
'link': categoryUrl,
'name': 'category',
'label': menuItem.text(),
'link': menuItem.attr('href'),
'title': ''
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ define([
defaultContext = require.s.contexts._,
menuItem = $(
'<li class="level0 category-item">' +
'<a href="http://localhost.com/cat1.html" id="ui-id-3">Cat1</a>' +
'<a href="http://localhost.com/cat1.html">Cat1</a>' +
'</li>'
)[0],

Expand Down Expand Up @@ -116,14 +116,14 @@ define([
});

it('Check _getCategoryCrumb call', function () {
var item = $('<a href="http://localhost.com/cat1.html" id="ui-id-3">Cat1</a>');
var item = $('<a href="http://localhost.com/cat1.html">Cat1</a>');

expect(widget).toBeDefined();
expect(widget).toEqual(jasmine.any(Function));
expect(widget.prototype._getCategoryCrumb).toBeDefined();
expect(widget.prototype._getCategoryCrumb(item)).toEqual(jasmine.objectContaining(
{
'name': 'category3',
'name': 'category',
'label': 'Cat1',
'link': 'http://localhost.com/cat1.html'
}
Expand Down Expand Up @@ -232,7 +232,7 @@ define([
expect(result.length).toBe(1);
expect(result[0]).toEqual(jasmine.objectContaining(
{
'name': 'category3',
'name': 'category',
'label': 'Cat1',
'link': 'http://localhost.com/cat1.html'
}
Expand All @@ -243,10 +243,10 @@ define([
var result,
menuItems = $(
'<li class="level0 nav-1">' +
'<a href="http://localhost.com/cat1.html" id="ui-id-3">cat1</a>' +
'<a href="http://localhost.com/cat1.html">cat1</a>' +
'<ul>' +
'<li class="level1 nav-1-1">' +
'<a href="http://localhost.com/cat1/cat21.html" id="ui-id-9">cat21</a>' +
'<a href="http://localhost.com/cat1/cat21.html">cat21</a>' +
'</li>' +
'</ul>' +
'</li>'
Expand All @@ -262,14 +262,14 @@ define([

context = createContext(widget.prototype);
getParentMenuHandler = widget.prototype._getParentMenuItem.bind(context);
result = getParentMenuHandler($('#ui-id-9'));
result = getParentMenuHandler($('[href="http://localhost.com/cat1/cat21.html"]'));

expect(result).toBeDefined();
expect(result.length).toBe(1);
expect(result[0].tagName.toLowerCase()).toEqual('a');
expect(result.attr('id')).toEqual('ui-id-3');
expect(result.attr('href')).toEqual('http://localhost.com/cat1.html');

result = getParentMenuHandler($('#ui-id-3'));
result = getParentMenuHandler($('[href="http://localhost.com/cat1.html"]'));

expect(result).toBeNull();
});
Expand Down