Skip to content

Commit 926a617

Browse files
committed
Properly import DocumentReference in database.test.ts
1 parent 3df2e8e commit 926a617

File tree

4 files changed

+53
-15
lines changed

4 files changed

+53
-15
lines changed

integration/firestore/firebase_export.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,22 @@ export function usesFunctionalApi(): false {
5050
return false;
5151
}
5252

53-
const Firestore = firebase.firestore.Firestore;
53+
const Blob = firebase.firestore.Blob;
54+
const DocumentReference = firebase.firestore.DocumentReference;
5455
const FieldPath = firebase.firestore.FieldPath;
55-
const Timestamp = firebase.firestore.Timestamp;
56-
const GeoPoint = firebase.firestore.GeoPoint;
5756
const FieldValue = firebase.firestore.FieldValue;
58-
const Blob = firebase.firestore.Blob;
57+
const Firestore = firebase.firestore.Firestore;
58+
const GeoPoint = firebase.firestore.GeoPoint;
59+
const QueryDocumentSnapshot = firebase.firestore.QueryDocumentSnapshot;
60+
const Timestamp = firebase.firestore.Timestamp;
5961

60-
export { Firestore, FieldValue, FieldPath, Timestamp, Blob, GeoPoint };
62+
export {
63+
Blob,
64+
DocumentReference,
65+
FieldPath,
66+
FieldValue,
67+
Firestore,
68+
GeoPoint,
69+
QueryDocumentSnapshot,
70+
Timestamp
71+
};

integration/firestore/firebase_export_memory.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,22 @@ export function usesFunctionalApi(): false {
5050
return false;
5151
}
5252

53-
const Firestore = firebase.firestore.Firestore;
53+
const Blob = firebase.firestore.Blob;
54+
const DocumentReference = firebase.firestore.DocumentReference;
5455
const FieldPath = firebase.firestore.FieldPath;
55-
const Timestamp = firebase.firestore.Timestamp;
56-
const GeoPoint = firebase.firestore.GeoPoint;
5756
const FieldValue = firebase.firestore.FieldValue;
58-
const Blob = firebase.firestore.Blob;
57+
const Firestore = firebase.firestore.Firestore;
58+
const GeoPoint = firebase.firestore.GeoPoint;
59+
const QueryDocumentSnapshot = firebase.firestore.QueryDocumentSnapshot;
60+
const Timestamp = firebase.firestore.Timestamp;
5961

60-
export { Firestore, FieldValue, FieldPath, Timestamp, Blob, GeoPoint };
62+
export {
63+
Blob,
64+
DocumentReference,
65+
FieldPath,
66+
FieldValue,
67+
Firestore,
68+
GeoPoint,
69+
QueryDocumentSnapshot,
70+
Timestamp
71+
};

packages/firestore/test/integration/api/database.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ const newTestFirestore = firebaseExport.newTestFirestore;
3939
const Timestamp = firebaseExport.Timestamp;
4040
const FieldPath = firebaseExport.FieldPath;
4141
const FieldValue = firebaseExport.FieldValue;
42+
const DocumentReference = firebaseExport.DocumentReference;
43+
const QueryDocumentSnapshot = firebaseExport.QueryDocumentSnapshot;
4244

4345
const MEMORY_ONLY_BUILD =
4446
typeof process !== 'undefined' &&
@@ -1344,6 +1346,7 @@ apiDescribe('Database', (persistence: boolean) => {
13441346
snapshot: firestore.QueryDocumentSnapshot,
13451347
options: firestore.SnapshotOptions
13461348
): Post {
1349+
expect(snapshot).to.be.an.instanceof(QueryDocumentSnapshot);
13471350
const data = snapshot.data(options);
13481351
return new Post(data.title, data.author, snapshot.ref);
13491352
}
@@ -1602,7 +1605,7 @@ apiDescribe('Database', (persistence: boolean) => {
16021605
await docRef.set(new Post('post', 'author'));
16031606
const docSnapshot = await docRef.get();
16041607
const ref = docSnapshot.data()!.ref!;
1605-
//expect(ref).to.be.an.instanceof(firestore.DocumentReference);
1608+
expect(ref).to.be.an.instanceof(DocumentReference);
16061609
expect(untypedDocRef.isEqual(ref)).to.be.true;
16071610
});
16081611
});
@@ -1619,7 +1622,7 @@ apiDescribe('Database', (persistence: boolean) => {
16191622
const querySnapshot = await collection.get();
16201623
expect(querySnapshot.size).to.equal(1);
16211624
const ref = querySnapshot.docs[0].data().ref!;
1622-
//expect(ref).to.be.an.instanceof(firestore.DocumentReference);
1625+
expect(ref).to.be.an.instanceof(DocumentReference);
16231626
const untypedDocRef = untypedCollection.doc(docRef.id);
16241627
expect(untypedDocRef.isEqual(ref)).to.be.true;
16251628
});
@@ -1637,7 +1640,7 @@ apiDescribe('Database', (persistence: boolean) => {
16371640
const querySnapshot = await query.get();
16381641
expect(querySnapshot.size).to.equal(1);
16391642
const ref = querySnapshot.docs[0].data().ref!;
1640-
//expect(ref).to.be.an.instanceof(firestore.DocumentReference);
1643+
expect(ref).to.be.an.instanceof(DocumentReference);
16411644
expect(untypedDocRef.isEqual(ref)).to.be.true;
16421645
});
16431646
});

packages/firestore/test/integration/util/firebase_export.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ import { FirebaseApp } from '@firebase/app-types';
2525
import * as firestore from '@firebase/firestore-types';
2626

2727
import { Blob } from '../../../src/api/blob';
28-
import { Firestore } from '../../../src/api/database';
28+
import {
29+
Firestore,
30+
DocumentReference,
31+
QueryDocumentSnapshot
32+
} from '../../../src/api/database';
2933
import { FieldPath } from '../../../src/api/field_path';
3034
import { FieldValue } from '../../../src/api/field_value';
3135
import { GeoPoint } from '../../../src/api/geo_point';
@@ -68,4 +72,13 @@ export function newTestFirestore(
6872
return firestore;
6973
}
7074

71-
export { Firestore, FieldValue, FieldPath, Timestamp, Blob, GeoPoint };
75+
export {
76+
Firestore,
77+
FieldValue,
78+
FieldPath,
79+
Timestamp,
80+
Blob,
81+
GeoPoint,
82+
DocumentReference,
83+
QueryDocumentSnapshot
84+
};

0 commit comments

Comments
 (0)