Skip to content

Commit 00224fa

Browse files
authoredFeb 3, 2022
feat: add test for hash when error (#4814)
1 parent fd643dc commit 00224fa

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed
 

‎src/node/util.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,7 @@ export const generatePassword = async (length = 24): Promise<string> => {
157157
* Used to hash the password.
158158
*/
159159
export const hash = async (password: string): Promise<string> => {
160-
try {
161-
return await argon2.hash(password)
162-
} catch (error: any) {
163-
logger.error(error)
164-
return ""
165-
}
160+
return await argon2.hash(password)
166161
}
167162

168163
/**

‎test/unit/node/util.test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ describe("hash", () => {
104104
const hashed = await util.hash(plainTextPassword)
105105
expect(hashed).not.toBe(plainTextPassword)
106106
})
107+
it("should return a hash for an empty string", async () => {
108+
const hashed = await util.hash("")
109+
expect(hashed).not.toBe("")
110+
})
107111
})
108112

109113
describe("isHashMatch", () => {

0 commit comments

Comments
 (0)
Failed to load comments.