chore: convert hash_location_strategy example to a tested spec

This commit is contained in:
Jesús Rodríguez 2016-08-31 02:02:40 +02:00 committed by Victor Berchet
parent 4c35be3e07
commit fb38fba8f9
2 changed files with 35 additions and 12 deletions

View File

@ -27,18 +27,8 @@ import {LocationChangeListener, PlatformLocation} from './platform_location';
* *
* ### Example * ### Example
* *
* ``` * {@example common/location/ts/hash_location_strategy/hash_location_strategy_spec.ts
* import {Component, NgModule} from '@angular/core'; * region='hash_location_strategy'}
* import {
* LocationStrategy,
* HashLocationStrategy
* } from '@angular/common';
*
* @NgModule({
* providers: [{provide: LocationStrategy, useClass: HashLocationStrategy}]
* })
* class AppModule {}
* ```
* *
* @stable * @stable
*/ */

View File

@ -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'); });
});
}