UNPKG

@tomei/sso

Version:
32 lines (26 loc) 932 B
import { PasswordHashService } from "../../../../src/components/password-hash/password-hash.service"; jest.mock('argon2', () => { return { hash: jest.fn((passowrd) => { return `hash${passowrd}`; }), verify: jest.fn().mockResolvedValue(true) } }) describe('password-hash.service', () => { const passwordHashService = new PasswordHashService(); afterEach(() => { jest.clearAllMocks(); }); it('should return hash password', async () => { const password = 'password'; const hash = await passwordHashService.hashPassword(password); expect(hash).toEqual('hashpassword'); }) it('should return true when verify password', async () => { const password = 'password'; const hash = 'hashpassword10'; const result = await passwordHashService.verify(password, hash); expect(result).toEqual(true); }); })