style(lint): re-format modules/@angular
This commit is contained in:
@ -1,15 +1,4 @@
|
||||
import {
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
xdescribe,
|
||||
describe,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
beforeEachProviders,
|
||||
it,
|
||||
xit,
|
||||
} from '@angular/core/testing/testing_internal';
|
||||
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {TestComponentBuilder, ComponentFixture} from '@angular/compiler/testing';
|
||||
|
||||
@ -20,19 +9,7 @@ import {ListWrapper} from '../../src/facade/collection';
|
||||
|
||||
import {provide, Component} from '@angular/core';
|
||||
|
||||
import {
|
||||
Router,
|
||||
RouteRegistry,
|
||||
RouterLink,
|
||||
RouterOutlet,
|
||||
AsyncRoute,
|
||||
AuxRoute,
|
||||
Route,
|
||||
RouteParams,
|
||||
RouteConfig,
|
||||
ROUTER_DIRECTIVES,
|
||||
ROUTER_PRIMARY_COMPONENT
|
||||
} from '@angular/router-deprecated';
|
||||
import {Router, RouteRegistry, RouterLink, RouterOutlet, AsyncRoute, AuxRoute, Route, RouteParams, RouteConfig, ROUTER_DIRECTIVES, ROUTER_PRIMARY_COMPONENT} from '@angular/router-deprecated';
|
||||
import {RootRouter} from '@angular/router-deprecated/src/router';
|
||||
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
@ -46,21 +23,22 @@ export function main() {
|
||||
var router: Router;
|
||||
var location: Location;
|
||||
|
||||
beforeEachProviders(() => [
|
||||
RouteRegistry,
|
||||
{provide: Location, useClass: SpyLocation},
|
||||
{provide: ROUTER_PRIMARY_COMPONENT, useValue: MyComp7},
|
||||
{provide: Router, useClass: RootRouter},
|
||||
beforeEachProviders(
|
||||
() =>
|
||||
[RouteRegistry, {provide: Location, useClass: SpyLocation},
|
||||
{provide: ROUTER_PRIMARY_COMPONENT, useValue: MyComp7},
|
||||
{provide: Router, useClass: RootRouter},
|
||||
]);
|
||||
|
||||
beforeEach(inject([TestComponentBuilder, Router, Location],
|
||||
(tcBuilder: any /** TODO #9100 */, rtr: Router, loc: Location) => {
|
||||
tcb = tcBuilder;
|
||||
router = rtr;
|
||||
location = loc;
|
||||
}));
|
||||
beforeEach(inject(
|
||||
[TestComponentBuilder, Router, Location],
|
||||
(tcBuilder: any /** TODO #9100 */, rtr: Router, loc: Location) => {
|
||||
tcb = tcBuilder;
|
||||
router = rtr;
|
||||
location = loc;
|
||||
}));
|
||||
|
||||
function compile(template: string = "<router-outlet></router-outlet>") {
|
||||
function compile(template: string = '<router-outlet></router-outlet>') {
|
||||
return tcb.overrideTemplate(MyComp7, ('<div>' + template + '</div>'))
|
||||
.createAsync(MyComp7)
|
||||
.then((tc) => { fixture = tc; });
|
||||
@ -70,8 +48,9 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
(<SpyLocation>location).setBaseHref('/my/base');
|
||||
compile('<a href="hello" [routerLink]="[\'./User\']"></a>')
|
||||
.then((_) => router.config(
|
||||
[new Route({path: '/user', component: UserCmp, name: 'User'})]))
|
||||
.then(
|
||||
(_) =>
|
||||
router.config([new Route({path: '/user', component: UserCmp, name: 'User'})]))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
fixture.detectChanges();
|
||||
@ -81,10 +60,12 @@ export function main() {
|
||||
}));
|
||||
|
||||
|
||||
it('should generate link hrefs without params', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
it('should generate link hrefs without params',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile('<a href="hello" [routerLink]="[\'./User\']"></a>')
|
||||
.then((_) => router.config(
|
||||
[new Route({path: '/user', component: UserCmp, name: 'User'})]))
|
||||
.then(
|
||||
(_) =>
|
||||
router.config([new Route({path: '/user', component: UserCmp, name: 'User'})]))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
fixture.detectChanges();
|
||||
@ -94,10 +75,11 @@ export function main() {
|
||||
}));
|
||||
|
||||
|
||||
it('should generate link hrefs with params', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
it('should generate link hrefs with params',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile('<a href="hello" [routerLink]="[\'./User\', {name: name}]">{{name}}</a>')
|
||||
.then((_) => router.config(
|
||||
[new Route({path: '/user/:name', component: UserCmp, name: 'User'})]))
|
||||
.then((_) => router.config([new Route(
|
||||
{path: '/user/:name', component: UserCmp, name: 'User'})]))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
fixture.debugElement.componentInstance.name = 'brian';
|
||||
@ -111,9 +93,8 @@ export function main() {
|
||||
it('should generate link hrefs from a child to its sibling',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile()
|
||||
.then(
|
||||
(_) => router.config(
|
||||
[new Route({path: '/page/:number', component: SiblingPageCmp, name: 'Page'})]))
|
||||
.then((_) => router.config([new Route(
|
||||
{path: '/page/:number', component: SiblingPageCmp, name: 'Page'})]))
|
||||
.then((_) => router.navigateByUrl('/page/1'))
|
||||
.then((_) => {
|
||||
fixture.detectChanges();
|
||||
@ -125,10 +106,8 @@ export function main() {
|
||||
it('should generate link hrefs from a child to its sibling with no leading slash',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile()
|
||||
.then((_) => router.config([
|
||||
new Route(
|
||||
{path: '/page/:number', component: NoPrefixSiblingPageCmp, name: 'Page'})
|
||||
]))
|
||||
.then((_) => router.config([new Route(
|
||||
{path: '/page/:number', component: NoPrefixSiblingPageCmp, name: 'Page'})]))
|
||||
.then((_) => router.navigateByUrl('/page/1'))
|
||||
.then((_) => {
|
||||
fixture.detectChanges();
|
||||
@ -140,9 +119,8 @@ export function main() {
|
||||
it('should generate link hrefs to a child with no leading slash',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile()
|
||||
.then((_) => router.config([
|
||||
new Route({path: '/book/:title/...', component: NoPrefixBookCmp, name: 'Book'})
|
||||
]))
|
||||
.then((_) => router.config([new Route(
|
||||
{path: '/book/:title/...', component: NoPrefixBookCmp, name: 'Book'})]))
|
||||
.then((_) => router.navigateByUrl('/book/1984/page/1'))
|
||||
.then((_) => {
|
||||
fixture.detectChanges();
|
||||
@ -154,9 +132,8 @@ export function main() {
|
||||
it('should throw when links without a leading slash are ambiguous',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile()
|
||||
.then((_) => router.config([
|
||||
new Route({path: '/book/:title/...', component: AmbiguousBookCmp, name: 'Book'})
|
||||
]))
|
||||
.then((_) => router.config([new Route(
|
||||
{path: '/book/:title/...', component: AmbiguousBookCmp, name: 'Book'})]))
|
||||
.then((_) => router.navigateByUrl('/book/1984/page/1'))
|
||||
.then((_) => {
|
||||
var link = ListWrapper.toJSON(['Book', {number: 100}]);
|
||||
@ -170,13 +147,11 @@ export function main() {
|
||||
it('should generate link hrefs when asynchronously loaded',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile()
|
||||
.then((_) => router.config([
|
||||
new AsyncRoute({
|
||||
path: '/child-with-grandchild/...',
|
||||
loader: parentCmpLoader,
|
||||
name: 'ChildWithGrandchild'
|
||||
})
|
||||
]))
|
||||
.then((_) => router.config([new AsyncRoute({
|
||||
path: '/child-with-grandchild/...',
|
||||
loader: parentCmpLoader,
|
||||
name: 'ChildWithGrandchild'
|
||||
})]))
|
||||
.then((_) => router.navigateByUrl('/child-with-grandchild/grandchild'))
|
||||
.then((_) => {
|
||||
fixture.detectChanges();
|
||||
@ -188,30 +163,33 @@ export function main() {
|
||||
it('should generate relative links preserving the existing parent route',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile()
|
||||
.then((_) => router.config(
|
||||
[new Route({path: '/book/:title/...', component: BookCmp, name: 'Book'})]))
|
||||
.then((_) => router.config([new Route(
|
||||
{path: '/book/:title/...', component: BookCmp, name: 'Book'})]))
|
||||
.then((_) => router.navigateByUrl('/book/1984/page/1'))
|
||||
.then((_) => {
|
||||
fixture.detectChanges();
|
||||
// TODO(juliemr): This should be one By.css('book-cmp a') query, but the parse5
|
||||
// adapter
|
||||
// can't handle css child selectors.
|
||||
expect(getDOM().getAttribute(fixture.debugElement.query(By.css('book-cmp'))
|
||||
.query(By.css('a'))
|
||||
.nativeElement,
|
||||
'href'))
|
||||
expect(getDOM().getAttribute(
|
||||
fixture.debugElement.query(By.css('book-cmp'))
|
||||
.query(By.css('a'))
|
||||
.nativeElement,
|
||||
'href'))
|
||||
.toEqual('/book/1984/page/100');
|
||||
|
||||
expect(getDOM().getAttribute(fixture.debugElement.query(By.css('page-cmp'))
|
||||
.query(By.css('a'))
|
||||
.nativeElement,
|
||||
'href'))
|
||||
expect(getDOM().getAttribute(
|
||||
fixture.debugElement.query(By.css('page-cmp'))
|
||||
.query(By.css('a'))
|
||||
.nativeElement,
|
||||
'href'))
|
||||
.toEqual('/book/1984/page/2');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should generate links to auxiliary routes', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
it('should generate links to auxiliary routes',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile()
|
||||
.then((_) => router.config([new Route({path: '/...', component: AuxLinkCmp})]))
|
||||
.then((_) => router.navigateByUrl('/'))
|
||||
@ -224,11 +202,13 @@ export function main() {
|
||||
|
||||
|
||||
describe('router-link-active CSS class', () => {
|
||||
it('should be added to the associated element', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
router.config([
|
||||
new Route({path: '/child', component: HelloCmp, name: 'Child'}),
|
||||
new Route({path: '/better-child', component: Hello2Cmp, name: 'BetterChild'})
|
||||
])
|
||||
it('should be added to the associated element',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
router
|
||||
.config([
|
||||
new Route({path: '/child', component: HelloCmp, name: 'Child'}),
|
||||
new Route({path: '/better-child', component: Hello2Cmp, name: 'BetterChild'})
|
||||
])
|
||||
.then((_) => compile(`<a [routerLink]="['./Child']" class="child-link">Child</a>
|
||||
<a [routerLink]="['./BetterChild']" class="better-child-link">Better Child</a>
|
||||
<router-outlet></router-outlet>`))
|
||||
@ -255,15 +235,16 @@ export function main() {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should be added to links in child routes', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
router.config([
|
||||
new Route({path: '/child', component: HelloCmp, name: 'Child'}),
|
||||
new Route({
|
||||
path: '/child-with-grandchild/...',
|
||||
component: ParentCmp,
|
||||
name: 'ChildWithGrandchild'
|
||||
})
|
||||
])
|
||||
it('should be added to links in child routes',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
router
|
||||
.config([
|
||||
new Route({path: '/child', component: HelloCmp, name: 'Child'}), new Route({
|
||||
path: '/child-with-grandchild/...',
|
||||
component: ParentCmp,
|
||||
name: 'ChildWithGrandchild'
|
||||
})
|
||||
])
|
||||
.then((_) => compile(`<a [routerLink]="['./Child']" class="child-link">Child</a>
|
||||
<a [routerLink]="['./ChildWithGrandchild/Grandchild']" class="child-with-grandchild-link">Better Child</a>
|
||||
<router-outlet></router-outlet>`))
|
||||
@ -298,19 +279,19 @@ export function main() {
|
||||
|
||||
it('should not be added to links in other child routes',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
router.config([
|
||||
new Route({path: '/child', component: HelloCmp, name: 'Child'}),
|
||||
new Route({
|
||||
path: '/child-with-grandchild/...',
|
||||
component: ParentCmp,
|
||||
name: 'ChildWithGrandchild'
|
||||
}),
|
||||
new Route({
|
||||
path: '/child-with-other-grandchild/...',
|
||||
component: ParentCmp,
|
||||
name: 'ChildWithOtherGrandchild'
|
||||
})
|
||||
])
|
||||
router
|
||||
.config([
|
||||
new Route({path: '/child', component: HelloCmp, name: 'Child'}), new Route({
|
||||
path: '/child-with-grandchild/...',
|
||||
component: ParentCmp,
|
||||
name: 'ChildWithGrandchild'
|
||||
}),
|
||||
new Route({
|
||||
path: '/child-with-other-grandchild/...',
|
||||
component: ParentCmp,
|
||||
name: 'ChildWithOtherGrandchild'
|
||||
})
|
||||
])
|
||||
.then((_) => compile(`<a [routerLink]="['./Child']" class="child-link">Child</a>
|
||||
<a [routerLink]="['./ChildWithGrandchild/Grandchild']" class="child-with-grandchild-link">Better Child</a>
|
||||
<a [routerLink]="['./ChildWithOtherGrandchild/Grandchild']" class="child-with-other-grandchild-link">Better Child</a>
|
||||
@ -351,10 +332,11 @@ export function main() {
|
||||
return dispatchedEvent;
|
||||
};
|
||||
|
||||
it('should navigate to link hrefs without params', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
it('should navigate to link hrefs without params',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
compile('<a href="hello" [routerLink]="[\'./User\']"></a>')
|
||||
.then((_) => router.config(
|
||||
[new Route({path: '/user', component: UserCmp, name: 'User'})]))
|
||||
.then((_) => router.config([new Route(
|
||||
{path: '/user', component: UserCmp, name: 'User'})]))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
fixture.detectChanges();
|
||||
@ -374,8 +356,8 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
(<SpyLocation>location).setBaseHref('/base');
|
||||
compile('<a href="hello" [routerLink]="[\'./User\']"></a>')
|
||||
.then((_) => router.config(
|
||||
[new Route({path: '/user', component: UserCmp, name: 'User'})]))
|
||||
.then((_) => router.config([new Route(
|
||||
{path: '/user', component: UserCmp, name: 'User'})]))
|
||||
.then((_) => router.navigateByUrl('/a/b'))
|
||||
.then((_) => {
|
||||
fixture.detectChanges();
|
||||
@ -404,7 +386,7 @@ class MyComp7 {
|
||||
name: any /** TODO #9100 */;
|
||||
}
|
||||
|
||||
@Component({selector: 'user-cmp', template: "hello {{user}}"})
|
||||
@Component({selector: 'user-cmp', template: 'hello {{user}}'})
|
||||
class UserCmp {
|
||||
user: string;
|
||||
constructor(params: RouteParams) { this.user = params.get('name'); }
|
||||
@ -504,8 +486,7 @@ class AmbiguousBookCmp {
|
||||
|
||||
@Component({
|
||||
selector: 'aux-cmp',
|
||||
template:
|
||||
`<a [routerLink]="[\'./Hello\', [ \'Aside\' ] ]">aside</a> |
|
||||
template: `<a [routerLink]="[\'./Hello\', [ \'Aside\' ] ]">aside</a> |
|
||||
<router-outlet></router-outlet> | aside <router-outlet name="aside"></router-outlet>`,
|
||||
directives: ROUTER_DIRECTIVES
|
||||
})
|
||||
|
Reference in New Issue
Block a user