template-web-astro/tests/libs/authUtils.test.ts
Florian Bouillon ff07f8f4a5 fet: Add changes lol
Signed-off-by: Florian BOUILLON <f.bouillon@aptatio.com>
2023-06-28 17:30:18 +02:00

23 lines
637 B
TypeScript

import { describe, expect, it } from 'vitest'
import { comparePassword, hashPassword } from '../../src/libs/AuthUtils'
describe('AuthUtils', () => {
it('should hash the password', async () => {
expect(await hashPassword('test')).toBeDefined()
})
it('should compared succeffully password', async () => {
const pass = 'test'
const hash = await hashPassword(pass)
expect(await comparePassword(pass, hash)).toBe(true)
})
it('should not generate twice the same hash', async () => {
const pass = 'test'
const hash1 = await hashPassword(pass)
const hash2 = await hashPassword(pass)
expect(hash1).not.toBe(hash2)
})
})