Skip to content

Commit

Permalink
fix(router): do not add routes with nav=false
Browse files Browse the repository at this point in the history
routes with nav:false were still being included in router.navigation

routes that contain nav:false will no longer be included
  • Loading branch information
kyeotic committed Jan 13, 2015
1 parent db8ddb3 commit 2cda7eb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export class Router {

config.navModel = navModel;

if (('nav' in config || 'order' in navModel) && this.navigation.indexOf(navModel) === -1) {
if ((config.nav || 'order' in navModel) && this.navigation.indexOf(navModel) === -1) {
navModel.order = navModel.order || config.nav;
navModel.href = navModel.href || config.href;
navModel.isActive = false;
Expand Down Expand Up @@ -232,4 +232,4 @@ export class Router {
this.isNavigating = false;
this.navigation = [];
}
}
}
23 changes: 21 additions & 2 deletions test/router.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,28 @@ import {History} from 'aurelia-history';
import {Container} from 'aurelia-dependency-injection';
import {AppRouter, PipelineProvider} from '../src/index';

describe('observer locator', () => {
describe('the router', () => {
it('should have some tests', () => {
var router = new AppRouter(new History(), new PipelineProvider(new Container()));
expect(router).not.toBe(null);
});
});

describe('addRoute', () => {

it('should add a route to navigation if it has a nav=true', () => {
var router = new AppRouter(new History(), new PipelineProvider(new Container())),
testRoute = {};

router.addRoute({ route: 'test', moduleId: 'test', title: 'Resume', nav: true }, testRoute);
expect(router.navigation).toContain(testRoute);
});

it('should not add a route to navigation if it has a nav=false', () => {
var router = new AppRouter(new History(), new PipelineProvider(new Container())),
testRoute = {};

router.addRoute({ route: 'test', moduleId: 'test', title: 'Resume', nav: false }, testRoute);
expect(router.navigation).not.toContain(testRoute);
});
});
});

1 comment on commit 2cda7eb

@martingust
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, was just looking into this issue.

Please sign in to comment.