
AngularJS's `$location` service doesn't have a direct counterpart in Angular. This is largely because the `Location` service in Angular was pulled out of the `Router`, but was not purpose-built to stand on its own. This commit adds a new `@angular/common/upgrade` package with the beginnings of a new `LocationUpgradeService`. This service will more closely match the API of AngularJS and provide a way to replace the `$location` service from AngularJS. PR Close #30055
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
import {LocationUpgradeModule, LocationUpgradeService} from '@angular/common/upgrade';
|
|
import {TestBed, inject} from '@angular/core/testing';
|
|
import {UpgradeModule} from '@angular/upgrade/static';
|
|
|
|
describe('LocationUpgradeService', () => {
|
|
let upgradeModule: UpgradeModule;
|
|
|
|
beforeEach(() => {
|
|
TestBed.configureTestingModule({
|
|
imports: [LocationUpgradeModule],
|
|
providers: [UpgradeModule],
|
|
});
|
|
|
|
upgradeModule = TestBed.get(UpgradeModule);
|
|
upgradeModule.$injector = {
|
|
get: jasmine.createSpy('$injector.get').and.returnValue({'$on': () => undefined})
|
|
};
|
|
});
|
|
|
|
it('should instantiate LocationUpgradeService',
|
|
inject([LocationUpgradeService], (location: LocationUpgradeService) => {
|
|
expect(location).toBeDefined();
|
|
expect(location instanceof LocationUpgradeService).toBe(true);
|
|
}));
|
|
}); |