Skip to content

Commit

Permalink
feat: add test for hash when error (#4814)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsjoeio authored Feb 3, 2022
1 parent fd643dc commit 00224fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 1 addition & 6 deletions src/node/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

/**
Expand Down
4 changes: 4 additions & 0 deletions test/unit/node/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down

0 comments on commit 00224fa

Please sign in to comment.