71aaec93ef
this adds the groundwork to start unit testing some modules
21 lines
611 B
TypeScript
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);
|
|
});
|
|
});
|