test(router): add tests for router.d.ts

Closes #3282
This commit is contained in:
Brian Ford 2015-08-04 15:08:59 -07:00
parent 166688348a
commit 450d3630cc
9 changed files with 49 additions and 12 deletions

View File

@ -20,7 +20,3 @@ declare module ng {
interface InjectableReference {}
}
{% endblock %}
declare module "angular2/angular2" {
export = ng;
}

View File

@ -65,8 +65,8 @@ declare module ng {
{% endfor %}
}
{% endfor %}
declare module "angular2/angular2" {
declare module "{$ alias $}" {
export = ng;
}
{% endfor %}

View File

@ -761,7 +761,7 @@ gulp.task('!pre.test.typings', ['docs/typings'], function() {
// -----------------
gulp.task('test.typings', ['!pre.test.typings'], function() {
return gulp.src(['typing_spec/*.ts', 'dist/docs/typings/angular2/angular2.d.ts'])
return gulp.src(['typing_spec/*.ts', 'dist/docs/typings/angular2/*.d.ts'])
.pipe(tsc({target: 'ES5', module: 'commonjs',
experimentalDecorators: true,
noImplicitAny: true,

View File

@ -16,8 +16,10 @@ export {HTML5LocationStrategy} from './src/router/html5_location_strategy';
export {Location, appBaseHrefToken} from './src/router/location';
export {Pipeline} from './src/router/pipeline';
export * from './src/router/route_config_decorator';
export * from './src/router/route_definition';
export {OnActivate, OnDeactivate, OnReuse, CanDeactivate, CanReuse} from './src/router/interfaces';
export {CanActivate} from './src/router/lifecycle_annotations';
export {Instruction} from './src/router/instruction';
import {LocationStrategy} from './src/router/location_strategy';
import {HTML5LocationStrategy} from './src/router/html5_location_strategy';

View File

@ -5,6 +5,8 @@
import {makeDecorator} from 'angular2/src/util/decorators';
import {CanActivate as CanActivateAnnotation} from './lifecycle_annotations_impl';
import {Promise} from 'angular2/src/facade/async';
import {Instruction} from 'angular2/src/router/instruction';
export {
canReuse,
@ -14,4 +16,6 @@ export {
onDeactivate
} from './lifecycle_annotations_impl';
export var CanActivate = makeDecorator(CanActivateAnnotation);
export var CanActivate:
(hook: (next: Instruction, prev: Instruction) => Promise<boolean>| boolean) => ClassDecorator =
makeDecorator(CanActivateAnnotation);

View File

@ -9,6 +9,6 @@ export class LocationStrategy {
pushState(ctx: any, title: string, url: string): void { throw _abstract(); }
forward(): void { throw _abstract(); }
back(): void { throw _abstract(); }
onPopState(fn: (_) => any): void { throw _abstract(); }
onPopState(fn: (_: any) => any): void { throw _abstract(); }
getBaseHref(): string { throw _abstract(); }
}

View File

@ -1,5 +1,7 @@
import {RouteConfig as RouteConfigAnnotation} from './route_config_impl';
import {RouteConfig as RouteConfigAnnotation, RouteDefinition} from './route_config_impl';
import {makeDecorator} from 'angular2/src/util/decorators';
import {List} from 'angular2/src/facade/collection';
export {Route, Redirect, AsyncRoute, RouteDefinition} from './route_config_impl';
export var RouteConfig = makeDecorator(RouteConfigAnnotation);
export var RouteConfig: (configs: List<RouteDefinition>) => ClassDecorator =
makeDecorator(RouteConfigAnnotation);

View File

View File

@ -0,0 +1,33 @@
///<reference path="../dist/docs/typings/angular2/angular2.d.ts"/>
///<reference path="../dist/docs/typings/angular2/router.d.ts"/>
import {Component, bootstrap, View} from 'angular2/angular2';
import {RouteConfig, routerDirectives, routerInjectables} from 'angular2/router';
@Component({
selector: 'my-app'
})
@View({
template: '<h1>Hello</h1>',
})
class FooCmp {
}
@Component({
selector: 'my-app'
})
@View({
template: '<h1>Hello {{ name }}</h1><router-outlet></router-outlet>',
directives: routerDirectives
})
@RouteConfig([
{path: '/home', component: FooCmp}
])
class MyAppComponent {
name: string;
constructor() { this.name = 'Alice'; }
}
bootstrap(MyAppComponent, routerInjectables);