Skip to content

Commit 190b0a1

Browse files
committed
test: ensure BcryptAdapter returns a hash on success
1 parent 450815b commit 190b0a1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/infra/criptography/bcrypt-adapter.spec.ts

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { BcryptAdapter } from './bcrypt-adapter'
22
import bcrypt from 'bcrypt'
3+
jest.mock('bcrypt', () => ({
4+
async hash (): Promise<string> {
5+
return await new Promise(resolve => resolve('hash'))
6+
}
7+
8+
}))
39
describe('Bcrypt Adapter', () => {
410
test('Should call bcrypt with correct values', async () => {
511
const salt = 12
@@ -8,4 +14,10 @@ describe('Bcrypt Adapter', () => {
814
await sut.encrypt('any_value')
915
expect(hashSpy).toHaveBeenCalledWith('any_value', salt)
1016
})
17+
test('Should return a hash on success', async () => {
18+
const salt = 12
19+
const sut = new BcryptAdapter(salt)
20+
const hash = await sut.encrypt('any_value')
21+
expect(hash).toBe('hash')
22+
})
1123
})

0 commit comments

Comments
 (0)