From cd488fb98e248b7f173d9ea8e2b1b4aa41d088f4 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Mon, 31 Jan 2022 16:11:20 -0700 Subject: [PATCH] feat: add test for hash when error --- 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 a926838e0bc1..a56d6615c222 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 a236bfca6a7f..e5c50b4bdf9d 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", () => {