Files
wg-easy-ca-lose/src/test/unit/password.spec.ts
T
Bernd Storath 71aaec93ef add unit tests
this adds the groundwork to start unit testing some modules
2026-02-11 15:23:04 +01:00

21 lines
611 B
TypeScript

import { expect, test, describe } from 'vitest';
import {
hashPassword,
isPasswordValid,
isValidPasswordHash,
} from '../../server/utils/password';
describe('password', () => {
test('password', async () => {
const hash = await hashPassword('password');
await expect(isPasswordValid('password', hash)).resolves.toBe(true);
await expect(isPasswordValid('wrong', hash)).resolves.toBe(false);
expect(isValidPasswordHash('not a hash')).toBe(false);
expect(isValidPasswordHash(hash)).toBe(true);
expect(isValidPasswordHash(hash.replace('argon2', 'argon3'))).toBe(false);
});
});