@@ -21,6 +21,10 @@ describe('chunker: rabin', function () {
2121 return
2222 }
2323
24+ it ( 'Allows constructing without any options' , ( ) => {
25+ expect ( ( ) => rabin ( ) ) . to . not . throw ( )
26+ } )
27+
2428 it ( 'chunks non flat buffers' , async ( ) => {
2529 const b1 = new Uint8Array ( 2 * 256 )
2630 const b2 = new Uint8Array ( 1 * 256 )
@@ -96,19 +100,48 @@ describe('chunker: rabin', function () {
96100 }
97101 } )
98102
99- it ( 'throws when avg chunk size is not specified' , async ( ) => {
103+ it ( 'throws when invalid avg chunk size is specified' , async ( ) => {
100104 const opts = {
101- avgChunkSize : undefined
105+ avgChunkSize : 'fortytwo'
102106 }
103107
104108 try {
109+ // @ts -expect-error invalid input
105110 await all ( rabin ( opts ) ( asAsyncIterable ( [ ] ) ) )
106111 throw new Error ( 'Should have thrown' )
107112 } catch ( err : any ) {
108113 expect ( err . code ) . to . equal ( 'ERR_INVALID_AVG_CHUNK_SIZE' )
109114 }
110115 } )
111116
117+ it ( 'throws when invalid min chunk size is specified' , async ( ) => {
118+ const opts = {
119+ minChunkSize : 'fortytwo'
120+ }
121+
122+ try {
123+ // @ts -expect-error invalid input
124+ await all ( rabin ( opts ) ( asAsyncIterable ( [ ] ) ) )
125+ throw new Error ( 'Should have thrown' )
126+ } catch ( err : any ) {
127+ expect ( err . code ) . to . equal ( 'ERR_INVALID_CHUNK_SIZE' )
128+ }
129+ } )
130+
131+ it ( 'throws when invalid max chunk size is specified' , async ( ) => {
132+ const opts = {
133+ maxChunkSize : 'fortytwo'
134+ }
135+
136+ try {
137+ // @ts -expect-error invalid input
138+ await all ( rabin ( opts ) ( asAsyncIterable ( [ ] ) ) )
139+ throw new Error ( 'Should have thrown' )
140+ } catch ( err : any ) {
141+ expect ( err . code ) . to . equal ( 'ERR_INVALID_CHUNK_SIZE' )
142+ }
143+ } )
144+
112145 it ( 'uses the min chunk size when max and avg are too small' , async ( ) => {
113146 const file = uint8ArrayConcat ( [ rawFile , uint8ArrayFromString ( 'hello' ) ] )
114147 const opts = {
0 commit comments