Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. it('should call getBook', async() => {
  2. // given
  3. spyOn(booksService, 'getBook');
  4.  
  5. // when
  6. const isbn = '9788306021486';
  7. component.ngOnInit();
  8. fixture.detectChanges();
  9. fixture.whenStable().then(() => {
  10. // then
  11. expect(booksService.getBook(isbn)).toHaveBeenCalled();
  12. });
  13. });
  14.  
  15. it('should call addNewBook', async() => {
  16. // given
  17. spyOn(booksService, 'addNewBook');
  18.  
  19. // when
  20. const book = new Book();
  21. component.ngOnInit();
  22. fixture.detectChanges();
  23. fixture.whenStable().then(() => {
  24. // then
  25. expect(booksService.addNewBook(book)).toHaveBeenCalled();
  26. });
  27. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement