blob: 09ad31dbd7d1354fad93216dbe1465f90d63db93 [file] [log] [blame]
/**
******************************************************************************
* Copyright © 2017-2018 PTA GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
*
* http://www.eclipse.org/legal/epl-v10.html
*
******************************************************************************
*/
/* tslint:disable */
// export for convenience.
export { ActivatedRoute, Router, RouterLink, RouterOutlet } from '@angular/router';
import { ParamMap, convertToParamMap } from '@angular/router';
import { Component, Directive, Injectable, Input } from '@angular/core';
import { NavigationExtras } from '@angular/router';
@Directive({
selector: '[routerLink]',
host: {
'(click)': 'onClick()'
}
})
export class RouterLinkStubDirective {
@Input('routerLink') linkParams: any;
navigatedTo: any = null;
onClick() {
this.navigatedTo = this.linkParams;
}
}
@Component({ selector: 'router-outlet', template: '' })
export class RouterOutletStubComponent { }
@Injectable()
export class RouterStub {
navigate(commands: any[], extras?: NavigationExtras) { }
}
// Only implements params and part of snapshot.params
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
@Injectable()
export class ActivatedRouteStub {
// ActivatedRoute.params is Observable
private subject = new BehaviorSubject(this.testParams);
params = this.subject.asObservable();
private subject2 = new BehaviorSubject(this.testQueryParamMap);
queryParamMap = this.subject2.asObservable();
// Test parameters
private _testParams: {};
private _testQueryParamMap: ParamMap;
get testQueryParamMap() { return this._testQueryParamMap; }
set testQueryParamMap(params: {}) {
this._testQueryParamMap = convertToParamMap(params);
this.subject2.next(params);
}
get testParams() { return this._testParams; }
set testParams(params: {}) {
this._testParams = params;
this.subject.next(params);
}
// ActivatedRoute.snapshot.params
get snapshot() {
return { params: this.testParams, queryParamMap: this.testQueryParamMap };
}
}
/*
Copyright 2017 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 http://angular.io/license
*/