@react-native-firebase/firestore 21.7.0 → 21.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +1 -1
- package/__tests__/firestore.test.ts +707 -5
- package/ios/RNFBFirestore/RNFBFirestoreCollectionModule.m +12 -1
- package/lib/FirestoreDocumentChange.js +4 -2
- package/lib/FirestoreDocumentReference.js +13 -7
- package/lib/FirestoreQuery.js +46 -30
- package/lib/FirestoreQuerySnapshot.js +4 -1
- package/lib/FirestoreStatics.js +4 -3
- package/lib/FirestoreTransaction.js +2 -2
- package/lib/index.d.ts +0 -1
- package/lib/index.js +11 -8
- package/lib/modular/index.d.ts +86 -0
- package/lib/modular/index.js +43 -24
- package/lib/modular/query.js +9 -9
- package/lib/modular/snapshot.js +3 -1
- package/lib/version.js +1 -1
- package/lib/web/RNFBFirestoreModule.js +2 -2
- package/package.json +3 -3
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
import { describe, expect, it } from '@jest/globals';
|
|
1
|
+
import { describe, expect, it, jest, beforeEach } from '@jest/globals';
|
|
2
|
+
// @ts-ignore test
|
|
3
|
+
import { createDeprecationProxy } from '../../app/lib/common';
|
|
4
|
+
// @ts-ignore test
|
|
5
|
+
import FirebaseModule from '../../app/lib/internal/FirebaseModule';
|
|
6
|
+
// @ts-ignore test
|
|
7
|
+
import FirestoreQuery from '../lib/FirestoreQuery';
|
|
8
|
+
// @ts-ignore test
|
|
9
|
+
import FirestoreDocumentSnapshot from '../lib/FirestoreDocumentSnapshot';
|
|
10
|
+
// @ts-ignore test
|
|
11
|
+
import * as nativeModule from '@react-native-firebase/app/lib/internal/nativeModuleAndroidIos';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
createCheckV9Deprecation,
|
|
15
|
+
CheckV9DeprecationFunction,
|
|
16
|
+
} from '../../app/lib/common/unitTestUtils';
|
|
2
17
|
|
|
3
18
|
import firestore, {
|
|
4
19
|
firebase,
|
|
20
|
+
connectFirestoreEmulator,
|
|
5
21
|
Filter,
|
|
6
22
|
getFirestore,
|
|
7
23
|
getAggregateFromServer,
|
|
@@ -17,6 +33,7 @@ import firestore, {
|
|
|
17
33
|
enableNetwork,
|
|
18
34
|
disableNetwork,
|
|
19
35
|
clearPersistence,
|
|
36
|
+
clearIndexedDbPersistence,
|
|
20
37
|
terminate,
|
|
21
38
|
waitForPendingWrites,
|
|
22
39
|
initializeFirestore,
|
|
@@ -679,11 +696,11 @@ describe('Firestore', function () {
|
|
|
679
696
|
firestore1.settings({ persistence: true });
|
|
680
697
|
const indexManager = firestore1.persistentCacheIndexManager();
|
|
681
698
|
expect(indexManager).toBeDefined();
|
|
682
|
-
expect(indexManager
|
|
699
|
+
expect(indexManager!.constructor.name).toEqual('FirestorePersistentCacheIndexManager');
|
|
683
700
|
|
|
684
|
-
expect(indexManager
|
|
685
|
-
expect(indexManager
|
|
686
|
-
expect(indexManager
|
|
701
|
+
expect(indexManager!.enableIndexAutoCreation).toBeInstanceOf(Function);
|
|
702
|
+
expect(indexManager!.disableIndexAutoCreation).toBeInstanceOf(Function);
|
|
703
|
+
expect(indexManager!.deleteAllIndexes).toBeInstanceOf(Function);
|
|
687
704
|
|
|
688
705
|
const firestore2 = firebase.firestore();
|
|
689
706
|
firestore2.settings({ persistence: false });
|
|
@@ -696,4 +713,689 @@ describe('Firestore', function () {
|
|
|
696
713
|
expect(nullIndexManagerModular).toBeNull();
|
|
697
714
|
});
|
|
698
715
|
});
|
|
716
|
+
|
|
717
|
+
describe('test `console.warn` is called for RNFB v8 API & not called for v9 API', function () {
|
|
718
|
+
let collectionRefV9Deprecation: CheckV9DeprecationFunction;
|
|
719
|
+
let docRefV9Deprecation: CheckV9DeprecationFunction;
|
|
720
|
+
let fieldValueV9Deprecation: CheckV9DeprecationFunction;
|
|
721
|
+
let filterV9Deprecation: CheckV9DeprecationFunction;
|
|
722
|
+
let persistentCacheIndexManagerV9Deprecation: CheckV9DeprecationFunction;
|
|
723
|
+
let firestoreRefV9Deprecation: CheckV9DeprecationFunction;
|
|
724
|
+
let staticsV9Deprecation: CheckV9DeprecationFunction;
|
|
725
|
+
let timestampV9Deprecation: CheckV9DeprecationFunction;
|
|
726
|
+
|
|
727
|
+
beforeEach(function () {
|
|
728
|
+
firestoreRefV9Deprecation = createCheckV9Deprecation(['firestore']);
|
|
729
|
+
collectionRefV9Deprecation = createCheckV9Deprecation([
|
|
730
|
+
'firestore',
|
|
731
|
+
'FirestoreCollectionReference',
|
|
732
|
+
]);
|
|
733
|
+
|
|
734
|
+
docRefV9Deprecation = createCheckV9Deprecation(['firestore', 'FirestoreDocumentReference']);
|
|
735
|
+
|
|
736
|
+
fieldValueV9Deprecation = createCheckV9Deprecation(['firestore', 'FirestoreFieldValue']);
|
|
737
|
+
filterV9Deprecation = createCheckV9Deprecation(['firestore', 'Filter']);
|
|
738
|
+
persistentCacheIndexManagerV9Deprecation = createCheckV9Deprecation([
|
|
739
|
+
'firestore',
|
|
740
|
+
'FirestorePersistentCacheIndexManager',
|
|
741
|
+
]);
|
|
742
|
+
|
|
743
|
+
staticsV9Deprecation = createCheckV9Deprecation(['firestore', 'statics']);
|
|
744
|
+
|
|
745
|
+
timestampV9Deprecation = createCheckV9Deprecation(['firestore', 'FirestoreTimestamp']);
|
|
746
|
+
|
|
747
|
+
// @ts-ignore test
|
|
748
|
+
jest.spyOn(FirebaseModule.prototype, 'native', 'get').mockImplementation(() => {
|
|
749
|
+
return new Proxy(
|
|
750
|
+
{},
|
|
751
|
+
{
|
|
752
|
+
get: () =>
|
|
753
|
+
jest.fn().mockResolvedValue({
|
|
754
|
+
source: 'cache',
|
|
755
|
+
changes: [],
|
|
756
|
+
documents: [],
|
|
757
|
+
metadata: {},
|
|
758
|
+
path: 'foo',
|
|
759
|
+
} as never),
|
|
760
|
+
},
|
|
761
|
+
);
|
|
762
|
+
});
|
|
763
|
+
|
|
764
|
+
jest
|
|
765
|
+
.spyOn(FirestoreQuery.prototype, '_handleQueryCursor')
|
|
766
|
+
// @ts-ignore test
|
|
767
|
+
.mockImplementation(() => {
|
|
768
|
+
return [];
|
|
769
|
+
});
|
|
770
|
+
});
|
|
771
|
+
|
|
772
|
+
describe('Firestore', function () {
|
|
773
|
+
it('firestore.batch()', function () {
|
|
774
|
+
const firestore = getFirestore();
|
|
775
|
+
firestoreRefV9Deprecation(
|
|
776
|
+
() => writeBatch(firestore),
|
|
777
|
+
() => firestore.batch(),
|
|
778
|
+
'batch',
|
|
779
|
+
);
|
|
780
|
+
});
|
|
781
|
+
|
|
782
|
+
it('firestore.loadBundle()', function () {
|
|
783
|
+
const firestore = getFirestore();
|
|
784
|
+
firestoreRefV9Deprecation(
|
|
785
|
+
() => loadBundle(firestore, 'some bundle'),
|
|
786
|
+
() => firestore.loadBundle('some bundle'),
|
|
787
|
+
'loadBundle',
|
|
788
|
+
);
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
it('firestore.namedQuery()', function () {
|
|
792
|
+
const firestore = getFirestore();
|
|
793
|
+
firestoreRefV9Deprecation(
|
|
794
|
+
() => namedQuery(firestore, 'some name'),
|
|
795
|
+
() => firestore.namedQuery('some name'),
|
|
796
|
+
'namedQuery',
|
|
797
|
+
);
|
|
798
|
+
});
|
|
799
|
+
|
|
800
|
+
it('firestore.clearPersistence()', function () {
|
|
801
|
+
const firestore = getFirestore();
|
|
802
|
+
firestoreRefV9Deprecation(
|
|
803
|
+
() => clearIndexedDbPersistence(firestore),
|
|
804
|
+
() => firestore.clearPersistence(),
|
|
805
|
+
'clearPersistence',
|
|
806
|
+
);
|
|
807
|
+
// Deprecating the modular method clearPersistence() as it doesn't exist on firebase-js-sdk
|
|
808
|
+
firestoreRefV9Deprecation(
|
|
809
|
+
() => clearIndexedDbPersistence(firestore),
|
|
810
|
+
() => clearPersistence(firestore),
|
|
811
|
+
'clearPersistence',
|
|
812
|
+
);
|
|
813
|
+
});
|
|
814
|
+
|
|
815
|
+
it('firestore.waitForPendingWrites()', function () {
|
|
816
|
+
const firestore = getFirestore();
|
|
817
|
+
firestoreRefV9Deprecation(
|
|
818
|
+
() => waitForPendingWrites(firestore),
|
|
819
|
+
() => firestore.waitForPendingWrites(),
|
|
820
|
+
'waitForPendingWrites',
|
|
821
|
+
);
|
|
822
|
+
});
|
|
823
|
+
|
|
824
|
+
it('firestore.terminate()', function () {
|
|
825
|
+
const firestore = getFirestore();
|
|
826
|
+
firestoreRefV9Deprecation(
|
|
827
|
+
() => terminate(firestore),
|
|
828
|
+
() => firestore.terminate(),
|
|
829
|
+
'terminate',
|
|
830
|
+
);
|
|
831
|
+
});
|
|
832
|
+
|
|
833
|
+
it('firestore.useEmulator()', function () {
|
|
834
|
+
const firestore = getFirestore();
|
|
835
|
+
firestoreRefV9Deprecation(
|
|
836
|
+
() => connectFirestoreEmulator(firestore, 'localhost', 8080),
|
|
837
|
+
() => firestore.useEmulator('localhost', 8080),
|
|
838
|
+
'useEmulator',
|
|
839
|
+
);
|
|
840
|
+
});
|
|
841
|
+
|
|
842
|
+
it('firestore.collection()', function () {
|
|
843
|
+
const firestore = getFirestore();
|
|
844
|
+
firestoreRefV9Deprecation(
|
|
845
|
+
() => collection(firestore, 'collection'),
|
|
846
|
+
() => firestore.collection('collection'),
|
|
847
|
+
'collection',
|
|
848
|
+
);
|
|
849
|
+
});
|
|
850
|
+
|
|
851
|
+
it('firestore.collectionGroup()', function () {
|
|
852
|
+
const firestore = getFirestore();
|
|
853
|
+
firestoreRefV9Deprecation(
|
|
854
|
+
() => collectionGroup(firestore, 'collection'),
|
|
855
|
+
() => firestore.collectionGroup('collection'),
|
|
856
|
+
'collectionGroup',
|
|
857
|
+
);
|
|
858
|
+
});
|
|
859
|
+
|
|
860
|
+
it('firestore.disableNetwork()', function () {
|
|
861
|
+
const firestore = getFirestore();
|
|
862
|
+
firestoreRefV9Deprecation(
|
|
863
|
+
() => disableNetwork(firestore),
|
|
864
|
+
() => firestore.disableNetwork(),
|
|
865
|
+
'disableNetwork',
|
|
866
|
+
);
|
|
867
|
+
});
|
|
868
|
+
|
|
869
|
+
it('firestore.doc()', function () {
|
|
870
|
+
const firestore = getFirestore();
|
|
871
|
+
firestoreRefV9Deprecation(
|
|
872
|
+
() => doc(firestore, 'collection/path'),
|
|
873
|
+
() => firestore.doc('collection/path'),
|
|
874
|
+
'doc',
|
|
875
|
+
);
|
|
876
|
+
});
|
|
877
|
+
|
|
878
|
+
it('firestore.enableNetwork()', function () {
|
|
879
|
+
const firestore = getFirestore();
|
|
880
|
+
firestoreRefV9Deprecation(
|
|
881
|
+
() => enableNetwork(firestore),
|
|
882
|
+
() => firestore.enableNetwork(),
|
|
883
|
+
'enableNetwork',
|
|
884
|
+
);
|
|
885
|
+
});
|
|
886
|
+
|
|
887
|
+
it('firestore.runTransaction()', function () {
|
|
888
|
+
const firestore = getFirestore();
|
|
889
|
+
firestoreRefV9Deprecation(
|
|
890
|
+
() => runTransaction(firestore, async () => {}),
|
|
891
|
+
() => firestore.runTransaction(async () => {}),
|
|
892
|
+
'runTransaction',
|
|
893
|
+
);
|
|
894
|
+
});
|
|
895
|
+
|
|
896
|
+
it('firestore.settings()', function () {
|
|
897
|
+
const firestore = getFirestore();
|
|
898
|
+
const app = firebase.app();
|
|
899
|
+
firestoreRefV9Deprecation(
|
|
900
|
+
// no equivalent settings method for firebase-js-sdk
|
|
901
|
+
() => initializeFirestore(app, {}),
|
|
902
|
+
() => firestore.settings({}),
|
|
903
|
+
'settings',
|
|
904
|
+
);
|
|
905
|
+
});
|
|
906
|
+
});
|
|
907
|
+
|
|
908
|
+
describe('CollectionReference', function () {
|
|
909
|
+
it('CollectionReference.count()', function () {
|
|
910
|
+
const firestore = getFirestore();
|
|
911
|
+
|
|
912
|
+
const query = collection(firestore, 'test');
|
|
913
|
+
|
|
914
|
+
collectionRefV9Deprecation(
|
|
915
|
+
() => getCountFromServer(query),
|
|
916
|
+
() => query.count(),
|
|
917
|
+
'count',
|
|
918
|
+
);
|
|
919
|
+
});
|
|
920
|
+
|
|
921
|
+
it('CollectionReference.countFromServer()', function () {
|
|
922
|
+
const firestore = getFirestore();
|
|
923
|
+
|
|
924
|
+
const query = collection(firestore, 'test');
|
|
925
|
+
|
|
926
|
+
collectionRefV9Deprecation(
|
|
927
|
+
() => getCountFromServer(query),
|
|
928
|
+
() => query.countFromServer(),
|
|
929
|
+
'count',
|
|
930
|
+
);
|
|
931
|
+
});
|
|
932
|
+
|
|
933
|
+
it('CollectionReference.endAt()', function () {
|
|
934
|
+
const firestore = getFirestore();
|
|
935
|
+
|
|
936
|
+
const query = collection(firestore, 'test');
|
|
937
|
+
|
|
938
|
+
collectionRefV9Deprecation(
|
|
939
|
+
() => endAt('foo'),
|
|
940
|
+
() => query.endAt('foo'),
|
|
941
|
+
'endAt',
|
|
942
|
+
);
|
|
943
|
+
});
|
|
944
|
+
|
|
945
|
+
it('CollectionReference.endBefore()', function () {
|
|
946
|
+
const firestore = getFirestore();
|
|
947
|
+
|
|
948
|
+
const query = collection(firestore, 'test');
|
|
949
|
+
|
|
950
|
+
collectionRefV9Deprecation(
|
|
951
|
+
() => endBefore('foo'),
|
|
952
|
+
() => query.endBefore('foo'),
|
|
953
|
+
'endBefore',
|
|
954
|
+
);
|
|
955
|
+
});
|
|
956
|
+
|
|
957
|
+
it('CollectionReference.get()', function () {
|
|
958
|
+
const firestore = getFirestore();
|
|
959
|
+
|
|
960
|
+
const query = collection(firestore, 'test');
|
|
961
|
+
|
|
962
|
+
collectionRefV9Deprecation(
|
|
963
|
+
() => getDocs(query),
|
|
964
|
+
() => query.get(),
|
|
965
|
+
'get',
|
|
966
|
+
);
|
|
967
|
+
});
|
|
968
|
+
|
|
969
|
+
it('CollectionReference.isEqual()', function () {
|
|
970
|
+
const firestore = getFirestore();
|
|
971
|
+
|
|
972
|
+
const query = collection(firestore, 'test');
|
|
973
|
+
|
|
974
|
+
collectionRefV9Deprecation(
|
|
975
|
+
// no equivalent method
|
|
976
|
+
() => {},
|
|
977
|
+
() => query.isEqual(query),
|
|
978
|
+
'isEqual',
|
|
979
|
+
);
|
|
980
|
+
});
|
|
981
|
+
|
|
982
|
+
it('CollectionReference.limit()', function () {
|
|
983
|
+
const firestore = getFirestore();
|
|
984
|
+
|
|
985
|
+
const query = collection(firestore, 'test');
|
|
986
|
+
|
|
987
|
+
collectionRefV9Deprecation(
|
|
988
|
+
() => limit(9),
|
|
989
|
+
() => query.limit(9),
|
|
990
|
+
'limit',
|
|
991
|
+
);
|
|
992
|
+
});
|
|
993
|
+
|
|
994
|
+
it('CollectionReference.limitToLast()', function () {
|
|
995
|
+
const firestore = getFirestore();
|
|
996
|
+
|
|
997
|
+
const query = collection(firestore, 'test');
|
|
998
|
+
|
|
999
|
+
collectionRefV9Deprecation(
|
|
1000
|
+
() => limitToLast(9),
|
|
1001
|
+
() => query.limitToLast(9),
|
|
1002
|
+
'limitToLast',
|
|
1003
|
+
);
|
|
1004
|
+
});
|
|
1005
|
+
|
|
1006
|
+
it('CollectionReference.onSnapshot()', function () {
|
|
1007
|
+
const firestore = getFirestore();
|
|
1008
|
+
|
|
1009
|
+
const query = collection(firestore, 'test');
|
|
1010
|
+
|
|
1011
|
+
collectionRefV9Deprecation(
|
|
1012
|
+
() => onSnapshot(query, () => {}),
|
|
1013
|
+
() => query.onSnapshot(() => {}),
|
|
1014
|
+
'onSnapshot',
|
|
1015
|
+
);
|
|
1016
|
+
});
|
|
1017
|
+
|
|
1018
|
+
it('CollectionReference.orderBy()', function () {
|
|
1019
|
+
const firestore = getFirestore();
|
|
1020
|
+
|
|
1021
|
+
const query = collection(firestore, 'test');
|
|
1022
|
+
|
|
1023
|
+
collectionRefV9Deprecation(
|
|
1024
|
+
() => orderBy('foo', 'asc'),
|
|
1025
|
+
() => query.orderBy('foo', 'asc'),
|
|
1026
|
+
'orderBy',
|
|
1027
|
+
);
|
|
1028
|
+
});
|
|
1029
|
+
|
|
1030
|
+
it('CollectionReference.startAfter()', function () {
|
|
1031
|
+
const firestore = getFirestore();
|
|
1032
|
+
|
|
1033
|
+
const query = collection(firestore, 'test');
|
|
1034
|
+
|
|
1035
|
+
collectionRefV9Deprecation(
|
|
1036
|
+
() => startAfter('foo'),
|
|
1037
|
+
() => query.startAfter('foo'),
|
|
1038
|
+
'startAfter',
|
|
1039
|
+
);
|
|
1040
|
+
});
|
|
1041
|
+
|
|
1042
|
+
it('CollectionReference.startAt()', function () {
|
|
1043
|
+
const firestore = getFirestore();
|
|
1044
|
+
|
|
1045
|
+
const query = collection(firestore, 'test');
|
|
1046
|
+
|
|
1047
|
+
collectionRefV9Deprecation(
|
|
1048
|
+
() => startAt('foo'),
|
|
1049
|
+
() => query.startAt('foo'),
|
|
1050
|
+
'startAt',
|
|
1051
|
+
);
|
|
1052
|
+
});
|
|
1053
|
+
|
|
1054
|
+
it('CollectionReference.where()', function () {
|
|
1055
|
+
const firestore = getFirestore();
|
|
1056
|
+
|
|
1057
|
+
const query = collection(firestore, 'test');
|
|
1058
|
+
|
|
1059
|
+
collectionRefV9Deprecation(
|
|
1060
|
+
() => where('foo', '==', 'bar'),
|
|
1061
|
+
() => query.where('foo', '==', 'bar'),
|
|
1062
|
+
'where',
|
|
1063
|
+
);
|
|
1064
|
+
});
|
|
1065
|
+
|
|
1066
|
+
it('CollectionReference.add()', function () {
|
|
1067
|
+
const firestore = getFirestore();
|
|
1068
|
+
|
|
1069
|
+
const query = collection(firestore, 'test');
|
|
1070
|
+
|
|
1071
|
+
collectionRefV9Deprecation(
|
|
1072
|
+
() => addDoc(query, { foo: 'bar' }),
|
|
1073
|
+
() => query.add({ foo: 'bar' }),
|
|
1074
|
+
'add',
|
|
1075
|
+
);
|
|
1076
|
+
});
|
|
1077
|
+
|
|
1078
|
+
it('CollectionReference.doc()', function () {
|
|
1079
|
+
const firestore = getFirestore();
|
|
1080
|
+
|
|
1081
|
+
const query = collection(firestore, 'test');
|
|
1082
|
+
|
|
1083
|
+
collectionRefV9Deprecation(
|
|
1084
|
+
() => doc(query, 'bar'),
|
|
1085
|
+
() => query.doc('foo'),
|
|
1086
|
+
'doc',
|
|
1087
|
+
);
|
|
1088
|
+
});
|
|
1089
|
+
});
|
|
1090
|
+
|
|
1091
|
+
describe('DocumentReference', function () {
|
|
1092
|
+
it('DocumentReference.collection()', function () {
|
|
1093
|
+
const firestore = getFirestore();
|
|
1094
|
+
|
|
1095
|
+
const docRef = firestore.doc('some/foo');
|
|
1096
|
+
|
|
1097
|
+
docRefV9Deprecation(
|
|
1098
|
+
() => collection(firestore, 'bar'),
|
|
1099
|
+
() => docRef.collection('bar'),
|
|
1100
|
+
'collection',
|
|
1101
|
+
);
|
|
1102
|
+
});
|
|
1103
|
+
|
|
1104
|
+
it('DocumentReference.delete()', function () {
|
|
1105
|
+
const firestore = getFirestore();
|
|
1106
|
+
|
|
1107
|
+
const docRef = firestore.doc('some/foo');
|
|
1108
|
+
|
|
1109
|
+
docRefV9Deprecation(
|
|
1110
|
+
() => deleteDoc(docRef),
|
|
1111
|
+
() => docRef.delete(),
|
|
1112
|
+
'delete',
|
|
1113
|
+
);
|
|
1114
|
+
});
|
|
1115
|
+
|
|
1116
|
+
it('DocumentReference.get()', function () {
|
|
1117
|
+
const firestore = getFirestore();
|
|
1118
|
+
|
|
1119
|
+
const docRef = firestore.doc('some/foo');
|
|
1120
|
+
|
|
1121
|
+
docRefV9Deprecation(
|
|
1122
|
+
() => getDoc(docRef),
|
|
1123
|
+
() => docRef.get(),
|
|
1124
|
+
'get',
|
|
1125
|
+
);
|
|
1126
|
+
});
|
|
1127
|
+
|
|
1128
|
+
it('DocumentReference.isEqual()', function () {
|
|
1129
|
+
const firestore = getFirestore();
|
|
1130
|
+
|
|
1131
|
+
const docRef = firestore.doc('some/foo');
|
|
1132
|
+
|
|
1133
|
+
docRefV9Deprecation(
|
|
1134
|
+
// no equivalent method
|
|
1135
|
+
() => {},
|
|
1136
|
+
() => docRef.isEqual(docRef),
|
|
1137
|
+
'isEqual',
|
|
1138
|
+
);
|
|
1139
|
+
});
|
|
1140
|
+
|
|
1141
|
+
it('DocumentReference.onSnapshot()', function () {
|
|
1142
|
+
const firestore = getFirestore();
|
|
1143
|
+
|
|
1144
|
+
const docRef = firestore.doc('some/foo');
|
|
1145
|
+
|
|
1146
|
+
docRefV9Deprecation(
|
|
1147
|
+
() => onSnapshot(docRef, () => {}),
|
|
1148
|
+
() => docRef.onSnapshot(() => {}),
|
|
1149
|
+
'onSnapshot',
|
|
1150
|
+
);
|
|
1151
|
+
});
|
|
1152
|
+
|
|
1153
|
+
it('DocumentReference.set()', function () {
|
|
1154
|
+
const firestore = getFirestore();
|
|
1155
|
+
|
|
1156
|
+
const docRef = firestore.doc('some/foo');
|
|
1157
|
+
|
|
1158
|
+
docRefV9Deprecation(
|
|
1159
|
+
() => setDoc(docRef, { foo: 'bar' }),
|
|
1160
|
+
() => docRef.set({ foo: 'bar' }),
|
|
1161
|
+
'set',
|
|
1162
|
+
);
|
|
1163
|
+
});
|
|
1164
|
+
|
|
1165
|
+
it('DocumentReference.update()', function () {
|
|
1166
|
+
const firestore = getFirestore();
|
|
1167
|
+
|
|
1168
|
+
const docRef = firestore.doc('some/foo');
|
|
1169
|
+
|
|
1170
|
+
docRefV9Deprecation(
|
|
1171
|
+
() => updateDoc(docRef, { foo: 'bar' }),
|
|
1172
|
+
() => docRef.update({ foo: 'bar' }),
|
|
1173
|
+
'update',
|
|
1174
|
+
);
|
|
1175
|
+
});
|
|
1176
|
+
});
|
|
1177
|
+
|
|
1178
|
+
it('FirestoreDocumentSnapshot.isEqual()', function () {
|
|
1179
|
+
const firestore = getFirestore();
|
|
1180
|
+
// Every `FirestoreDocumentSnapshot` has been wrapped in deprecation proxy, so we use constructor directly
|
|
1181
|
+
// for ease of mocking
|
|
1182
|
+
const snapshot = createDeprecationProxy(
|
|
1183
|
+
new FirestoreDocumentSnapshot(firestore, {
|
|
1184
|
+
source: 'cache',
|
|
1185
|
+
changes: [],
|
|
1186
|
+
documents: [],
|
|
1187
|
+
metadata: {},
|
|
1188
|
+
path: 'foo',
|
|
1189
|
+
}),
|
|
1190
|
+
);
|
|
1191
|
+
|
|
1192
|
+
docRefV9Deprecation(
|
|
1193
|
+
// no equivalent method
|
|
1194
|
+
() => {},
|
|
1195
|
+
() => snapshot.isEqual(snapshot),
|
|
1196
|
+
'isEqual',
|
|
1197
|
+
);
|
|
1198
|
+
});
|
|
1199
|
+
|
|
1200
|
+
describe('FieldValue', function () {
|
|
1201
|
+
it('FieldValue.delete()', function () {
|
|
1202
|
+
const fieldValue = firestore.FieldValue;
|
|
1203
|
+
fieldValueV9Deprecation(
|
|
1204
|
+
() => deleteField(),
|
|
1205
|
+
() => fieldValue.delete(),
|
|
1206
|
+
'delete',
|
|
1207
|
+
);
|
|
1208
|
+
});
|
|
1209
|
+
|
|
1210
|
+
it('FieldValue.increment()', function () {
|
|
1211
|
+
const fieldValue = firestore.FieldValue;
|
|
1212
|
+
fieldValueV9Deprecation(
|
|
1213
|
+
() => increment(3),
|
|
1214
|
+
() => fieldValue.increment(4),
|
|
1215
|
+
'increment',
|
|
1216
|
+
);
|
|
1217
|
+
});
|
|
1218
|
+
|
|
1219
|
+
it('FieldValue.serverTimestamp()', function () {
|
|
1220
|
+
const fieldValue = firestore.FieldValue;
|
|
1221
|
+
fieldValueV9Deprecation(
|
|
1222
|
+
() => serverTimestamp(),
|
|
1223
|
+
() => fieldValue.serverTimestamp(),
|
|
1224
|
+
'serverTimestamp',
|
|
1225
|
+
);
|
|
1226
|
+
});
|
|
1227
|
+
|
|
1228
|
+
it('FieldValue.arrayUnion()', function () {
|
|
1229
|
+
const fieldValue = firestore.FieldValue;
|
|
1230
|
+
fieldValueV9Deprecation(
|
|
1231
|
+
() => arrayUnion('foo'),
|
|
1232
|
+
() => fieldValue.arrayUnion('bar'),
|
|
1233
|
+
'arrayUnion',
|
|
1234
|
+
);
|
|
1235
|
+
});
|
|
1236
|
+
|
|
1237
|
+
it('FieldValue.arrayRemove()', function () {
|
|
1238
|
+
const fieldValue = firestore.FieldValue;
|
|
1239
|
+
fieldValueV9Deprecation(
|
|
1240
|
+
() => arrayRemove('foo'),
|
|
1241
|
+
() => fieldValue.arrayRemove('bar'),
|
|
1242
|
+
'arrayRemove',
|
|
1243
|
+
);
|
|
1244
|
+
});
|
|
1245
|
+
});
|
|
1246
|
+
|
|
1247
|
+
describe('statics', function () {
|
|
1248
|
+
it('Firestore.setLogLevel()', function () {
|
|
1249
|
+
// @ts-ignore test
|
|
1250
|
+
jest
|
|
1251
|
+
.spyOn(nativeModule, 'getReactNativeModule')
|
|
1252
|
+
.mockReturnValue({ setLogLevel: jest.fn() });
|
|
1253
|
+
|
|
1254
|
+
staticsV9Deprecation(
|
|
1255
|
+
() => setLogLevel('debug'),
|
|
1256
|
+
() => firestore.setLogLevel('debug'),
|
|
1257
|
+
'setLogLevel',
|
|
1258
|
+
);
|
|
1259
|
+
});
|
|
1260
|
+
|
|
1261
|
+
it('Filter static', function () {
|
|
1262
|
+
staticsV9Deprecation(
|
|
1263
|
+
// no corresponding method
|
|
1264
|
+
() => {},
|
|
1265
|
+
() => firestore.Filter,
|
|
1266
|
+
'Filter',
|
|
1267
|
+
);
|
|
1268
|
+
});
|
|
1269
|
+
|
|
1270
|
+
it('Timestamp static', function () {
|
|
1271
|
+
staticsV9Deprecation(
|
|
1272
|
+
() => Timestamp,
|
|
1273
|
+
() => firestore.Timestamp,
|
|
1274
|
+
'Timestamp',
|
|
1275
|
+
);
|
|
1276
|
+
});
|
|
1277
|
+
|
|
1278
|
+
it('FieldValue static', function () {
|
|
1279
|
+
staticsV9Deprecation(
|
|
1280
|
+
() => FieldValue,
|
|
1281
|
+
() => firestore.FieldValue,
|
|
1282
|
+
'FieldValue',
|
|
1283
|
+
);
|
|
1284
|
+
});
|
|
1285
|
+
|
|
1286
|
+
it('GeoPoint static', function () {
|
|
1287
|
+
staticsV9Deprecation(
|
|
1288
|
+
() => GeoPoint,
|
|
1289
|
+
() => firestore.GeoPoint,
|
|
1290
|
+
'GeoPoint',
|
|
1291
|
+
);
|
|
1292
|
+
});
|
|
1293
|
+
|
|
1294
|
+
it('Blob static', function () {
|
|
1295
|
+
staticsV9Deprecation(
|
|
1296
|
+
() => Blob,
|
|
1297
|
+
() => firestore.Blob,
|
|
1298
|
+
'Blob',
|
|
1299
|
+
);
|
|
1300
|
+
});
|
|
1301
|
+
|
|
1302
|
+
it('FieldPath static', function () {
|
|
1303
|
+
staticsV9Deprecation(
|
|
1304
|
+
() => FieldPath,
|
|
1305
|
+
() => firestore.FieldPath,
|
|
1306
|
+
'FieldPath',
|
|
1307
|
+
);
|
|
1308
|
+
});
|
|
1309
|
+
});
|
|
1310
|
+
|
|
1311
|
+
describe('Filter', function () {
|
|
1312
|
+
it('Filter.or()', function () {
|
|
1313
|
+
const filter = firestore.Filter;
|
|
1314
|
+
filterV9Deprecation(
|
|
1315
|
+
() => or(where('foo.bar', '==', null), where('foo.bar', '==', null)),
|
|
1316
|
+
() => filter.or(filter('foo', '==', 'bar'), filter('baz', '==', 'qux')),
|
|
1317
|
+
'or',
|
|
1318
|
+
);
|
|
1319
|
+
});
|
|
1320
|
+
|
|
1321
|
+
it('Filter.and()', function () {
|
|
1322
|
+
const filter = firestore.Filter;
|
|
1323
|
+
filterV9Deprecation(
|
|
1324
|
+
() => and(where('foo.bar', '==', null), where('foo.bar', '==', null)),
|
|
1325
|
+
() => filter.and(filter('foo', '==', 'bar'), filter('baz', '==', 'qux')),
|
|
1326
|
+
'and',
|
|
1327
|
+
);
|
|
1328
|
+
});
|
|
1329
|
+
});
|
|
1330
|
+
|
|
1331
|
+
describe('FirestorePersistentCacheIndexManager', function () {
|
|
1332
|
+
it('firestore.persistentCacheIndexManager()', function () {
|
|
1333
|
+
const firestore = getFirestore();
|
|
1334
|
+
|
|
1335
|
+
firestoreRefV9Deprecation(
|
|
1336
|
+
() => getPersistentCacheIndexManager(firestore),
|
|
1337
|
+
() => firestore.persistentCacheIndexManager(),
|
|
1338
|
+
'persistentCacheIndexManager',
|
|
1339
|
+
);
|
|
1340
|
+
});
|
|
1341
|
+
|
|
1342
|
+
it('FirestorePersistentCacheIndexManager.enableIndexAutoCreation()', function () {
|
|
1343
|
+
const firestore = getFirestore();
|
|
1344
|
+
// @ts-ignore test
|
|
1345
|
+
firestore._settings.persistence = true;
|
|
1346
|
+
const indexManager = firestore.persistentCacheIndexManager();
|
|
1347
|
+
persistentCacheIndexManagerV9Deprecation(
|
|
1348
|
+
() => enablePersistentCacheIndexAutoCreation(indexManager!),
|
|
1349
|
+
() => indexManager!.enableIndexAutoCreation(),
|
|
1350
|
+
'enableIndexAutoCreation',
|
|
1351
|
+
);
|
|
1352
|
+
});
|
|
1353
|
+
|
|
1354
|
+
it('FirestorePersistentCacheIndexManager.disableIndexAutoCreation()', function () {
|
|
1355
|
+
const firestore = getFirestore();
|
|
1356
|
+
// @ts-ignore test
|
|
1357
|
+
firestore._settings.persistence = true;
|
|
1358
|
+
const indexManager = firestore.persistentCacheIndexManager();
|
|
1359
|
+
persistentCacheIndexManagerV9Deprecation(
|
|
1360
|
+
() => disablePersistentCacheIndexAutoCreation(indexManager!),
|
|
1361
|
+
() => indexManager!.disableIndexAutoCreation(),
|
|
1362
|
+
'disableIndexAutoCreation',
|
|
1363
|
+
);
|
|
1364
|
+
});
|
|
1365
|
+
|
|
1366
|
+
it('FirestorePersistentCacheIndexManager.deleteAllIndexes()', function () {
|
|
1367
|
+
const firestore = getFirestore();
|
|
1368
|
+
// @ts-ignore test
|
|
1369
|
+
firestore._settings.persistence = true;
|
|
1370
|
+
const indexManager = firestore.persistentCacheIndexManager();
|
|
1371
|
+
persistentCacheIndexManagerV9Deprecation(
|
|
1372
|
+
() => deleteAllPersistentCacheIndexes(indexManager!),
|
|
1373
|
+
() => indexManager!.deleteAllIndexes(),
|
|
1374
|
+
'deleteAllIndexes',
|
|
1375
|
+
);
|
|
1376
|
+
});
|
|
1377
|
+
});
|
|
1378
|
+
|
|
1379
|
+
describe('Timestamp', function () {
|
|
1380
|
+
it('Timestamp.seconds', function () {
|
|
1381
|
+
const timestamp = new firestore.Timestamp(2, 3);
|
|
1382
|
+
timestampV9Deprecation(
|
|
1383
|
+
// no corresponding method
|
|
1384
|
+
() => {},
|
|
1385
|
+
() => timestamp.seconds,
|
|
1386
|
+
'seconds',
|
|
1387
|
+
);
|
|
1388
|
+
});
|
|
1389
|
+
|
|
1390
|
+
it('Timestamp.nanoseconds', function () {
|
|
1391
|
+
const timestamp = new firestore.Timestamp(2000, 3000000);
|
|
1392
|
+
timestampV9Deprecation(
|
|
1393
|
+
// no corresponding method
|
|
1394
|
+
() => {},
|
|
1395
|
+
() => timestamp.nanoseconds,
|
|
1396
|
+
'nanoseconds',
|
|
1397
|
+
);
|
|
1398
|
+
});
|
|
1399
|
+
});
|
|
1400
|
+
});
|
|
699
1401
|
});
|