@@ -216,21 +216,58 @@ describe('IndexedDBFileManager', () => {
216
216
} ) ;
217
217
218
218
it ( 'should register JSON data' , async ( ) => {
219
- const fileJson = {
219
+ const jsonFile = {
220
220
tableName : 'taxi-json' ,
221
221
fileName : 'taxi-json.parquet' ,
222
222
json : {
223
223
test : 'test' ,
224
224
} ,
225
225
} ;
226
226
227
- await fileManager . registerJSON ( fileJson ) ;
227
+ await fileManager . registerJSON ( jsonFile ) ;
228
228
229
229
const tableData = await indexedDB . tablesKey . toArray ( ) ;
230
230
const fileBufferData = await indexedDB . files . toArray ( ) ;
231
231
232
- tableData . some ( ( table ) => table . tableName === fileJson . tableName ) ;
233
- fileBufferData . some ( ( file ) => file . fileName === fileJson . fileName ) ;
232
+ expect (
233
+ tableData . some ( ( table ) => table . tableName === jsonFile . tableName )
234
+ ) . toBe ( true ) ;
235
+
236
+ expect (
237
+ fileBufferData . some ( ( file ) => file . fileName === jsonFile . fileName )
238
+ ) . toBe ( true ) ;
239
+ } ) ;
240
+
241
+ it ( 'should register multiple JSON data' , async ( ) => {
242
+ const jsonFiles = [
243
+ {
244
+ tableName : 'taxi-json-bulk' ,
245
+ fileName : 'taxi-json1.parquet' ,
246
+ json : {
247
+ test : 'test' ,
248
+ } ,
249
+ } ,
250
+ {
251
+ tableName : 'taxi-json-bulk' ,
252
+ fileName : 'taxi-json2.parquet' ,
253
+ json : {
254
+ test : 'test' ,
255
+ } ,
256
+ } ,
257
+ ] ;
258
+
259
+ await fileManager . bulkRegisterJSON ( jsonFiles ) ;
260
+
261
+ const tableData = await indexedDB . tablesKey . toArray ( ) ;
262
+ const fileBufferData = await indexedDB . files . toArray ( ) ;
263
+
264
+ expect (
265
+ tableData . some ( ( table ) => table . tableName === jsonFiles [ 0 ] . tableName )
266
+ ) . toBe ( true ) ;
267
+
268
+ expect ( fileBufferData . map ( ( file ) => file . fileName ) ) . toEqual (
269
+ expect . arrayContaining ( jsonFiles . map ( ( file ) => file . fileName ) )
270
+ ) ;
234
271
} ) ;
235
272
} ) ;
236
273
0 commit comments