File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -154,3 +154,10 @@ common.expectsError(
154154 message : 'The "algorithm" argument must be of type string'
155155 }
156156) ;
157+
158+ {
159+ const Hash = crypto . Hash ;
160+ const instance = crypto . Hash ( 'sha256' ) ;
161+ assert ( instance instanceof Hash , 'Hash is expected to return a new instance' +
162+ ' when called without `new`' ) ;
163+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,30 @@ if (!common.hasCrypto)
66const assert = require ( 'assert' ) ;
77const crypto = require ( 'crypto' ) ;
88
9+ {
10+ const Hmac = crypto . Hmac ;
11+ const instance = crypto . Hmac ( 'sha256' , 'Node' ) ;
12+ assert ( instance instanceof Hmac , 'Hmac is expected to return a new instance' +
13+ ' when called without `new`' ) ;
14+ }
15+
16+ common . expectsError (
17+ ( ) => crypto . createHmac ( null ) ,
18+ {
19+ code : 'ERR_INVALID_ARG_TYPE' ,
20+ type : TypeError ,
21+ message : 'The "hmac" argument must be of type string'
22+ } ) ;
23+
24+ common . expectsError (
25+ ( ) => crypto . createHmac ( 'sha1' , null ) ,
26+ {
27+ code : 'ERR_INVALID_ARG_TYPE' ,
28+ type : TypeError ,
29+ message : 'The "key" argument must be one of type string, TypedArray, or ' +
30+ 'DataView'
31+ } ) ;
32+
933{
1034 // Test HMAC
1135 const actual = crypto . createHmac ( 'sha1' , 'Node' )
You can’t perform that action at this time.
0 commit comments