Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 91300ec

Browse files
tomaszgrabowskiTomasz GrabowskiSplaktar
authored
fix(nav-bar): add test for handling when a nav item's controller isn't found (#11964)
* add unit test * add missing JSDoc Co-authored-by: Tomasz Grabowski <[email protected]> Co-authored-by: Michael Prentice <[email protected]>
1 parent 579a327 commit 91300ec

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/components/navBar/navBar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ MdNavBarController.prototype.getFocusedTab = function() {
328328
* Find a tab that matches the specified function, starting from the first tab.
329329
* @param {Function} fn
330330
* @param {number=} startIndex index to start at. Defaults to 0.
331-
* @returns {MdNavItemController}
331+
* @returns {MdNavItemController|null}
332332
* @private
333333
*/
334334
MdNavBarController.prototype._findTab = function(fn, startIndex) {

src/components/navBar/navBar.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,17 @@ describe('mdNavBar', function() {
254254
expect(ctrl._updateInkBarStyles)
255255
.not.toHaveBeenCalled();
256256
});
257+
258+
it('does not update selected tab if controller is undefined', function() {
259+
$scope.selectedTabRoute = 'tab1';
260+
261+
spyOn(Object.getPrototypeOf(ctrl), '_updateInkBarStyles');
262+
spyOn(Object.getPrototypeOf(ctrl), '_findTab').and.returnValue(null);
263+
createTabs();
264+
265+
expect(ctrl._updateInkBarStyles)
266+
.toHaveBeenCalledWith(null, -1);
267+
});
257268
});
258269

259270
describe('inkbar', function() {

0 commit comments

Comments
 (0)