Mudanças entre as edições de "Unit testing with default Angular installation"
De Basef
(Criou página com ' == Getting instance of a service == <source lang="javascript"> let mockedLoginService = TestBed.get(LoginService); </source> Category: AngularJS2') |
|||
| Linha 6: | Linha 6: | ||
let mockedLoginService = TestBed.get(LoginService); | let mockedLoginService = TestBed.get(LoginService); | ||
</source> | </source> | ||
| + | |||
| + | == Asserting that some method is called == | ||
| + | |||
| + | <source lang="javascript"> | ||
| + | |||
| + | let spySomeMethod = spyOn(someInstance, 'someMethod'); | ||
| + | |||
| + | // do something here | ||
| + | |||
| + | expect(spySomeMethod).toHaveBeenCalled(); | ||
| + | |||
| + | </source> | ||
| + | |||
| + | |||
[[Category: AngularJS2]] | [[Category: AngularJS2]] | ||
Edição das 14h52min de 26 de abril de 2018
Getting instance of a service
let mockedLoginService = TestBed.get(LoginService);
Asserting that some method is called
let spySomeMethod = spyOn(someInstance, 'someMethod'); // do something here expect(spySomeMethod).toHaveBeenCalled();