Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: angular/angular-cli
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 90315fbfcd2a2e5bedffa2c61806453f4e3ae62f
Choose a base ref
..
head repository: angular/angular-cli
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0ea756fb34c5b3d4911136171df00cd107b8da5e
Choose a head ref
Showing with 36 additions and 2 deletions.
  1. +2 −2 addon/ng2/utilities/route-utils.ts
  2. +34 −0 tests/acceptance/route-utils.spec.ts
4 changes: 2 additions & 2 deletions addon/ng2/utilities/route-utils.ts
Original file line number Diff line number Diff line change
@@ -408,8 +408,8 @@ function pathExists(routesArray: ts.Node[], route: string, component: string,
&& componentNode.getChildAt(2).text === component;
sameRoute = currentRoute === splitRoute[0];
// Confirm that it's parents are the same
parentRoute['parentRoute'] = parentRoute['parentRoute'] += currentRoute

let sep = parentRoute['parentRoute'].length !== 0 ? '/' : '';
parentRoute['parentRoute'] = parentRoute['parentRoute'] += `${sep}${currentRoute}`;
return sameRoute && sameComponent // match entire route to count as repeated
&& parentRoute['fullRoute'] === parentRoute['parentRoute'];
});
34 changes: 34 additions & 0 deletions tests/acceptance/route-utils.spec.ts
Original file line number Diff line number Diff line change
@@ -414,6 +414,40 @@ export default [
expect(content).to.equal(expected);
});
});
it('does not report false repeat: multiple paths on a level', () => {

let routes = `\n { path: 'home', component: HomeComponent,
children: [
{ path: 'about', component: AboutComponent,
children: [
{ path: 'more', component: MoreComponent }
]
}
]
},\n { path: 'trap-queen', component: TrapQueenComponent}\n`;

let editedFile = new InsertChange(routesFile, 16, routes);
return editedFile.apply().then(() => {
options.dasherizedName = 'trap-queen';
options.component = 'TrapQueenComponent';
return nru.applyChanges(
nru.addPathToRoutes(routesFile, _.merge({route: 'home/trap-queen'}, options))); })
.then(() => readFile(routesFile, 'utf8')
.then(content => {
let expected = `import { TrapQueenComponent } from './app/+home/+trap-queen/trap-queen.component';
export default [
{ path: 'home', component: HomeComponent,
children: [
{ path: 'trap-queen', component: TrapQueenComponent },
{ path: 'about', component: AboutComponent,
children: [
{ path: 'more', component: MoreComponent }
]
}
]
},\n { path: 'trap-queen', component: TrapQueenComponent}\n];`;
expect(content).to.equal(expected);
});
});

describe('validators', () => {