Skip to content

Commit cb4a9a3

Browse files
committed
refactor(router): use CamelCase aliases for routes
1 parent 97d1844 commit cb4a9a3

File tree

11 files changed

+98
-98
lines changed

11 files changed

+98
-98
lines changed

modules/angular1_router/test/ng_link_spec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ describe('ngOutlet', function () {
3838

3939
$router.config([
4040
{ path: '/a', component: OneController },
41-
{ path: '/b', component: TwoController, as: 'two' }
41+
{ path: '/b', component: TwoController, as: 'Two' }
4242
]);
43-
compile('<a ng-link="[\'/two\']">link</a> | outer { <div ng-outlet></div> }');
43+
compile('<a ng-link="[\'/Two\']">link</a> | outer { <div ng-outlet></div> }');
4444

4545
$router.navigateByUrl('/a');
4646
$rootScope.$digest();
@@ -49,11 +49,11 @@ describe('ngOutlet', function () {
4949
});
5050

5151
it('should allow linking from the child and the parent', function () {
52-
put('one', '<div><a ng-link="[\'/two\']">{{number}}</a></div>');
52+
put('one', '<div><a ng-link="[\'/Two\']">{{number}}</a></div>');
5353

5454
$router.config([
5555
{ path: '/a', component: OneController },
56-
{ path: '/b', component: TwoController, as: 'two' }
56+
{ path: '/b', component: TwoController, as: 'Two' }
5757
]);
5858
compile('outer { <div ng-outlet></div> }');
5959

@@ -66,11 +66,11 @@ describe('ngOutlet', function () {
6666

6767
it('should allow params in routerLink directive', function () {
6868
put('router', '<div>outer { <div ng-outlet></div> }</div>');
69-
put('one', '<div><a ng-link="[\'/two\', {param: \'lol\'}]">{{number}}</a></div>');
69+
put('one', '<div><a ng-link="[\'/Two\', {param: \'lol\'}]">{{number}}</a></div>');
7070

7171
$router.config([
7272
{ path: '/a', component: OneController },
73-
{ path: '/b/:param', component: TwoController, as: 'two' }
73+
{ path: '/b/:param', component: TwoController, as: 'Two' }
7474
]);
7575
compile('<div ng-outlet></div>');
7676

@@ -83,11 +83,11 @@ describe('ngOutlet', function () {
8383
// TODO: test dynamic links
8484
it('should update the href of links with bound params', function () {
8585
put('router', '<div>outer { <div ng-outlet></div> }</div>');
86-
put('one', '<div><a ng-link="[\'/two\', {param: one.number}]">{{one.number}}</a></div>');
86+
put('one', '<div><a ng-link="[\'/Two\', {param: one.number}]">{{one.number}}</a></div>');
8787

8888
$router.config([
8989
{ path: '/a', component: OneController },
90-
{ path: '/b/:param', component: TwoController, as: 'two' }
90+
{ path: '/b/:param', component: TwoController, as: 'Two' }
9191
]);
9292
compile('<div ng-outlet></div>');
9393

modules/angular2/test/router/integration/router_link_spec.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ export function main() {
7272
it('should generate absolute hrefs that include the base href',
7373
inject([AsyncTestCompleter], (async) => {
7474
location.setBaseHref('/my/base');
75-
compile('<a href="hello" [router-link]="[\'./user\']"></a>')
75+
compile('<a href="hello" [router-link]="[\'./User\']"></a>')
7676
.then((_) =>
77-
router.config([new Route({path: '/user', component: UserCmp, as: 'user'})]))
77+
router.config([new Route({path: '/user', component: UserCmp, as: 'User'})]))
7878
.then((_) => router.navigateByUrl('/a/b'))
7979
.then((_) => {
8080
rootTC.detectChanges();
@@ -85,9 +85,9 @@ export function main() {
8585

8686

8787
it('should generate link hrefs without params', inject([AsyncTestCompleter], (async) => {
88-
compile('<a href="hello" [router-link]="[\'./user\']"></a>')
88+
compile('<a href="hello" [router-link]="[\'./User\']"></a>')
8989
.then((_) =>
90-
router.config([new Route({path: '/user', component: UserCmp, as: 'user'})]))
90+
router.config([new Route({path: '/user', component: UserCmp, as: 'User'})]))
9191
.then((_) => router.navigateByUrl('/a/b'))
9292
.then((_) => {
9393
rootTC.detectChanges();
@@ -98,9 +98,9 @@ export function main() {
9898

9999

100100
it('should generate link hrefs with params', inject([AsyncTestCompleter], (async) => {
101-
compile('<a href="hello" [router-link]="[\'./user\', {name: name}]">{{name}}</a>')
101+
compile('<a href="hello" [router-link]="[\'./User\', {name: name}]">{{name}}</a>')
102102
.then((_) => router.config(
103-
[new Route({path: '/user/:name', component: UserCmp, as: 'user'})]))
103+
[new Route({path: '/user/:name', component: UserCmp, as: 'User'})]))
104104
.then((_) => router.navigateByUrl('/a/b'))
105105
.then((_) => {
106106
rootTC.debugElement.componentInstance.name = 'brian';
@@ -117,7 +117,7 @@ export function main() {
117117
inject([AsyncTestCompleter], (async) => {
118118
compile()
119119
.then((_) => router.config(
120-
[new Route({path: '/page/:number', component: SiblingPageCmp, as: 'page'})]))
120+
[new Route({path: '/page/:number', component: SiblingPageCmp, as: 'Page'})]))
121121
.then((_) => router.navigateByUrl('/page/1'))
122122
.then((_) => {
123123
rootTC.detectChanges();
@@ -137,10 +137,10 @@ export function main() {
137137
new AsyncRoute({
138138
path: '/child-with-grandchild/...',
139139
loader: parentCmpLoader,
140-
as: 'child-with-grandchild'
140+
as: 'ChildWithGrandchild'
141141
})
142142
]))
143-
.then((_) => router.navigate(['/child-with-grandchild']))
143+
.then((_) => router.navigate(['/ChildWithGrandchild']))
144144
.then((_) => {
145145
rootTC.detectChanges();
146146
expect(DOM.getAttribute(rootTC.debugElement.componentViewChildren[1]
@@ -156,7 +156,7 @@ export function main() {
156156
inject([AsyncTestCompleter], (async) => {
157157
compile()
158158
.then((_) => router.config(
159-
[new Route({path: '/book/:title/...', component: BookCmp, as: 'book'})]))
159+
[new Route({path: '/book/:title/...', component: BookCmp, as: 'Book'})]))
160160
.then((_) => router.navigateByUrl('/book/1984/page/1'))
161161
.then((_) => {
162162
rootTC.detectChanges();
@@ -180,11 +180,11 @@ export function main() {
180180
describe('router-link-active CSS class', () => {
181181
it('should be added to the associated element', inject([AsyncTestCompleter], (async) => {
182182
router.config([
183-
new Route({path: '/child', component: HelloCmp, as: 'child'}),
184-
new Route({path: '/better-child', component: Hello2Cmp, as: 'better-child'})
183+
new Route({path: '/child', component: HelloCmp, as: 'Child'}),
184+
new Route({path: '/better-child', component: Hello2Cmp, as: 'BetterChild'})
185185
])
186-
.then((_) => compile(`<a [router-link]="['./child']" class="child-link">Child</a>
187-
<a [router-link]="['./better-child']" class="better-child-link">Better Child</a>
186+
.then((_) => compile(`<a [router-link]="['./Child']" class="child-link">Child</a>
187+
<a [router-link]="['./BetterChild']" class="better-child-link">Better Child</a>
188188
<router-outlet></router-outlet>`))
189189
.then((_) => {
190190
var element = rootTC.debugElement.nativeElement;
@@ -211,15 +211,15 @@ export function main() {
211211

212212
it('should be added to links in child routes', inject([AsyncTestCompleter], (async) => {
213213
router.config([
214-
new Route({path: '/child', component: HelloCmp, as: 'child'}),
214+
new Route({path: '/child', component: HelloCmp, as: 'Child'}),
215215
new Route({
216216
path: '/child-with-grandchild/...',
217217
component: ParentCmp,
218-
as: 'child-with-grandchild'
218+
as: 'ChildWithGrandchild'
219219
})
220220
])
221-
.then((_) => compile(`<a [router-link]="['./child']" class="child-link">Child</a>
222-
<a [router-link]="['./child-with-grandchild/grandchild']" class="child-with-grandchild-link">Better Child</a>
221+
.then((_) => compile(`<a [router-link]="['./Child']" class="child-link">Child</a>
222+
<a [router-link]="['./ChildWithGrandchild/Grandchild']" class="child-with-grandchild-link">Better Child</a>
223223
<router-outlet></router-outlet>`))
224224
.then((_) => {
225225
var element = rootTC.debugElement.nativeElement;
@@ -261,9 +261,9 @@ export function main() {
261261
};
262262

263263
it('should navigate to link hrefs without params', inject([AsyncTestCompleter], (async) => {
264-
compile('<a href="hello" [router-link]="[\'./user\']"></a>')
264+
compile('<a href="hello" [router-link]="[\'./User\']"></a>')
265265
.then((_) => router.config(
266-
[new Route({path: '/user', component: UserCmp, as: 'user'})]))
266+
[new Route({path: '/user', component: UserCmp, as: 'User'})]))
267267
.then((_) => router.navigateByUrl('/a/b'))
268268
.then((_) => {
269269
rootTC.detectChanges();
@@ -282,9 +282,9 @@ export function main() {
282282
it('should navigate to link hrefs in presence of base href',
283283
inject([AsyncTestCompleter], (async) => {
284284
location.setBaseHref('/base');
285-
compile('<a href="hello" [router-link]="[\'./user\']"></a>')
285+
compile('<a href="hello" [router-link]="[\'./User\']"></a>')
286286
.then((_) => router.config(
287-
[new Route({path: '/user', component: UserCmp, as: 'user'})]))
287+
[new Route({path: '/user', component: UserCmp, as: 'User'})]))
288288
.then((_) => router.navigateByUrl('/a/b'))
289289
.then((_) => {
290290
rootTC.detectChanges();
@@ -322,7 +322,7 @@ class UserCmp {
322322
@Component({selector: 'page-cmp'})
323323
@View({
324324
template:
325-
`page #{{pageNumber}} | <a href="hello" [router-link]="[\'../page\', {number: nextPage}]">next</a>`,
325+
`page #{{pageNumber}} | <a href="hello" [router-link]="[\'../Page\', {number: nextPage}]">next</a>`,
326326
directives: [RouterLink]
327327
})
328328
class SiblingPageCmp {
@@ -350,26 +350,26 @@ function parentCmpLoader() {
350350

351351
@Component({selector: 'parent-cmp'})
352352
@View({
353-
template: `{ <a [router-link]="['./grandchild']" class="grandchild-link">Grandchild</a>
354-
<a [router-link]="['./better-grandchild']" class="better-grandchild-link">Better Grandchild</a>
353+
template: `{ <a [router-link]="['./Grandchild']" class="grandchild-link">Grandchild</a>
354+
<a [router-link]="['./BetterGrandchild']" class="better-grandchild-link">Better Grandchild</a>
355355
<router-outlet></router-outlet> }`,
356356
directives: ROUTER_DIRECTIVES
357357
})
358358
@RouteConfig([
359-
new Route({path: '/grandchild', component: HelloCmp, as: 'grandchild'}),
360-
new Route({path: '/better-grandchild', component: Hello2Cmp, as: 'better-grandchild'})
359+
new Route({path: '/grandchild', component: HelloCmp, as: 'Grandchild'}),
360+
new Route({path: '/better-grandchild', component: Hello2Cmp, as: 'BetterGrandchild'})
361361
])
362362
class ParentCmp {
363363
constructor(public router: Router) {}
364364
}
365365

366366
@Component({selector: 'book-cmp'})
367367
@View({
368-
template: `<a href="hello" [router-link]="[\'./page\', {number: 100}]">{{title}}</a> |
368+
template: `<a href="hello" [router-link]="[\'./Page\', {number: 100}]">{{title}}</a> |
369369
<router-outlet></router-outlet>`,
370370
directives: ROUTER_DIRECTIVES
371371
})
372-
@RouteConfig([new Route({path: '/page/:number', component: SiblingPageCmp, as: 'page'})])
372+
@RouteConfig([new Route({path: '/page/:number', component: SiblingPageCmp, as: 'Page'})])
373373
class BookCmp {
374374
title: string;
375375
constructor(params: RouteParams) { this.title = params.get('title'); }

modules/angular2/test/router/route_recognizer_spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,28 +108,28 @@ export function main() {
108108

109109

110110
it('should generate URLs with params', () => {
111-
recognizer.config(new Route({path: '/app/user/:name', component: DummyCmpA, as: 'user'}));
112-
var instruction = recognizer.generate('user', {'name': 'misko'});
111+
recognizer.config(new Route({path: '/app/user/:name', component: DummyCmpA, as: 'User'}));
112+
var instruction = recognizer.generate('User', {'name': 'misko'});
113113
expect(instruction.urlPath).toEqual('app/user/misko');
114114
});
115115

116116

117117
it('should generate URLs with numeric params', () => {
118-
recognizer.config(new Route({path: '/app/page/:number', component: DummyCmpA, as: 'page'}));
119-
expect(recognizer.generate('page', {'number': 42}).urlPath).toEqual('app/page/42');
118+
recognizer.config(new Route({path: '/app/page/:number', component: DummyCmpA, as: 'Page'}));
119+
expect(recognizer.generate('Page', {'number': 42}).urlPath).toEqual('app/page/42');
120120
});
121121

122122

123123
it('should throw in the absence of required params URLs', () => {
124-
recognizer.config(new Route({path: 'app/user/:name', component: DummyCmpA, as: 'user'}));
125-
expect(() => recognizer.generate('user', {}))
124+
recognizer.config(new Route({path: 'app/user/:name', component: DummyCmpA, as: 'User'}));
125+
expect(() => recognizer.generate('User', {}))
126126
.toThrowError('Route generator for \'name\' was not included in parameters passed.');
127127
});
128128

129129

130130
describe('params', () => {
131131
it('should recognize parameters within the URL path', () => {
132-
recognizer.config(new Route({path: 'profile/:name', component: DummyCmpA, as: 'user'}));
132+
recognizer.config(new Route({path: 'profile/:name', component: DummyCmpA, as: 'User'}));
133133
var solution = recognize(recognizer, '/profile/matsko?comments=all');
134134
expect(solution.params).toEqual({'name': 'matsko', 'comments': 'all'});
135135
});
@@ -138,26 +138,26 @@ export function main() {
138138
it('should generate and populate the given static-based route with querystring params',
139139
() => {
140140
recognizer.config(
141-
new Route({path: 'forum/featured', component: DummyCmpA, as: 'forum-page'}));
141+
new Route({path: 'forum/featured', component: DummyCmpA, as: 'ForumPage'}));
142142

143143
var params = {'start': 10, 'end': 100};
144144

145-
var result = recognizer.generate('forum-page', params);
145+
var result = recognizer.generate('ForumPage', params);
146146
expect(result.urlPath).toEqual('forum/featured');
147147
expect(result.urlParams).toEqual(['start=10', 'end=100']);
148148
});
149149

150150

151151
it('should prefer positional params over query params', () => {
152-
recognizer.config(new Route({path: 'profile/:name', component: DummyCmpA, as: 'user'}));
152+
recognizer.config(new Route({path: 'profile/:name', component: DummyCmpA, as: 'User'}));
153153

154154
var solution = recognize(recognizer, '/profile/yegor?name=igor');
155155
expect(solution.params).toEqual({'name': 'yegor'});
156156
});
157157

158158

159159
it('should ignore matrix params for the top-level component', () => {
160-
recognizer.config(new Route({path: '/home/:subject', component: DummyCmpA, as: 'user'}));
160+
recognizer.config(new Route({path: '/home/:subject', component: DummyCmpA, as: 'User'}));
161161
var solution = recognize(recognizer, '/home;sort=asc/zero;one=1?two=2');
162162
expect(solution.params).toEqual({'subject': 'zero', 'two': '2'});
163163
});

0 commit comments

Comments
 (0)