@ -12,7 +12,7 @@ import {
|
||||
SpyObject
|
||||
} from 'angular2/test_lib';
|
||||
|
||||
import {Injector, bind} from 'angular2/core';
|
||||
import {Injector, provide} from 'angular2/core';
|
||||
import {CONST_EXPR} from 'angular2/src/core/facade/lang';
|
||||
import {Location, APP_BASE_HREF} from 'angular2/src/router/location';
|
||||
import {LocationStrategy} from 'angular2/src/router/location_strategy';
|
||||
@ -23,11 +23,11 @@ export function main() {
|
||||
|
||||
var locationStrategy, location;
|
||||
|
||||
function makeLocation(baseHref: string = '/my/app', binding: any = CONST_EXPR([])): Location {
|
||||
function makeLocation(baseHref: string = '/my/app', provider: any = CONST_EXPR([])): Location {
|
||||
locationStrategy = new MockLocationStrategy();
|
||||
locationStrategy.internalBaseHref = baseHref;
|
||||
let injector = Injector.resolveAndCreate(
|
||||
[Location, bind(LocationStrategy).toValue(locationStrategy), binding]);
|
||||
[Location, provide(LocationStrategy, {asValue: locationStrategy}), provider]);
|
||||
return location = injector.get(Location);
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should use optional base href param', () => {
|
||||
let location = makeLocation('/', bind(APP_BASE_HREF).toValue('/my/custom/href'));
|
||||
let location = makeLocation('/', provide(APP_BASE_HREF, {asValue: '/my/custom/href'}));
|
||||
location.go('user/btford');
|
||||
expect(locationStrategy.path()).toEqual('/my/custom/href/user/btford');
|
||||
});
|
||||
@ -81,7 +81,7 @@ export function main() {
|
||||
locationStrategy.internalBaseHref = null;
|
||||
expect(() => new Location(locationStrategy))
|
||||
.toThrowError(
|
||||
`No base href set. Either provide a binding for the APP_BASE_HREF token or add a base element to the document.`);
|
||||
`No base href set. Either provide a provider for the APP_BASE_HREF token or add a base element to the document.`);
|
||||
});
|
||||
|
||||
it('should revert to the previous path when a back() operation is executed', () => {
|
||||
|
Reference in New Issue
Block a user