20 lines
658 B
TypeScript
20 lines
658 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { hashPassword, verifyPassword } from '#shared/password';
|
|
import { slugify } from '#shared/plans';
|
|
|
|
describe('password hashing', () => {
|
|
it('round-trips a password', async () => {
|
|
const hash = await hashPassword('password');
|
|
expect(hash).not.toBe('password');
|
|
expect(await verifyPassword('password', hash)).toBe(true);
|
|
expect(await verifyPassword('wrong', hash)).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('slugify', () => {
|
|
it('produces a url-safe slug', () => {
|
|
expect(slugify('Hello, World!')).toBe('hello-world');
|
|
expect(slugify(' Already-slug ')).toBe('already-slug');
|
|
});
|
|
});
|