UNPKG

@tomei/sso

Version:
38 lines 1.85 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const password_hash_service_1 = require("../../../../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 password_hash_service_1.PasswordHashService(); afterEach(() => { jest.clearAllMocks(); }); it('should return hash password', () => __awaiter(void 0, void 0, void 0, function* () { const password = 'password'; const hash = yield passwordHashService.hashPassword(password); expect(hash).toEqual('hashpassword'); })); it('should return true when verify password', () => __awaiter(void 0, void 0, void 0, function* () { const password = 'password'; const hash = 'hashpassword10'; const result = yield passwordHashService.verify(password, hash); expect(result).toEqual(true); })); }); //# sourceMappingURL=password-hash.service.spec.js.map