# All files / src/testing activated-route-stub.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 3/3
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    243x

    3x

    3x

    3x

    3x

    3x
    8x

    3x
     import { ReplaySubject } from 'rxjs';

    /**
     * An ActivateRoute test double with a `params` observable.
     * Use the `setParams()` method to add the next `params` value.
     */
    export class ActivatedRouteStub {
      // Use a ReplaySubject to share previous values with subscribers
      // and pump new values into the `params` observable
      private subject = new ReplaySubject<object>();

      constructor(initialParams?: object) {
        this.setParams(initialParams);
      }

      /** The mock params observable */
      readonly params = this.subject.asObservable();

      /** Set the params observables's next value */
      setParams(params?: object) {
        this.subject.next(params);
      }
    }