to much to say
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
const dotenv = require("dotenv");
|
||||
const {verify, hash, generatePassword} = require("./password");
|
||||
|
||||
dotenv.config();
|
||||
|
||||
describe('Password.js Tests', () => {
|
||||
const password = 'password';
|
||||
test('hash should return a hashed password', async () => {
|
||||
const hashedPassword = await hash(password);
|
||||
expect(hashedPassword).not.toEqual(password);
|
||||
});
|
||||
|
||||
test('verify should return true for a valid password', async () => {
|
||||
const hashedPassword = await hash(password);
|
||||
const result = await verify(password, hashedPassword);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test('verify should return false for an invalid password', async () => {
|
||||
const hashedPassword = await hash(password);
|
||||
const result = await verify(password + 'a', hashedPassword);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
test('generatePassword should return a valid password', async () => {
|
||||
const generatedPassword = await generatePassword();
|
||||
const hashedpass = await hash(generatedPassword);
|
||||
const result = await verify(generatedPassword, hashedpass);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user