Files
kestrelos/test/unit/password.spec.js
Madison Grubb 1a566e2d80
Some checks failed
ci/woodpecker/pr/pr Pipeline failed
refactor testing
2026-02-17 11:05:57 -05:00

24 lines
712 B
JavaScript

import { describe, it, expect } from 'vitest'
import { hashPassword, verifyPassword } from '../../server/utils/password.js'
describe('password', () => {
it('hashes and verifies password', () => {
const password = 'secret123'
const stored = hashPassword(password)
expect(stored).toContain(':')
expect(verifyPassword(password, stored)).toBe(true)
})
it('rejects wrong password', () => {
const stored = hashPassword('right')
expect(verifyPassword('wrong', stored)).toBe(false)
})
it.each([
['a', ''],
['a', 'nocolon'],
])('rejects invalid stored format: password=%s, stored=%s', (password, stored) => {
expect(verifyPassword(password, stored)).toBe(false)
})
})