import { describe, expect, it } from 'vitest'; import { generateToken, hashToken, verifyToken } from '../src/services/tokens.js'; describe('tokens', () => { it('hashes a random token and rejects a different one', () => { const token = generateToken(); const hash = hashToken(token); expect(token).toMatch(/^[A-Za-z0-9_-]+$/); expect(hash).toHaveLength(64); expect(verifyToken(token, hash)).toBe(true); expect(verifyToken(`${token}x`, hash)).toBe(false); expect(verifyToken(token, 'abcd')).toBe(false); }); });