feat: add test for hash when error (#4814)

This commit is contained in:
Joe Previte 2022-02-03 14:22:16 -07:00 committed by GitHub
parent fd643dcbc3
commit 00224fa73a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View File

@ -157,12 +157,7 @@ export const generatePassword = async (length = 24): Promise<string> => {
* Used to hash the password.
*/
export const hash = async (password: string): Promise<string> => {
try {
return await argon2.hash(password)
} catch (error: any) {
logger.error(error)
return ""
}
return await argon2.hash(password)
}
/**

View File

@ -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", () => {