@@ -247,7 +247,8 @@ describe('DataConnectApiClient CRUD helpers', () => {
247247 projectId : 'test-project-crud' ,
248248 } ;
249249
250- const testTableName = 'TestTable' ;
250+ const tableName = 'TestTable' ;
251+ const formatedTableName = 'testTable' ;
251252
252253 // Helper function to normalize GraphQL strings
253254 const normalizeGraphQLString = ( str : string ) : string => {
@@ -275,25 +276,25 @@ describe('DataConnectApiClient CRUD helpers', () => {
275276 const simpleData = { name : 'test' , value : 123 } ;
276277 const expectedMutation = `
277278 mutation {
278- ${ testTableName } _insert(data: {
279+ ${ formatedTableName } _insert(data: {
279280 name: "test",
280281 value: 123
281282 })
282283 }` ;
283- await apiClient . insert ( testTableName , simpleData ) ;
284+ await apiClient . insert ( tableName , simpleData ) ;
284285 expect ( executeGraphqlStub ) . to . have . been . calledOnceWithExactly ( normalizeGraphQLString ( expectedMutation ) ) ;
285286 } ) ;
286287
287288 it ( 'should call executeGraphql with the correct mutation for complex data' , async ( ) => {
288289 const complexData = { id : 'abc' , active : true , scores : [ 10 , 20 ] , info : { nested : 'yes/no "quote" \\slash\\' } } ;
289290 const expectedMutation = `
290291 mutation {
291- ${ testTableName } _insert(data: {
292+ ${ formatedTableName } _insert(data: {
292293 id: "abc", active: true, scores: [10, 20],
293294 info: { nested: "yes/no \\"quote\\" \\\\slash\\\\" }
294295 })
295296 }` ;
296- await apiClient . insert ( testTableName , complexData ) ;
297+ await apiClient . insert ( tableName , complexData ) ;
297298 expect ( executeGraphqlStub ) . to . have . been . calledOnceWithExactly ( normalizeGraphQLString ( expectedMutation ) ) ;
298299 } ) ;
299300
@@ -312,15 +313,15 @@ describe('DataConnectApiClient CRUD helpers', () => {
312313 } ;
313314 const expectedMutation = `
314315 mutation {
315- ${ testTableName } _insert(data: {
316+ ${ formatedTableName } _insert(data: {
316317 genre: "Action",
317318 title: "Die Hard",
318319 ratings: null,
319320 director: {},
320321 extras: [1, null, "hello", null, { a: 1 }]
321322 })
322323 }` ;
323- await apiClient . insert ( testTableName , dataWithUndefined ) ;
324+ await apiClient . insert ( tableName , dataWithUndefined ) ;
324325 expect ( executeGraphqlStub ) . to . have . been . calledOnceWithExactly ( normalizeGraphQLString ( expectedMutation ) ) ;
325326 } ) ;
326327
@@ -330,12 +331,12 @@ describe('DataConnectApiClient CRUD helpers', () => {
330331 } ) ;
331332
332333 it ( 'should throw FirebaseDataConnectError for null data' , async ( ) => {
333- await expect ( apiClient . insert ( testTableName , null as any ) )
334+ await expect ( apiClient . insert ( tableName , null as any ) )
334335 . to . be . rejectedWith ( FirebaseDataConnectError , / ` d a t a ` m u s t b e a n o n - n u l l o b j e c t ./ ) ;
335336 } ) ;
336337
337338 it ( 'should throw FirebaseDataConnectError for array data' , async ( ) => {
338- await expect ( apiClient . insert ( testTableName , [ ] ) )
339+ await expect ( apiClient . insert ( tableName , [ ] ) )
339340 . to . be . rejectedWith ( FirebaseDataConnectError , / ` d a t a ` m u s t b e a n o b j e c t , n o t a n a r r a y , f o r s i n g l e i n s e r t ./ ) ;
340341 } ) ;
341342 } ) ;
@@ -346,8 +347,8 @@ describe('DataConnectApiClient CRUD helpers', () => {
346347 const simpleDataArray = [ { name : 'test1' } , { name : 'test2' , value : 456 } ] ;
347348 const expectedMutation = `
348349 mutation {
349- ${ testTableName } _insertMany(data: [{ name: "test1" }, { name: "test2", value: 456 }]) }` ;
350- await apiClient . insertMany ( testTableName , simpleDataArray ) ;
350+ ${ formatedTableName } _insertMany(data: [{ name: "test1" }, { name: "test2", value: 456 }]) }` ;
351+ await apiClient . insertMany ( tableName , simpleDataArray ) ;
351352 expect ( executeGraphqlStub ) . to . have . been . calledOnceWithExactly ( normalizeGraphQLString ( expectedMutation ) ) ;
352353 } ) ;
353354
@@ -358,10 +359,10 @@ describe('DataConnectApiClient CRUD helpers', () => {
358359 ] ;
359360 const expectedMutation = `
360361 mutation {
361- ${ testTableName } _insertMany(data:
362+ ${ formatedTableName } _insertMany(data:
362363 [{ id: "a", active: true, info: { nested: "n1 \\"quote\\"" } }, { id: "b", scores: [1, 2],
363364 info: { nested: "n2/\\\\" } }]) }` ;
364- await apiClient . insertMany ( testTableName , complexDataArray ) ;
365+ await apiClient . insertMany ( tableName , complexDataArray ) ;
365366 expect ( executeGraphqlStub ) . to . have . been . calledOnceWithExactly ( normalizeGraphQLString ( expectedMutation ) ) ;
366367 } ) ;
367368
@@ -371,17 +372,17 @@ describe('DataConnectApiClient CRUD helpers', () => {
371372 } ) ;
372373
373374 it ( 'should throw FirebaseDataConnectError for null data' , ( ) => {
374- expect ( apiClient . insertMany ( testTableName , null as any ) )
375+ expect ( apiClient . insertMany ( tableName , null as any ) )
375376 . to . be . rejectedWith ( FirebaseDataConnectError , / ` d a t a ` m u s t b e a n o n - e m p t y a r r a y f o r i n s e r t M a n y ./ ) ;
376377 } ) ;
377378
378379 it ( 'should throw FirebaseDataConnectError for empty array data' , ( ) => {
379- expect ( apiClient . insertMany ( testTableName , [ ] ) )
380+ expect ( apiClient . insertMany ( tableName , [ ] ) )
380381 . to . be . rejectedWith ( FirebaseDataConnectError , / ` d a t a ` m u s t b e a n o n - e m p t y a r r a y f o r i n s e r t M a n y ./ ) ;
381382 } ) ;
382383
383384 it ( 'should throw FirebaseDataConnectError for non-array data' , ( ) => {
384- expect ( apiClient . insertMany ( testTableName , { data : 1 } as any ) )
385+ expect ( apiClient . insertMany ( tableName , { data : 1 } as any ) )
385386 . to . be . rejectedWith ( FirebaseDataConnectError , / ` d a t a ` m u s t b e a n o n - e m p t y a r r a y f o r i n s e r t M a n y ./ ) ;
386387 } ) ;
387388 } ) ;
@@ -390,18 +391,18 @@ describe('DataConnectApiClient CRUD helpers', () => {
390391 describe ( 'upsert()' , ( ) => {
391392 it ( 'should call executeGraphql with the correct mutation for simple data' , async ( ) => {
392393 const simpleData = { id : 'key1' , value : 'updated' } ;
393- const expectedMutation = `mutation { ${ testTableName } _upsert(data: { id: "key1", value: "updated" }) }` ;
394- await apiClient . upsert ( testTableName , simpleData ) ;
394+ const expectedMutation = `mutation { ${ formatedTableName } _upsert(data: { id: "key1", value: "updated" }) }` ;
395+ await apiClient . upsert ( tableName , simpleData ) ;
395396 expect ( executeGraphqlStub ) . to . have . been . calledOnceWithExactly ( expectedMutation ) ;
396397 } ) ;
397398
398399 it ( 'should call executeGraphql with the correct mutation for complex data' , async ( ) => {
399400 const complexData = { id : 'key2' , active : false , items : [ 1 , null ] , detail : { status : 'done/\\' } } ;
400401 // Note: Matching specific escaping: / -> \\, ' -> \'
401402 const expectedMutation = `
402- mutation { ${ testTableName } _upsert(data:
403+ mutation { ${ formatedTableName } _upsert(data:
403404 { id: "key2", active: false, items: [1, null], detail: { status: "done/\\\\" } }) }` ;
404- await apiClient . upsert ( testTableName , complexData ) ;
405+ await apiClient . upsert ( tableName , complexData ) ;
405406 expect ( executeGraphqlStub ) . to . have . been . calledOnceWithExactly ( normalizeGraphQLString ( expectedMutation ) ) ;
406407 } ) ;
407408
@@ -411,12 +412,12 @@ describe('DataConnectApiClient CRUD helpers', () => {
411412 } ) ;
412413
413414 it ( 'should throw FirebaseDataConnectError for null data' , async ( ) => {
414- await expect ( apiClient . upsert ( testTableName , null as any ) )
415+ await expect ( apiClient . upsert ( tableName , null as any ) )
415416 . to . be . rejectedWith ( FirebaseDataConnectError , / ` d a t a ` m u s t b e a n o n - n u l l o b j e c t ./ ) ;
416417 } ) ;
417418
418419 it ( 'should throw FirebaseDataConnectError for array data' , async ( ) => {
419- await expect ( apiClient . upsert ( testTableName , [ { data : 1 } ] ) )
420+ await expect ( apiClient . upsert ( tableName , [ { data : 1 } ] ) )
420421 . to . be . rejectedWith ( FirebaseDataConnectError , / ` d a t a ` m u s t b e a n o b j e c t , n o t a n a r r a y , f o r s i n g l e u p s e r t ./ ) ;
421422 } ) ;
422423 } ) ;
@@ -426,8 +427,8 @@ describe('DataConnectApiClient CRUD helpers', () => {
426427 it ( 'should call executeGraphql with the correct mutation for simple data array' , async ( ) => {
427428 const simpleDataArray = [ { id : 'k1' } , { id : 'k2' , value : 99 } ] ;
428429 const expectedMutation = `
429- mutation { ${ testTableName } _upsertMany(data: [{ id: "k1" }, { id: "k2", value: 99 }]) }` ;
430- await apiClient . upsertMany ( testTableName , simpleDataArray ) ;
430+ mutation { ${ formatedTableName } _upsertMany(data: [{ id: "k1" }, { id: "k2", value: 99 }]) }` ;
431+ await apiClient . upsertMany ( tableName , simpleDataArray ) ;
431432 expect ( executeGraphqlStub ) . to . have . been . calledOnceWithExactly ( normalizeGraphQLString ( expectedMutation ) ) ;
432433 } ) ;
433434
@@ -437,9 +438,9 @@ describe('DataConnectApiClient CRUD helpers', () => {
437438 { id : 'y' , scores : [ null , 2 ] }
438439 ] ;
439440 const expectedMutation = `
440- mutation { ${ testTableName } _upsertMany(data:
441+ mutation { ${ formatedTableName } _upsertMany(data:
441442 [{ id: "x", active: true, info: { nested: "n1/\\\\\\"x" } }, { id: "y", scores: [null, 2] }]) }` ;
442- await apiClient . upsertMany ( testTableName , complexDataArray ) ;
443+ await apiClient . upsertMany ( tableName , complexDataArray ) ;
443444 expect ( executeGraphqlStub ) . to . have . been . calledOnceWithExactly ( normalizeGraphQLString ( expectedMutation ) ) ;
444445 } ) ;
445446
@@ -449,17 +450,17 @@ describe('DataConnectApiClient CRUD helpers', () => {
449450 } ) ;
450451
451452 it ( 'should throw FirebaseDataConnectError for null data' , async ( ) => {
452- expect ( apiClient . upsertMany ( testTableName , null as any ) )
453+ expect ( apiClient . upsertMany ( tableName , null as any ) )
453454 . to . be . rejectedWith ( FirebaseDataConnectError , / ` d a t a ` m u s t b e a n o n - e m p t y a r r a y f o r u p s e r t M a n y ./ ) ;
454455 } ) ;
455456
456457 it ( 'should throw FirebaseDataConnectError for empty array data' , async ( ) => {
457- expect ( apiClient . upsertMany ( testTableName , [ ] ) )
458+ expect ( apiClient . upsertMany ( tableName , [ ] ) )
458459 . to . be . rejectedWith ( FirebaseDataConnectError , / ` d a t a ` m u s t b e a n o n - e m p t y a r r a y f o r u p s e r t M a n y ./ ) ;
459460 } ) ;
460461
461462 it ( 'should throw FirebaseDataConnectError for non-array data' , async ( ) => {
462- await expect ( apiClient . upsertMany ( testTableName , { data : 1 } as any ) )
463+ await expect ( apiClient . upsertMany ( tableName , { data : 1 } as any ) )
463464 . to . be . rejectedWith ( FirebaseDataConnectError , / ` d a t a ` m u s t b e a n o n - e m p t y a r r a y f o r u p s e r t M a n y ./ ) ;
464465 } ) ;
465466 } ) ;
0 commit comments