File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -6,17 +6,21 @@ jest.mock('bcrypt', () => ({
6
6
}
7
7
8
8
} ) )
9
+
10
+ const salt = 12
11
+ const makeSut = ( ) : BcryptAdapter => {
12
+ return new BcryptAdapter ( salt )
13
+ }
14
+
9
15
describe ( 'Bcrypt Adapter' , ( ) => {
10
16
test ( 'Should call bcrypt with correct values' , async ( ) => {
11
- const salt = 12
12
- const sut = new BcryptAdapter ( salt )
17
+ const sut = makeSut ( )
13
18
const hashSpy = jest . spyOn ( bcrypt , 'hash' )
14
19
await sut . encrypt ( 'any_value' )
15
20
expect ( hashSpy ) . toHaveBeenCalledWith ( 'any_value' , salt )
16
21
} )
17
22
test ( 'Should return a hash on success' , async ( ) => {
18
- const salt = 12
19
- const sut = new BcryptAdapter ( salt )
23
+ const sut = makeSut ( )
20
24
const hash = await sut . encrypt ( 'any_value' )
21
25
expect ( hash ) . toBe ( 'hash' )
22
26
} )
You can’t perform that action at this time.
0 commit comments