How to unit test a component that depends on parameters from ActivatedRoute?

前端 未结 8 1127
离开以前
离开以前 2020-12-04 09:37

I am unit testing a component that is used to edit an object. The object has an unique id that is used in order to grab the specific object from an array of obj

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-04 10:04

    Added provider in the test class as:

    {
      provide: ActivatedRoute,
      useValue: {
        paramMap: of({ get: v => { return { id: 123 }; } })
      } 
    }
    

提交回复
热议问题