Skip to content

Commit 17baffa

Browse files
committed
feat: add additional test for handlePassswordValidation
1 parent 792e954 commit 17baffa

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/unit/node/util.test.ts

+16
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,22 @@ describe("handlePasswordValidation", () => {
287287

288288
const matchesHash = await util.isHashMatch(p, passwordValidation.hashedPassword)
289289

290+
expect(passwordValidation.isPasswordValid).toBe(false)
291+
expect(matchesHash).toBe(false)
292+
})
293+
it("should return false and empty string as hashedPassword when passwordMethod is invalid", async () => {
294+
const p = "password1"
295+
const passwordValidation = await util.handlePasswordValidation({
296+
// @ts-expect-error although this shouldn't ever happen, it ensures the default case in this function
297+
// works as expected.
298+
passwordMethod: "INVALID",
299+
passwordFromRequestBody: p,
300+
passwordFromArgs: undefined,
301+
hashedPasswordFromArgs: undefined,
302+
})
303+
304+
const matchesHash = await util.isHashMatch(p, passwordValidation.hashedPassword)
305+
290306
expect(passwordValidation.isPasswordValid).toBe(false)
291307
expect(matchesHash).toBe(false)
292308
})

0 commit comments

Comments
 (0)