23 lines
637 B
TypeScript
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)
|
|
})
|
|
})
|