According to the Angular DI documentation, there is an example provided:
let mockService = <HeroService> {getHeroes: () => expectedHeroes }
So, my question is - can we consider mockService
as an instance of HeroService
at this point?
To provide more clarity, here is another code snippet:
it('should have heroes when HeroListComponent created', () => {
let hlc = new HeroListComponent(mockService);
expect(hlc.heroes.length).toEqual(expectedHeroes.length);
});
In my opinion, in order for mockService
to be accepted by the HeroListComponent
constructor, it must be an instance of the implementation or interface of HeroService
.