Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- it('should call the banRepo.save() ones', async () => {
- const user = {
- id: '3',
- email: 'asdf@abv.bg',
- username: 'Pesho',
- password: '123450',
- isDeleted: false,
- banStatus: { id: '1', description: 'asfasd', expDate: '123.23.123', isBanned: false }
- }
- const options = {
- where: {
- id: user.id,
- }
- };
- const spyOnFindOne = jest.spyOn(userRepo, 'findOne').mockImplementation(() => Promise.resolve(user));
- const spyOnBan = jest.spyOn(banRepo, 'save').mockImplementation(() => user);
- service.banUser('1','123431');
- expect(spyOnBan).toHaveBeenCalledTimes(1);
- // expect(spyOnBan).toHaveBeenCalledWith(`You successfully succeeded to ban ${user.username}!`);
- spyOnBan.mockRestore();
- spyOnFindOne.mockRestore();
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement