0

I am reading data from the activatedRoute.data as below Not able to mock the ActivatedRoute. Please some one suggest me.

import { BehaviorSubject } from "rxjs";

export class MockActivatedRoute { data: BehaviorSubject;

constructor(){
    this.data = of({
        "projectdata": {data: "data"}
    });
}

private paramsSubject = new BehaviorSubject(this.testParams);
private _testParams: {};

params  = this.paramsSubject.asObservable();

get testParams() {
    return this._testParams;
}
set testParams(newParams: any) {
    this._testParams = newParams;
    this.paramsSubject.next(newParams);
}

}

I have tried like this

but unable to resolve the issue. the above code is used for mocking paramaters i want to mock the data..

Any suggestions Please let me know.

Indrakumara
  • 1,595
  • 17
  • 22
  • I am writing test cases for component which is having Activated route as dependency injection for that i need to create a Stub for mocking the ActivatedRoute tried this one(https://vsavkin.com/three-ways-to-test-angular-2-components-dcea8e90bd8d) but not able to fix my problem – user8260229 Dec 26 '18 at 07:08
  • can you please share your test case? When you do 'activatedRoute.data.subscribe()', what is the output? – Pavankumar Shukla Dec 26 '18 at 07:30

0 Answers0