@@ -60,9 +60,49 @@ describe('multihashing', () => {
60
60
} )
61
61
} )
62
62
63
- it ( 'throws on non implemented func' , ( ) => {
64
- multihashing ( new Buffer ( 'beep boop' ) , 'blake2b' , ( err ) => {
65
- expect ( err . message ) . to . match ( / n o t y e t s u p p o r t e d / )
63
+ it ( 'digest only, without length' , ( done ) => {
64
+ const buf = new Buffer ( 'beep boop' )
65
+
66
+ multihashing . digest ( buf , 'sha2-256' , ( err , digest ) => {
67
+ if ( err ) {
68
+ return done ( err )
69
+ }
70
+
71
+ expect (
72
+ digest
73
+ ) . to . be . eql (
74
+ new Buffer ( '90ea688e275d580567325032492b597bc77221c62493e76330b85ddda191ef7c' , 'hex' )
75
+ )
76
+
77
+ done ( )
78
+ } )
79
+ } )
80
+
81
+ describe ( 'invalid arguments' , ( ) => {
82
+ it ( 'returns an error on non implemented func' , ( done ) => {
83
+ multihashing ( new Buffer ( 'beep boop' ) , 'blake2b' , ( err ) => {
84
+ expect ( err . message ) . to . match ( / n o t y e t s u p p o r t e d / )
85
+ done ( )
86
+ } )
87
+ } )
88
+
89
+ it ( 'digest only, with length, returns error on non implmented func' , ( done ) => {
90
+ multihashing . digest ( new Buffer ( 'beep boop' ) , 'blake2b' , 10 , ( err ) => {
91
+ expect ( err . message ) . to . match ( / n o t y e t s u p p o r t e d / )
92
+ done ( )
93
+ } )
94
+ } )
95
+
96
+ it ( 'throws on missing callback' , ( ) => {
97
+ expect (
98
+ ( ) => multihashing ( new Buffer ( 'beep' ) , 'sha3' )
99
+ ) . to . throw ( / M i s s i n g c a l l b a c k / )
100
+ } )
101
+
102
+ it ( 'digest only, throws on missing callback' , ( ) => {
103
+ expect (
104
+ ( ) => multihashing . digest ( new Buffer ( 'beep' ) , 'sha3' )
105
+ ) . to . throw ( / M i s s i n g c a l l b a c k / )
66
106
} )
67
107
} )
68
108
} )
0 commit comments