| /** |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| import {BehaviorSubject} from 'rxjs/BehaviorSubject'; |
| import {NavigationExtras, Params} from '@angular/router'; |
| import {Component, Directive, Injectable, Input} from '@angular/core'; |
| |
| @Directive({ |
| // tslint:disable-next-line:directive-selector |
| selector: '[routerLink]', |
| // tslint:disable-next-line:use-host-property-decorator |
| host: { |
| '(click)': 'onClick()' |
| } |
| }) |
| export class RouterLinkStubDirective { |
| // tslint:disable-next-line:no-input-rename |
| @Input('routerLink') linkParams: any; |
| navigatedTo: any = null; |
| |
| onClick() { |
| this.navigatedTo = this.linkParams; |
| } |
| } |
| |
| |
| @Component({ |
| // tslint:disable-next-line:component-selector |
| selector: 'router-outlet', |
| template: '' |
| }) |
| export class RouterOutletStubComponent { } |
| |
| @Injectable() |
| export class RouterStub { |
| navigate(commands: any[], extras?: NavigationExtras) { } |
| } |
| |
| @Injectable() |
| export class ActivatedRouteStub { |
| |
| // ActivatedRoute.paramMap is Observable |
| private subject = new BehaviorSubject(this.testParams); |
| |
| params = this.subject.asObservable(); |
| |
| // Test parameters |
| private _testParams: Params; |
| |
| get testParams() { return this._testParams; } |
| |
| set testParams(params: {}) { |
| this._testParams = params; |
| this.subject.next(this._testParams); |
| } |
| |
| // ActivatedRoute.snapshot.paramMap |
| get snapshot() { |
| return { params: this.testParams }; |
| } |
| } |