@@ -12,11 +12,37 @@ suite('Crypto Utils', async () => {
12
12
crypto = new CryptoUtils ( ) ;
13
13
} ) ;
14
14
test ( 'If hashFormat equals `number`, method createHash() returns a number' , async ( ) => {
15
- const hash = crypto . createHash ( 'blabla' , 'hex' , ' number') ;
15
+ const hash = crypto . createHash ( 'blabla' , 'number' ) ;
16
16
assert . typeOf ( hash , 'number' , 'Type should be a number' ) ;
17
17
} ) ;
18
18
test ( 'If hashFormat equals `string`, method createHash() returns a string' , async ( ) => {
19
- const hash = crypto . createHash ( 'blabla' , 'hex' , ' string') ;
19
+ const hash = crypto . createHash ( 'blabla' , 'string' ) ;
20
20
assert . typeOf ( hash , 'string' , 'Type should be a string' ) ;
21
21
} ) ;
22
+ test ( 'If hashFormat equals `number`, the hash should not be NaN' , async ( ) => {
23
+ let hash = crypto . createHash ( 'test' , 'number' ) ;
24
+ assert . isNotNaN ( hash , 'Number hash should not be NaN' ) ;
25
+ hash = crypto . createHash ( 'hash' , 'number' ) ;
26
+ assert . isNotNaN ( hash , 'Number hash should not be NaN' ) ;
27
+ hash = crypto . createHash ( 'HASH1' , 'number' ) ;
28
+ assert . isNotNaN ( hash , 'Number hash should not be NaN' ) ;
29
+ } ) ;
30
+ test ( 'If hashFormat equals `string`, the hash should not be undefined' , async ( ) => {
31
+ let hash = crypto . createHash ( 'test' , 'string' ) ;
32
+ assert . isDefined ( hash , 'String hash should not be undefined' ) ;
33
+ hash = crypto . createHash ( 'hash' , 'string' ) ;
34
+ assert . isDefined ( hash , 'String hash should not be undefined' ) ;
35
+ hash = crypto . createHash ( 'HASH1' , 'string' ) ;
36
+ assert . isDefined ( hash , 'String hash should not be undefined' ) ;
37
+ } ) ;
38
+ test ( 'If hashFormat equals `number`, hashes with different data should return different number hashes' , async ( ) => {
39
+ const hash1 = crypto . createHash ( 'hash1' , 'number' ) ;
40
+ const hash2 = crypto . createHash ( 'hash2' , 'number' ) ;
41
+ assert . notEqual ( hash1 , hash2 , 'Hashes should be different numbers' ) ;
42
+ } ) ;
43
+ test ( 'If hashFormat equals `string`, hashes with different data should return different string hashes' , async ( ) => {
44
+ const hash1 = crypto . createHash ( 'hash1' , 'string' ) ;
45
+ const hash2 = crypto . createHash ( 'hash2' , 'string' ) ;
46
+ assert . notEqual ( hash1 , hash2 , 'Hashes should be different strings' ) ;
47
+ } ) ;
22
48
} ) ;
0 commit comments