@@ -21,6 +21,10 @@ describe('chunker: rabin', function () {
21
21
return
22
22
}
23
23
24
+ it ( 'Allows constructing without any options' , ( ) => {
25
+ expect ( ( ) => rabin ( ) ) . to . not . throw ( )
26
+ } )
27
+
24
28
it ( 'chunks non flat buffers' , async ( ) => {
25
29
const b1 = new Uint8Array ( 2 * 256 )
26
30
const b2 = new Uint8Array ( 1 * 256 )
@@ -96,19 +100,48 @@ describe('chunker: rabin', function () {
96
100
}
97
101
} )
98
102
99
- it ( 'throws when avg chunk size is not specified' , async ( ) => {
103
+ it ( 'throws when invalid avg chunk size is specified' , async ( ) => {
100
104
const opts = {
101
- avgChunkSize : undefined
105
+ avgChunkSize : 'fortytwo'
102
106
}
103
107
104
108
try {
109
+ // @ts -expect-error invalid input
105
110
await all ( rabin ( opts ) ( asAsyncIterable ( [ ] ) ) )
106
111
throw new Error ( 'Should have thrown' )
107
112
} catch ( err : any ) {
108
113
expect ( err . code ) . to . equal ( 'ERR_INVALID_AVG_CHUNK_SIZE' )
109
114
}
110
115
} )
111
116
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
+
112
145
it ( 'uses the min chunk size when max and avg are too small' , async ( ) => {
113
146
const file = uint8ArrayConcat ( [ rawFile , uint8ArrayFromString ( 'hello' ) ] )
114
147
const opts = {
0 commit comments