@@ -67,15 +67,13 @@ import {
67
67
} from '../util/firebase_export' ;
68
68
import {
69
69
apiDescribe ,
70
- withEnsuredLruGcTestDb ,
71
70
withTestCollection ,
72
71
withTestDbsSettings ,
73
72
withTestDb ,
74
73
withTestDbs ,
75
74
withTestDoc ,
76
75
withTestDocAndInitialData ,
77
- withNamedTestDbsOrSkipUnlessUsingEmulator ,
78
- withEnsuredEagerGcTestDb
76
+ withNamedTestDbsOrSkipUnlessUsingEmulator
79
77
} from '../util/helpers' ;
80
78
import { DEFAULT_SETTINGS , DEFAULT_PROJECT_ID } from '../util/settings' ;
81
79
@@ -153,29 +151,32 @@ apiDescribe('Database', persistence => {
153
151
} ) ;
154
152
155
153
// eslint-disable-next-line no-restricted-properties
156
- ( persistence ? it : it . skip ) ( 'can update an unknown document' , ( ) => {
157
- return withTestDbs ( persistence , 2 , async ( [ reader , writer ] ) => {
158
- const writerRef = doc ( collection ( writer , 'collection' ) ) ;
159
- const readerRef = doc ( collection ( reader , 'collection' ) , writerRef . id ) ;
160
- await setDoc ( writerRef , { a : 'a' } ) ;
161
- await updateDoc ( readerRef , { b : 'b' } ) ;
162
- await getDocFromCache ( writerRef ) . then (
163
- doc => expect ( doc . exists ( ) ) . to . be . true
164
- ) ;
165
- await getDocFromCache ( readerRef ) . then (
166
- ( ) => {
167
- expect . fail ( 'Expected cache miss' ) ;
168
- } ,
169
- err => expect ( err . code ) . to . be . equal ( 'unavailable' )
170
- ) ;
171
- await getDoc ( writerRef ) . then ( doc =>
172
- expect ( doc . data ( ) ) . to . deep . equal ( { a : 'a' , b : 'b' } )
173
- ) ;
174
- await getDoc ( readerRef ) . then ( doc =>
175
- expect ( doc . data ( ) ) . to . deep . equal ( { a : 'a' , b : 'b' } )
176
- ) ;
177
- } ) ;
178
- } ) ;
154
+ ( persistence . gc === 'lru' ? it : it . skip ) (
155
+ 'can update an unknown document' ,
156
+ ( ) => {
157
+ return withTestDbs ( persistence , 2 , async ( [ reader , writer ] ) => {
158
+ const writerRef = doc ( collection ( writer , 'collection' ) ) ;
159
+ const readerRef = doc ( collection ( reader , 'collection' ) , writerRef . id ) ;
160
+ await setDoc ( writerRef , { a : 'a' } ) ;
161
+ await updateDoc ( readerRef , { b : 'b' } ) ;
162
+ await getDocFromCache ( writerRef ) . then (
163
+ doc => expect ( doc . exists ( ) ) . to . be . true
164
+ ) ;
165
+ await getDocFromCache ( readerRef ) . then (
166
+ ( ) => {
167
+ expect . fail ( 'Expected cache miss' ) ;
168
+ } ,
169
+ err => expect ( err . code ) . to . be . equal ( 'unavailable' )
170
+ ) ;
171
+ await getDoc ( writerRef ) . then ( doc =>
172
+ expect ( doc . data ( ) ) . to . deep . equal ( { a : 'a' , b : 'b' } )
173
+ ) ;
174
+ await getDoc ( readerRef ) . then ( doc =>
175
+ expect ( doc . data ( ) ) . to . deep . equal ( { a : 'a' , b : 'b' } )
176
+ ) ;
177
+ } ) ;
178
+ }
179
+ ) ;
179
180
180
181
it ( 'can merge data with an existing document using set' , ( ) => {
181
182
return withTestDoc ( persistence , doc => {
@@ -1095,32 +1096,35 @@ apiDescribe('Database', persistence => {
1095
1096
} ) ;
1096
1097
1097
1098
// eslint-disable-next-line no-restricted-properties
1098
- ( persistence ? it : it . skip ) ( 'offline writes are sent after restart' , ( ) => {
1099
- return withTestDoc ( persistence , async ( docRef , firestore ) => {
1100
- const app = firestore . app ;
1101
- const name = app . name ;
1102
- const options = app . options ;
1099
+ ( persistence . storage === 'indexeddb' ? it : it . skip ) (
1100
+ 'offline writes are sent after restart' ,
1101
+ ( ) => {
1102
+ return withTestDoc ( persistence , async ( docRef , firestore ) => {
1103
+ const app = firestore . app ;
1104
+ const name = app . name ;
1105
+ const options = app . options ;
1103
1106
1104
- await disableNetwork ( firestore ) ;
1107
+ await disableNetwork ( firestore ) ;
1105
1108
1106
- // We are merely adding to the cache.
1107
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
1108
- setDoc ( docRef , { foo : 'bar' } ) ;
1109
+ // We are merely adding to the cache.
1110
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
1111
+ setDoc ( docRef , { foo : 'bar' } ) ;
1109
1112
1110
- await deleteApp ( app ) ;
1113
+ await deleteApp ( app ) ;
1111
1114
1112
- const firestore2 = newTestFirestore (
1113
- newTestApp ( options . projectId ! , name ) ,
1114
- DEFAULT_SETTINGS
1115
- ) ;
1116
- await enableIndexedDbPersistence ( firestore2 ) ;
1117
- await waitForPendingWrites ( firestore2 ) ;
1118
- const doc2 = await getDoc ( doc ( firestore2 , docRef . path ) ) ;
1115
+ const firestore2 = newTestFirestore (
1116
+ newTestApp ( options . projectId ! , name ) ,
1117
+ DEFAULT_SETTINGS
1118
+ ) ;
1119
+ await enableIndexedDbPersistence ( firestore2 ) ;
1120
+ await waitForPendingWrites ( firestore2 ) ;
1121
+ const doc2 = await getDoc ( doc ( firestore2 , docRef . path ) ) ;
1119
1122
1120
- expect ( doc2 . exists ( ) ) . to . be . true ;
1121
- expect ( doc2 . metadata . hasPendingWrites ) . to . be . false ;
1122
- } ) ;
1123
- } ) ;
1123
+ expect ( doc2 . exists ( ) ) . to . be . true ;
1124
+ expect ( doc2 . metadata . hasPendingWrites ) . to . be . false ;
1125
+ } ) ;
1126
+ }
1127
+ ) ;
1124
1128
1125
1129
it ( 'rejects subsequent method calls after terminate() is called' , async ( ) => {
1126
1130
return withTestDb ( persistence , db => {
@@ -1141,7 +1145,7 @@ apiDescribe('Database', persistence => {
1141
1145
} ) ;
1142
1146
1143
1147
// eslint-disable-next-line no-restricted-properties
1144
- ( persistence ? it : it . skip ) (
1148
+ ( persistence . storage === 'indexeddb' ? it : it . skip ) (
1145
1149
'maintains persistence after restarting app' ,
1146
1150
async ( ) => {
1147
1151
await withTestDoc ( persistence , async docRef => {
@@ -1164,7 +1168,7 @@ apiDescribe('Database', persistence => {
1164
1168
) ;
1165
1169
1166
1170
// eslint-disable-next-line no-restricted-properties
1167
- ( persistence ? it : it . skip ) (
1171
+ ( persistence . storage === 'indexeddb' ? it : it . skip ) (
1168
1172
'can clear persistence if the client has been terminated' ,
1169
1173
async ( ) => {
1170
1174
await withTestDoc ( persistence , async ( docRef , firestore ) => {
@@ -1188,7 +1192,7 @@ apiDescribe('Database', persistence => {
1188
1192
) ;
1189
1193
1190
1194
// eslint-disable-next-line no-restricted-properties
1191
- ( persistence ? it : it . skip ) (
1195
+ ( persistence . storage === 'indexeddb' ? it : it . skip ) (
1192
1196
'can clear persistence if the client has not been initialized' ,
1193
1197
async ( ) => {
1194
1198
await withTestDoc ( persistence , async docRef => {
@@ -1212,7 +1216,7 @@ apiDescribe('Database', persistence => {
1212
1216
) ;
1213
1217
1214
1218
// eslint-disable-next-line no-restricted-properties
1215
- ( persistence ? it : it . skip ) (
1219
+ ( persistence . storage === 'indexeddb' ? it : it . skip ) (
1216
1220
'cannot clear persistence if the client has been initialized' ,
1217
1221
async ( ) => {
1218
1222
await withTestDoc ( persistence , async ( docRef , firestore ) => {
@@ -1757,7 +1761,7 @@ apiDescribe('Database', persistence => {
1757
1761
1758
1762
it ( 'Cannot get document from cache with eager GC enabled.' , ( ) => {
1759
1763
const initialData = { key : 'value' } ;
1760
- return withEnsuredEagerGcTestDb ( async db => {
1764
+ return withTestDb ( persistence . toEagerGc ( ) , async db => {
1761
1765
const docRef = doc ( collection ( db , 'test-collection' ) ) ;
1762
1766
await setDoc ( docRef , initialData ) ;
1763
1767
await expect ( getDocFromCache ( docRef ) ) . to . be . rejectedWith ( 'Failed to get' ) ;
@@ -1766,7 +1770,7 @@ apiDescribe('Database', persistence => {
1766
1770
1767
1771
it ( 'Can get document from cache with Lru GC enabled.' , ( ) => {
1768
1772
const initialData = { key : 'value' } ;
1769
- return withEnsuredLruGcTestDb ( persistence , async db => {
1773
+ return withTestDb ( persistence . toLruGc ( ) , async db => {
1770
1774
const docRef = doc ( collection ( db , 'test-collection' ) ) ;
1771
1775
await setDoc ( docRef , initialData ) ;
1772
1776
return getDocFromCache ( docRef ) . then ( doc => {
0 commit comments