How to mock an activatedRoute parent Route in angular2 for testing purposes?

后端 未结 6 484
渐次进展
渐次进展 2020-12-05 03:57

Let\'s say I have this

export class QuestionnaireQuestionsComponent {

    questions: Question[] = [];
    private loading:boolean = true;


    constructor(         


        
6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-05 04:56

    You can also simple plass {params: {searchTerm: 'this is not me'}} as any) as ActivatedRouteSnapshot

    detailds code

      (service.resolve(({params: {id: 'this is id'}} as any) as ActivatedRouteSnapshot,
        {} as RouterStateSnapshot)as Observable)
        .subscribe((data) => {
          expect((data as xyzResolveData).results).toEqual(xyzData.results);
        });
    

提交回复
热议问题