@@ -26,6 +26,7 @@ import {
26
26
ComputeEngineCredential , RefreshTokenCredential
27
27
} from '../../../src/app/credential-internal' ;
28
28
import { FirestoreService , getFirestoreOptions } from '../../../src/firestore/firestore-internal' ;
29
+ import { DEFAULT_DATABASE_ID } from '@google-cloud/firestore/build/src/path' ;
29
30
30
31
describe ( 'Firestore' , ( ) => {
31
32
let mockApp : FirebaseApp ;
@@ -98,23 +99,25 @@ describe('Firestore', () => {
98
99
it ( `should throw given invalid app: ${ JSON . stringify ( invalidApp ) } ` , ( ) => {
99
100
expect ( ( ) => {
100
101
const firestoreAny : any = FirestoreService ;
101
- return new firestoreAny ( invalidApp ) ;
102
+ const firestoreService : FirestoreService = new firestoreAny ( invalidApp ) ;
103
+ return firestoreService . getDatabase ( DEFAULT_DATABASE_ID )
102
104
} ) . to . throw ( 'First argument passed to admin.firestore() must be a valid Firebase app instance.' ) ;
103
105
} ) ;
104
106
} ) ;
105
107
106
108
it ( 'should throw given no app' , ( ) => {
107
109
expect ( ( ) => {
108
110
const firestoreAny : any = FirestoreService ;
109
- return new firestoreAny ( ) ;
111
+ const firestoreService : FirestoreService = new firestoreAny ( ) ;
112
+ return firestoreService . getDatabase ( DEFAULT_DATABASE_ID )
110
113
} ) . to . throw ( 'First argument passed to admin.firestore() must be a valid Firebase app instance.' ) ;
111
114
} ) ;
112
115
113
116
it ( 'should throw given an invalid credential with project ID' , ( ) => {
114
117
// Project ID is read from the environment variable, but the credential is unsupported.
115
118
process . env . GOOGLE_CLOUD_PROJECT = 'project_id' ;
116
119
expect ( ( ) => {
117
- return new FirestoreService ( mockCredentialApp ) ;
120
+ return new FirestoreService ( mockCredentialApp ) . getDatabase ( DEFAULT_DATABASE_ID ) ;
118
121
} ) . to . throw ( invalidCredError ) ;
119
122
} ) ;
120
123
@@ -123,13 +126,13 @@ describe('Firestore', () => {
123
126
delete process . env . GOOGLE_CLOUD_PROJECT ;
124
127
delete process . env . GCLOUD_PROJECT ;
125
128
expect ( ( ) => {
126
- return new FirestoreService ( mockCredentialApp ) ;
129
+ return new FirestoreService ( mockCredentialApp ) . getDatabase ( DEFAULT_DATABASE_ID ) ;
127
130
} ) . to . throw ( invalidCredError ) ;
128
131
} ) ;
129
132
130
133
it ( 'should not throw given a valid app' , ( ) => {
131
134
expect ( ( ) => {
132
- return new FirestoreService ( mockApp ) ;
135
+ return new FirestoreService ( mockApp ) . getDatabase ( DEFAULT_DATABASE_ID ) ;
133
136
} ) . not . to . throw ( ) ;
134
137
} ) ;
135
138
@@ -139,7 +142,7 @@ describe('Firestore', () => {
139
142
delete process . env . GOOGLE_CLOUD_PROJECT ;
140
143
delete process . env . GCLOUD_PROJECT ;
141
144
expect ( ( ) => {
142
- return new FirestoreService ( config . app ) ;
145
+ return new FirestoreService ( config . app ) . getDatabase ( DEFAULT_DATABASE_ID ) ;
143
146
} ) . not . to . throw ( ) ;
144
147
} ) ;
145
148
} ) ;
@@ -158,19 +161,6 @@ describe('Firestore', () => {
158
161
} ) ;
159
162
} ) ;
160
163
161
- describe ( 'client' , ( ) => {
162
- it ( 'returns the client from the constructor' , ( ) => {
163
- // We expect referential equality here
164
- expect ( firestore . client ) . to . not . be . null ;
165
- } ) ;
166
-
167
- it ( 'is read-only' , ( ) => {
168
- expect ( ( ) => {
169
- firestore . client = mockApp ;
170
- } ) . to . throw ( 'Cannot set property client of #<FirestoreService> which has only a getter' ) ;
171
- } ) ;
172
- } ) ;
173
-
174
164
describe ( 'options.projectId' , ( ) => {
175
165
it ( 'should return a string when project ID is present in credential' , ( ) => {
176
166
const options = getFirestoreOptions ( mockApp ) ;
0 commit comments