Advertisement
Guest User

Untitled

a guest
May 20th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. it('should call the banRepo.save() ones', async () => {
  2. const user = {
  3. id: '3',
  4. email: 'asdf@abv.bg',
  5. username: 'Pesho',
  6. password: '123450',
  7. isDeleted: false,
  8. banStatus: { id: '1', description: 'asfasd', expDate: '123.23.123', isBanned: false }
  9. }
  10. const options = {
  11. where: {
  12. id: user.id,
  13. }
  14. };
  15.  
  16. const spyOnFindOne = jest.spyOn(userRepo, 'findOne').mockImplementation(() => Promise.resolve(user));
  17. const spyOnBan = jest.spyOn(banRepo, 'save').mockImplementation(() => user);
  18.  
  19. service.banUser('1','123431');
  20.  
  21. expect(spyOnBan).toHaveBeenCalledTimes(1);
  22. // expect(spyOnBan).toHaveBeenCalledWith(`You successfully succeeded to ban ${user.username}!`);
  23. spyOnBan.mockRestore();
  24. spyOnFindOne.mockRestore();
  25. })
  26. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement