@@ -23,36 +23,23 @@ import {
2323 DATA_CONNECT_ERROR_CODE_MAPPING ,
2424 FirebaseDataConnectError
2525} from '../../../src/data-connect/data-connect-api-client-internal' ;
26- import firebase , { FirebaseApp } from '@firebase/app-compat' ;
27- import { projectId } from '../../resources/mocks' ;
28- import { apiKey } from '../../integration/setup' ;
26+ import { App , initializeApp } from '../../../src/app' ;
27+ import { defaultAppStore } from '../../../src/app/lifecycle' ;
2928
3029interface IdVars {
3130 id : string
3231}
3332
3433describe ( 'validateAdminArgs()' , ( ) => {
35- let app : FirebaseApp ;
36- beforeEach ( ( ) => {
37- app = firebase . initializeApp ( {
38- apiKey,
39- authDomain : projectId + '.firebaseapp.com' ,
40- } ) ;
41- } ) ;
34+ let app : App ;
35+ let getDataConnectStub : sinon . SinonStub ;
4236
43- afterEach ( ( ) => {
44- app . delete ( ) ;
45- } ) ;
46-
4737 const connectorConfig : ConnectorConfig = {
4838 location : 'us-west2' ,
4939 serviceId : 'my-service' ,
5040 connector : 'my-connector' ,
5141 } ;
52- const stubDcInstance = { connectorConfig : connectorConfig , source : 'STUB' } as unknown as DataConnect ;
53- const getDataConnectStub = sinon . stub ( DataConnectService . prototype , 'getDataConnect' ) . returns (
54- stubDcInstance
55- ) ;
42+
5643 const providedDcInstance = { connectorConfig : connectorConfig , source : 'PROVIDED' } as unknown as DataConnect ;
5744 const variables : IdVars = { id : 'stephenarosaj' } ;
5845 const options : OperationOptions = { impersonate : { unauthenticated : true } } ;
@@ -62,6 +49,20 @@ describe('validateAdminArgs()', () => {
6249 'Variables required.'
6350 ) ;
6451
52+ const stubDcInstance = { connectorConfig : connectorConfig , source : 'STUB' } as unknown as DataConnect ;
53+ beforeEach ( ( ) => {
54+ getDataConnectStub = sinon . stub ( DataConnectService . prototype , 'getDataConnect' ) . returns ( stubDcInstance ) ;
55+
56+ // initializing app required, "using" it is required for successful build/compile
57+ app = initializeApp ( ) ;
58+ app . name ;
59+ } ) ;
60+
61+ afterEach ( ( ) => {
62+ getDataConnectStub . restore ( ) ;
63+ defaultAppStore . clearAllApps ( ) ;
64+ } ) ;
65+
6566 describe ( 'with no variadic args' , ( ) => {
6667 it ( 'should call getDataConnect to generate a DataConnect instance' , ( ) => {
6768 const { dc : dcInstance , vars : inputVars , options : inputOpts } = validateAdminArgs ( connectorConfig ) ;
@@ -215,9 +216,9 @@ describe('validateAdminArgs()', () => {
215216 } ) ;
216217
217218 it ( 'and the first argument is undefined variables' , ( ) => {
218- expect ( validateAdminArgs (
219- connectorConfig , undefined , undefined , undefined , true , true
220- ) ) . to . throw ( ) . and . have . property ( 'code' , invalidVariablesError . code ) ;
219+ expect ( ( ) => {
220+ validateAdminArgs ( connectorConfig , undefined , undefined , undefined , true , true ) ;
221+ } ) . to . throw ( ) . and . have . property ( 'code' , invalidVariablesError . code ) ;
221222 } ) ;
222223 } ) ;
223224 } ) ;
0 commit comments