# CICADA

### File

`src/testing/activated-route-stub.ts`

### Description

An ActivateRoute test double with a `paramMap` observable. Use the `setParamMap()` method to add the next `paramMap` value.

### Index

###### Properties

- Readonly paramMap
- Private subject

###### Methods

- setParamMap

### Constructor

`constructor(initialParams?: Params)`
Defined in src/testing/activated-route-stub.ts:11

Parameters :

Name | Type | Optional
initialParams | `Params` | Yes

### Properties

Readonly paramMap
Default value : `this.subject.asObservable()`
Defined in src/testing/activated-route-stub.ts:18
The mock paramMap observable

Private subject
Default value : `new ReplaySubject<ParamMap>()`
Defined in src/testing/activated-route-stub.ts:11

### Methods

setParamMap
`setParamMap(params?: Params)`
Defined in src/testing/activated-route-stub.ts:21

Set the paramMap observables's next value

Parameters :

Name | Type | Optional
params | `Params` | Yes

Returns : `void`

    import { convertToParamMap, ParamMap, Params } from '@angular/router';
    import { ReplaySubject } from 'rxjs';

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

      constructor(initialParams?: Params) {
        this.setParamMap(initialParams);
      }

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

      /** Set the paramMap observables's next value */
      setParamMap(params?: Params): void {
        this.subject.next(convertToParamMap(params));
      }
    }

# result-matching ""

# No results matching ""