Skip to content

Commit fb38fba

Browse files
Foxandxssvicb
authored andcommitted
chore: convert hash_location_strategy example to a tested spec
1 parent 4c35be3 commit fb38fba

2 files changed

Lines changed: 35 additions & 12 deletions

File tree

modules/@angular/common/src/location/hash_location_strategy.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,8 @@ import {LocationChangeListener, PlatformLocation} from './platform_location';
2727
*
2828
* ### Example
2929
*
30-
* ```
31-
* import {Component, NgModule} from '@angular/core';
32-
* import {
33-
* LocationStrategy,
34-
* HashLocationStrategy
35-
* } from '@angular/common';
36-
*
37-
* @NgModule({
38-
* providers: [{provide: LocationStrategy, useClass: HashLocationStrategy}]
39-
* })
40-
* class AppModule {}
41-
* ```
30+
* {@example common/location/ts/hash_location_strategy/hash_location_strategy_spec.ts
31+
* region='hash_location_strategy'}
4232
*
4333
* @stable
4434
*/
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
// #docplaster
9+
// #docregion hash_location_strategy
10+
import {HashLocationStrategy, LocationStrategy} from '@angular/common';
11+
import {NgModule} from '@angular/core';
12+
13+
// #enddocregion hash_location_strategy
14+
import {TestBed} from '@angular/core/testing';
15+
16+
// #docregion hash_location_strategy
17+
@NgModule({providers: [{provide: LocationStrategy, useClass: HashLocationStrategy}]})
18+
class AppModule {
19+
}
20+
// #enddocregion hash_location_strategy
21+
export function main() {
22+
describe('hash_location_strategy examples', () => {
23+
let locationStrategy: HashLocationStrategy;
24+
25+
beforeEach(() => {
26+
locationStrategy =
27+
TestBed.configureTestingModule({imports: [AppModule]}).get(LocationStrategy);
28+
});
29+
30+
it('hash_location_strategy example works',
31+
() => { expect(locationStrategy.prepareExternalUrl('app/foo')).toBe('#app/foo'); });
32+
});
33+
}

0 commit comments

Comments
 (0)