Promact/slack-erp-custom-integration-mvc

View on GitHub
Slack.Automation/Promact.Erp.Web/app/shared/mock/mock.router.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';


export class UrlTree {
    queryParams: {
        [key: string]: string;
    };
    fragment: string;
}

//mock Router service
@Injectable()
export class MockRouter {
    navigate() {
        return true;
    }
    createUrlTree() {
        return new UrlTree();
    }

    serializeUrl() {
        return "test";
    }
    hooks = {
        beforePreactivation: null,
        afterPreactivation: null
    };
    initialNavigation() {
    };

    private subject = new BehaviorSubject(this.testParams);
    events = this.subject.asObservable();

    // ActivatedRoute.params is Observable
    // Test parameters
    private _testParams: {};
    get testParams() { return this._testParams; }
    set testParams(params: {}) {
        this._testParams = params;
        this.subject.next(params);
    }
    routerState = {};
    navigateByUrl() {
        return new BehaviorSubject(true).asObservable();
    }
}