We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 450815b commit 190b0a1Copy full SHA for 190b0a1
src/infra/criptography/bcrypt-adapter.spec.ts
@@ -1,5 +1,11 @@
1
import { BcryptAdapter } from './bcrypt-adapter'
2
import bcrypt from 'bcrypt'
3
+jest.mock('bcrypt', () => ({
4
+ async hash (): Promise<string> {
5
+ return await new Promise(resolve => resolve('hash'))
6
+ }
7
+
8
+}))
9
describe('Bcrypt Adapter', () => {
10
test('Should call bcrypt with correct values', async () => {
11
const salt = 12
@@ -8,4 +14,10 @@ describe('Bcrypt Adapter', () => {
14
await sut.encrypt('any_value')
15
expect(hashSpy).toHaveBeenCalledWith('any_value', salt)
16
})
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
+ })
23
0 commit comments