@@ -2,7 +2,7 @@ import { randomBytes } from 'crypto'
2
2
3
3
import test from 'ava'
4
4
5
- import { Algorithm , hash , verify , Version } from '../index.js'
5
+ import { Algorithm , hash , hashRaw , verify , Version } from '../index.js'
6
6
7
7
const passwordString = 'some_string123'
8
8
const passwordBuffer = Buffer . from ( passwordString )
@@ -43,6 +43,16 @@ test('should be able to hash string', async (t) => {
43
43
)
44
44
} )
45
45
46
+ test ( 'should be able to hashRaw string with a defined salt' , async ( t ) => {
47
+ await t . notThrowsAsync ( ( ) => hash ( 'whatever' ) )
48
+ await t . notThrowsAsync ( ( ) =>
49
+ hashRaw ( 'whatever' , {
50
+ secret : randomBytes ( 32 ) ,
51
+ salt : randomBytes ( 32 ) ,
52
+ } ) ,
53
+ )
54
+ } )
55
+
46
56
test ( 'should be able to verify hashed string' , async ( t ) => {
47
57
const PASSWORD = 'Argon2_is_the_best_algorithm_ever'
48
58
t . true ( await verify ( await hash ( PASSWORD ) , PASSWORD ) )
@@ -88,7 +98,7 @@ test('should return memoryCost error', async (t) => {
88
98
} ) ,
89
99
)
90
100
91
- t . is ( error . message , 'memory cost is too small' )
101
+ t . is ( error ? .message , 'memory cost is too small' )
92
102
} )
93
103
94
104
test ( 'should return timeCost error' , async ( t ) => {
@@ -98,7 +108,7 @@ test('should return timeCost error', async (t) => {
98
108
} ) ,
99
109
)
100
110
101
- t . is ( error . message , 'time cost is too small' )
111
+ t . is ( error ? .message , 'time cost is too small' )
102
112
} )
103
113
104
114
test ( 'should return parallelism error' , async ( t ) => {
@@ -109,5 +119,5 @@ test('should return parallelism error', async (t) => {
109
119
} ) ,
110
120
)
111
121
112
- t . is ( error . message , 'not enough threads' )
122
+ t . is ( error ? .message , 'not enough threads' )
113
123
} )
0 commit comments