From 00224fa73a8907e6478ebeda6049f85711dbd1b4 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Thu, 3 Feb 2022 14:22:16 -0700 Subject: [PATCH] feat: add test for hash when error (#4814) --- src/node/util.ts | 7 +------ test/unit/node/util.test.ts | 4 ++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/node/util.ts b/src/node/util.ts index a926838e..a56d6615 100644 --- a/src/node/util.ts +++ b/src/node/util.ts @@ -157,12 +157,7 @@ export const generatePassword = async (length = 24): Promise => { * Used to hash the password. */ export const hash = async (password: string): Promise => { - try { - return await argon2.hash(password) - } catch (error: any) { - logger.error(error) - return "" - } + return await argon2.hash(password) } /** diff --git a/test/unit/node/util.test.ts b/test/unit/node/util.test.ts index a236bfca..e5c50b4b 100644 --- a/test/unit/node/util.test.ts +++ b/test/unit/node/util.test.ts @@ -104,6 +104,10 @@ describe("hash", () => { const hashed = await util.hash(plainTextPassword) expect(hashed).not.toBe(plainTextPassword) }) + it("should return a hash for an empty string", async () => { + const hashed = await util.hash("") + expect(hashed).not.toBe("") + }) }) describe("isHashMatch", () => {