@@ -53,8 +53,8 @@ describe('DataConnectApiClient', () => {
53
53
} ;
54
54
55
55
const noProjectId = 'Failed to determine project ID. Initialize the SDK with service '
56
- + 'account credentials or set project ID as an app option. Alternatively, set the '
57
- + 'GOOGLE_CLOUD_PROJECT environment variable.' ;
56
+ + 'account credentials or set project ID as an app option. Alternatively, set the '
57
+ + 'GOOGLE_CLOUD_PROJECT environment variable.' ;
58
58
59
59
const TEST_RESPONSE = {
60
60
data : {
@@ -75,7 +75,7 @@ describe('DataConnectApiClient', () => {
75
75
location : 'us-west2' ,
76
76
serviceId : 'my-service' ,
77
77
connector : 'mock-connector'
78
- } ;
78
+ } ;
79
79
80
80
const clientWithoutProjectId = new DataConnectApiClient (
81
81
connectorConfig ,
@@ -232,7 +232,7 @@ describe('DataConnectApiClient', () => {
232
232
method : 'POST' ,
233
233
url : `https://firebasedataconnect.googleapis.com/v1alpha/projects/test-project/locations/${ connectorConfig . location } /services/${ connectorConfig . serviceId } :executeGraphql` ,
234
234
headers : EXPECTED_HEADERS ,
235
- data : { query : 'query' }
235
+ data : { query : 'query' }
236
236
} ) ;
237
237
} ) ;
238
238
} ) ;
@@ -301,7 +301,7 @@ describe('DataConnectApiClient', () => {
301
301
302
302
describe ( 'executeQuery' , ( ) => {
303
303
it ( 'should reject when project id is not available' , ( ) => {
304
- return clientWithoutProjectIdWithConnector . executeQuery ( { operationName : 'getById' } )
304
+ return clientWithoutProjectIdWithConnector . executeQuery ( { operationName : 'getById' } )
305
305
. should . eventually . be . rejectedWith ( noProjectId ) ;
306
306
} ) ;
307
307
@@ -334,7 +334,7 @@ describe('DataConnectApiClient', () => {
334
334
. stub ( HttpClient . prototype , 'send' )
335
335
. rejects ( utils . errorFrom ( ERROR_RESPONSE , 404 ) ) ;
336
336
const expected = new FirebaseDataConnectError ( 'not-found' , 'Requested entity not found' ) ;
337
- return apiClientWithConnector . executeQuery ( { operationName : 'getById' } )
337
+ return apiClientWithConnector . executeQuery ( { operationName : 'getById' } )
338
338
. should . eventually . be . rejected . and . deep . include ( expected ) ;
339
339
} ) ;
340
340
@@ -343,7 +343,7 @@ describe('DataConnectApiClient', () => {
343
343
. stub ( HttpClient . prototype , 'send' )
344
344
. rejects ( utils . errorFrom ( { } , 404 ) ) ;
345
345
const expected = new FirebaseDataConnectError ( 'unknown-error' , 'Unknown server error: {}' ) ;
346
- return apiClientWithConnector . executeQuery ( { operationName : 'getById' } )
346
+ return apiClientWithConnector . executeQuery ( { operationName : 'getById' } )
347
347
. should . eventually . be . rejected . and . deep . include ( expected ) ;
348
348
} ) ;
349
349
@@ -353,7 +353,7 @@ describe('DataConnectApiClient', () => {
353
353
. rejects ( utils . errorFrom ( 'not json' , 404 ) ) ;
354
354
const expected = new FirebaseDataConnectError (
355
355
'unknown-error' , 'Unexpected response with status: 404 and body: not json' ) ;
356
- return apiClientWithConnector . executeQuery ( { operationName : 'getById' } )
356
+ return apiClientWithConnector . executeQuery ( { operationName : 'getById' } )
357
357
. should . eventually . be . rejected . and . deep . include ( expected ) ;
358
358
} ) ;
359
359
@@ -362,7 +362,7 @@ describe('DataConnectApiClient', () => {
362
362
sandbox
363
363
. stub ( HttpClient . prototype , 'send' )
364
364
. rejects ( expected ) ;
365
- return apiClientWithConnector . executeQuery ( { operationName : 'getById' } )
365
+ return apiClientWithConnector . executeQuery ( { operationName : 'getById' } )
366
366
. should . eventually . be . rejected . and . deep . include ( expected ) ;
367
367
} ) ;
368
368
@@ -379,7 +379,7 @@ describe('DataConnectApiClient', () => {
379
379
const stub = sandbox
380
380
. stub ( HttpClient . prototype , 'send' )
381
381
. resolves ( utils . responseFrom ( TEST_RESPONSE , 200 ) ) ;
382
- return apiClientWithConnector . executeQuery < UsersResponse , unknown > ( { operationName : 'getById' } )
382
+ return apiClientWithConnector . executeQuery < UsersResponse , unknown > ( { operationName : 'getById' } )
383
383
. then ( ( resp ) => {
384
384
expect ( resp . data . users ) . to . be . not . empty ;
385
385
expect ( resp . data . users [ 0 ] . name ) . to . be . not . undefined ;
@@ -389,7 +389,7 @@ describe('DataConnectApiClient', () => {
389
389
method : 'POST' ,
390
390
url : `https://firebasedataconnect.googleapis.com/v1alpha/projects/test-project/locations/${ connectorConfig_with_connector . location } /services/${ connectorConfig_with_connector . serviceId } /connectors/${ connectorConfig_with_connector . connector } :executeQuery` ,
391
391
headers : EXPECTED_HEADERS ,
392
- data : { query : undefined , name : 'getById' , operationName : 'getById' }
392
+ data : { query : undefined , name : 'getById' , operationName : 'getById' }
393
393
} ) ;
394
394
} ) ;
395
395
} ) ;
@@ -407,7 +407,7 @@ describe('DataConnectApiClient', () => {
407
407
const stub = sandbox
408
408
. stub ( HttpClient . prototype , 'send' )
409
409
. resolves ( utils . responseFrom ( TEST_RESPONSE , 200 ) ) ;
410
- return apiClientWithConnector . executeQuery < UsersResponse , unknown > ( { operationName : 'getById' , variables : { } } )
410
+ return apiClientWithConnector . executeQuery < UsersResponse , unknown > ( { operationName : 'getById' , variables : { } } )
411
411
. then ( ( resp ) => {
412
412
expect ( resp . data . users ) . to . be . not . empty ;
413
413
expect ( resp . data . users [ 0 ] . name ) . to . be . not . undefined ;
@@ -417,7 +417,7 @@ describe('DataConnectApiClient', () => {
417
417
method : 'POST' ,
418
418
url : `https://firebasedataconnect.googleapis.com/v1alpha/projects/test-project/locations/${ connectorConfig_with_connector . location } /services/${ connectorConfig_with_connector . serviceId } /connectors/${ connectorConfig_with_connector . connector } :executeQuery` ,
419
419
headers : EXPECTED_HEADERS ,
420
- data : { query : undefined , name : 'getById' , operationName : 'getById' , variables : { } }
420
+ data : { query : undefined , name : 'getById' , operationName : 'getById' , variables : { } }
421
421
} ) ;
422
422
} ) ;
423
423
} ) ;
@@ -427,21 +427,21 @@ describe('DataConnectApiClient', () => {
427
427
const stub = sandbox
428
428
. stub ( HttpClient . prototype , 'send' )
429
429
. resolves ( utils . responseFrom ( TEST_RESPONSE , 200 ) ) ;
430
- return apiClientWithConnector . executeQuery ( { operationName : 'getById' } )
430
+ return apiClientWithConnector . executeQuery ( { operationName : 'getById' } )
431
431
. then ( ( ) => {
432
432
expect ( stub ) . to . have . been . calledOnce . and . calledWith ( {
433
433
method : 'POST' ,
434
434
url : `http://localhost:9399/v1alpha/projects/test-project/locations/${ connectorConfig_with_connector . location } /services/${ connectorConfig_with_connector . serviceId } /connectors/${ connectorConfig_with_connector . connector } :executeQuery` ,
435
435
headers : EMULATOR_EXPECTED_HEADERS ,
436
- data : { query : undefined , name : 'getById' , operationName : 'getById' }
436
+ data : { query : undefined , name : 'getById' , operationName : 'getById' }
437
437
} ) ;
438
438
} ) ;
439
439
} ) ;
440
440
} ) ;
441
-
441
+
442
442
describe ( 'executeMutation' , ( ) => {
443
443
it ( 'should reject when project id is not available' , ( ) => {
444
- return clientWithoutProjectIdWithConnector . executeMutation ( { operationName : 'getById' } )
444
+ return clientWithoutProjectIdWithConnector . executeMutation ( { operationName : 'getById' } )
445
445
. should . eventually . be . rejectedWith ( noProjectId ) ;
446
446
} ) ;
447
447
@@ -474,7 +474,7 @@ describe('DataConnectApiClient', () => {
474
474
. stub ( HttpClient . prototype , 'send' )
475
475
. rejects ( utils . errorFrom ( ERROR_RESPONSE , 404 ) ) ;
476
476
const expected = new FirebaseDataConnectError ( 'not-found' , 'Requested entity not found' ) ;
477
- return apiClientWithConnector . executeMutation ( { operationName : 'getById' } )
477
+ return apiClientWithConnector . executeMutation ( { operationName : 'getById' } )
478
478
. should . eventually . be . rejected . and . deep . include ( expected ) ;
479
479
} ) ;
480
480
@@ -483,7 +483,7 @@ describe('DataConnectApiClient', () => {
483
483
. stub ( HttpClient . prototype , 'send' )
484
484
. rejects ( utils . errorFrom ( { } , 404 ) ) ;
485
485
const expected = new FirebaseDataConnectError ( 'unknown-error' , 'Unknown server error: {}' ) ;
486
- return apiClientWithConnector . executeMutation ( { operationName : 'getById' } )
486
+ return apiClientWithConnector . executeMutation ( { operationName : 'getById' } )
487
487
. should . eventually . be . rejected . and . deep . include ( expected ) ;
488
488
} ) ;
489
489
@@ -493,7 +493,7 @@ describe('DataConnectApiClient', () => {
493
493
. rejects ( utils . errorFrom ( 'not json' , 404 ) ) ;
494
494
const expected = new FirebaseDataConnectError (
495
495
'unknown-error' , 'Unexpected response with status: 404 and body: not json' ) ;
496
- return apiClientWithConnector . executeMutation ( { operationName : 'getById' } )
496
+ return apiClientWithConnector . executeMutation ( { operationName : 'getById' } )
497
497
. should . eventually . be . rejected . and . deep . include ( expected ) ;
498
498
} ) ;
499
499
@@ -502,7 +502,7 @@ describe('DataConnectApiClient', () => {
502
502
sandbox
503
503
. stub ( HttpClient . prototype , 'send' )
504
504
. rejects ( expected ) ;
505
- return apiClientWithConnector . executeMutation ( { operationName : 'getById' } )
505
+ return apiClientWithConnector . executeMutation ( { operationName : 'getById' } )
506
506
. should . eventually . be . rejected . and . deep . include ( expected ) ;
507
507
} ) ;
508
508
@@ -519,7 +519,7 @@ describe('DataConnectApiClient', () => {
519
519
const stub = sandbox
520
520
. stub ( HttpClient . prototype , 'send' )
521
521
. resolves ( utils . responseFrom ( TEST_RESPONSE , 200 ) ) ;
522
- return apiClientWithConnector . executeMutation < UsersResponse , unknown > ( { operationName : 'getById' } )
522
+ return apiClientWithConnector . executeMutation < UsersResponse , unknown > ( { operationName : 'getById' } )
523
523
. then ( ( resp ) => {
524
524
expect ( resp . data . users ) . to . be . not . empty ;
525
525
expect ( resp . data . users [ 0 ] . name ) . to . be . not . undefined ;
@@ -529,7 +529,7 @@ describe('DataConnectApiClient', () => {
529
529
method : 'POST' ,
530
530
url : `https://firebasedataconnect.googleapis.com/v1alpha/projects/test-project/locations/${ connectorConfig_with_connector . location } /services/${ connectorConfig_with_connector . serviceId } /connectors/${ connectorConfig_with_connector . connector } :executeMutation` ,
531
531
headers : EXPECTED_HEADERS ,
532
- data : { query : undefined , name : 'getById' , operationName : 'getById' }
532
+ data : { query : undefined , name : 'getById' , operationName : 'getById' }
533
533
} ) ;
534
534
} ) ;
535
535
} ) ;
@@ -547,7 +547,7 @@ describe('DataConnectApiClient', () => {
547
547
const stub = sandbox
548
548
. stub ( HttpClient . prototype , 'send' )
549
549
. resolves ( utils . responseFrom ( TEST_RESPONSE , 200 ) ) ;
550
- return apiClientWithConnector . executeMutation < UsersResponse , unknown > ( { operationName : 'getById' , variables : { } } )
550
+ return apiClientWithConnector . executeMutation < UsersResponse , unknown > ( { operationName : 'getById' , variables : { } } )
551
551
. then ( ( resp ) => {
552
552
expect ( resp . data . users ) . to . be . not . empty ;
553
553
expect ( resp . data . users [ 0 ] . name ) . to . be . not . undefined ;
@@ -557,7 +557,7 @@ describe('DataConnectApiClient', () => {
557
557
method : 'POST' ,
558
558
url : `https://firebasedataconnect.googleapis.com/v1alpha/projects/test-project/locations/${ connectorConfig_with_connector . location } /services/${ connectorConfig_with_connector . serviceId } /connectors/${ connectorConfig_with_connector . connector } :executeMutation` ,
559
559
headers : EXPECTED_HEADERS ,
560
- data : { query : undefined , name : 'getById' , operationName : 'getById' , variables : { } }
560
+ data : { query : undefined , name : 'getById' , operationName : 'getById' , variables : { } }
561
561
} ) ;
562
562
} ) ;
563
563
} ) ;
@@ -567,13 +567,13 @@ describe('DataConnectApiClient', () => {
567
567
const stub = sandbox
568
568
. stub ( HttpClient . prototype , 'send' )
569
569
. resolves ( utils . responseFrom ( TEST_RESPONSE , 200 ) ) ;
570
- return apiClientWithConnector . executeMutation ( { operationName : 'getById' } )
570
+ return apiClientWithConnector . executeMutation ( { operationName : 'getById' } )
571
571
. then ( ( ) => {
572
572
expect ( stub ) . to . have . been . calledOnce . and . calledWith ( {
573
573
method : 'POST' ,
574
574
url : `http://localhost:9399/v1alpha/projects/test-project/locations/${ connectorConfig_with_connector . location } /services/${ connectorConfig_with_connector . serviceId } /connectors/${ connectorConfig_with_connector . connector } :executeMutation` ,
575
575
headers : EMULATOR_EXPECTED_HEADERS ,
576
- data : { query : undefined , name : 'getById' , operationName : 'getById' }
576
+ data : { query : undefined , name : 'getById' , operationName : 'getById' }
577
577
} ) ;
578
578
} ) ;
579
579
} ) ;
@@ -708,11 +708,11 @@ describe('DataConnectApiClient CRUD helpers', () => {
708
708
. 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 ./ ) ;
709
709
} ) ;
710
710
711
- it ( 'should throw FirebaseDataConnectError for array data' , async ( ) => {
711
+ it ( 'should throw FirebaseDataConnectError for array data' , async ( ) => {
712
712
await expect ( apiClient . insert ( tableName , [ ] ) )
713
713
. 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 ./ ) ;
714
714
} ) ;
715
-
715
+
716
716
it ( 'should amend the message for query errors' , async ( ) => {
717
717
await expect ( apiClientQueryError . insert ( tableName , { data : 1 } ) )
718
718
. to . be . rejectedWith ( FirebaseDataConnectError , `${ serverErrorString } . ${ additionalErrorMessageForBulkImport } ` ) ;
0 commit comments