2016-05-02 18:03:00 -04:00
|
|
|
import {
|
|
|
|
AsyncTestCompleter,
|
|
|
|
beforeEach,
|
|
|
|
ddescribe,
|
|
|
|
xdescribe,
|
|
|
|
describe,
|
|
|
|
expect,
|
|
|
|
iit,
|
|
|
|
inject,
|
|
|
|
beforeEachProviders,
|
|
|
|
it,
|
|
|
|
xit
|
|
|
|
} from '@angular/core/testing/testing_internal';
|
|
|
|
|
|
|
|
import {provide, Component, ComponentResolver} from '@angular/core';
|
|
|
|
import {RouterLink} from '../src/directives/router_link';
|
|
|
|
import {
|
|
|
|
Router,
|
|
|
|
RouterOutletMap,
|
|
|
|
RouteSegment,
|
|
|
|
Route,
|
|
|
|
ROUTER_DIRECTIVES,
|
|
|
|
Routes,
|
|
|
|
RouterUrlSerializer,
|
|
|
|
DefaultRouterUrlSerializer,
|
|
|
|
OnActivate,
|
|
|
|
CanDeactivate
|
|
|
|
} from '@angular/router';
|
2016-05-24 18:23:46 -04:00
|
|
|
import {Location, LocationStrategy} from '@angular/common';
|
|
|
|
import {SpyLocation, MockLocationStrategy} from '@angular/common/testing';
|
2016-05-02 18:03:00 -04:00
|
|
|
|
|
|
|
export function main() {
|
|
|
|
describe('RouterLink', () => {
|
|
|
|
beforeEachProviders(() => [
|
2016-06-02 20:30:40 -04:00
|
|
|
{provide: RouterUrlSerializer, useClass: DefaultRouterUrlSerializer},
|
2016-05-02 18:03:00 -04:00
|
|
|
RouterOutletMap,
|
2016-06-02 20:30:40 -04:00
|
|
|
{provide: Location, useClass: SpyLocation},
|
|
|
|
{provide: LocationStrategy, useClass: MockLocationStrategy},
|
|
|
|
{
|
|
|
|
provide: Router,
|
|
|
|
useFactory: (resolver, urlParser, outletMap, location) => new Router(
|
|
|
|
"RootComponent", RootCmp, resolver, urlParser, outletMap, location),
|
|
|
|
deps: [ComponentResolver, RouterUrlSerializer, RouterOutletMap, Location]
|
|
|
|
}
|
2016-05-02 18:03:00 -04:00
|
|
|
]);
|
|
|
|
|
|
|
|
describe("routerLink=", () => {
|
2016-05-24 18:23:46 -04:00
|
|
|
it("should accept an array of commands", inject([Router, LocationStrategy], (router, locationStrategy) => {
|
|
|
|
let link = new RouterLink(null, router, locationStrategy);
|
2016-05-03 21:49:59 -04:00
|
|
|
link.routerLink = ['/one', 11];
|
|
|
|
expect(link.href).toEqual("/one/11");
|
|
|
|
}));
|
2016-05-02 18:03:00 -04:00
|
|
|
|
2016-05-24 18:23:46 -04:00
|
|
|
it("should accept a single command", inject([Router, LocationStrategy], (router, locationStrategy) => {
|
|
|
|
let link = new RouterLink(null, router, locationStrategy);
|
2016-05-03 21:49:59 -04:00
|
|
|
link.routerLink = '/one/11';
|
|
|
|
expect(link.href).toEqual("/one/11");
|
|
|
|
}));
|
2016-05-02 18:03:00 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@Component({template: ''})
|
|
|
|
class RootCmp {
|
2016-05-24 18:23:46 -04:00
|
|
|
}
|