chore: convert hash_location_strategy example to a tested spec
This commit is contained in:
parent
4c35be3e07
commit
fb38fba8f9
|
@ -27,18 +27,8 @@ import {LocationChangeListener, PlatformLocation} from './platform_location';
|
|||
*
|
||||
* ### Example
|
||||
*
|
||||
* ```
|
||||
* import {Component, NgModule} from '@angular/core';
|
||||
* import {
|
||||
* LocationStrategy,
|
||||
* HashLocationStrategy
|
||||
* } from '@angular/common';
|
||||
*
|
||||
* @NgModule({
|
||||
* providers: [{provide: LocationStrategy, useClass: HashLocationStrategy}]
|
||||
* })
|
||||
* class AppModule {}
|
||||
* ```
|
||||
* {@example common/location/ts/hash_location_strategy/hash_location_strategy_spec.ts
|
||||
* region='hash_location_strategy'}
|
||||
*
|
||||
* @stable
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* @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
|
||||
*/
|
||||
// #docplaster
|
||||
// #docregion hash_location_strategy
|
||||
import {HashLocationStrategy, LocationStrategy} from '@angular/common';
|
||||
import {NgModule} from '@angular/core';
|
||||
|
||||
// #enddocregion hash_location_strategy
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
|
||||
// #docregion hash_location_strategy
|
||||
@NgModule({providers: [{provide: LocationStrategy, useClass: HashLocationStrategy}]})
|
||||
class AppModule {
|
||||
}
|
||||
// #enddocregion hash_location_strategy
|
||||
export function main() {
|
||||
describe('hash_location_strategy examples', () => {
|
||||
let locationStrategy: HashLocationStrategy;
|
||||
|
||||
beforeEach(() => {
|
||||
locationStrategy =
|
||||
TestBed.configureTestingModule({imports: [AppModule]}).get(LocationStrategy);
|
||||
});
|
||||
|
||||
it('hash_location_strategy example works',
|
||||
() => { expect(locationStrategy.prepareExternalUrl('app/foo')).toBe('#app/foo'); });
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue