@@ -164,79 +164,76 @@ apiDescribe('Array Transforms:', persistence => {
164164 * being enabled so documents remain in the cache after the write.
165165 */
166166 // eslint-disable-next-line no-restricted-properties
167- ( persistence ? describe : describe . skip ) (
168- 'Server Application: ' ,
169- ( ) => {
170- it ( 'set() with no cached base doc' , async ( ) => {
171- await withTestDoc ( persistence , async docRef => {
172- await setDoc ( docRef , { array : arrayUnion ( 1 , 2 ) } ) ;
173- const snapshot = await getDocFromCache ( docRef ) ;
174- expect ( snapshot . data ( ) ) . to . deep . equal ( { array : [ 1 , 2 ] } ) ;
175- } ) ;
167+ ( persistence ? describe : describe . skip ) ( 'Server Application: ' , ( ) => {
168+ it ( 'set() with no cached base doc' , async ( ) => {
169+ await withTestDoc ( persistence , async docRef => {
170+ await setDoc ( docRef , { array : arrayUnion ( 1 , 2 ) } ) ;
171+ const snapshot = await getDocFromCache ( docRef ) ;
172+ expect ( snapshot . data ( ) ) . to . deep . equal ( { array : [ 1 , 2 ] } ) ;
173+ } ) ;
174+ } ) ;
175+
176+ it ( 'update() with no cached base doc' , async ( ) => {
177+ let path : string | null = null ;
178+ // Write an initial document in an isolated Firestore instance so it's not
179+ // stored in our cache
180+ await withTestDoc ( persistence , async docRef => {
181+ path = docRef . path ;
182+ await setDoc ( docRef , { array : [ 42 ] } ) ;
176183 } ) ;
177184
178- it ( 'update() with no cached base doc' , async ( ) => {
179- let path : string | null = null ;
180- // Write an initial document in an isolated Firestore instance so it's not
181- // stored in our cache
182- await withTestDoc ( persistence , async docRef => {
183- path = docRef . path ;
184- await setDoc ( docRef , { array : [ 42 ] } ) ;
185- } ) ;
186-
187- await withTestDb ( persistence , async db => {
188- const docRef = doc ( db , path ! ) ;
189- await updateDoc ( docRef , { array : arrayUnion ( 1 , 2 ) } ) ;
190-
191- // Nothing should be cached since it was an update and we had no base
192- // doc.
193- let errCaught = false ;
194- try {
195- await getDocFromCache ( docRef ) ;
196- } catch ( err ) {
197- expect ( ( err as FirestoreError ) . code ) . to . equal ( 'unavailable' ) ;
198- errCaught = true ;
199- }
200- expect ( errCaught ) . to . be . true ;
201- } ) ;
185+ await withTestDb ( persistence , async db => {
186+ const docRef = doc ( db , path ! ) ;
187+ await updateDoc ( docRef , { array : arrayUnion ( 1 , 2 ) } ) ;
188+
189+ // Nothing should be cached since it was an update and we had no base
190+ // doc.
191+ let errCaught = false ;
192+ try {
193+ await getDocFromCache ( docRef ) ;
194+ } catch ( err ) {
195+ expect ( ( err as FirestoreError ) . code ) . to . equal ( 'unavailable' ) ;
196+ errCaught = true ;
197+ }
198+ expect ( errCaught ) . to . be . true ;
202199 } ) ;
200+ } ) ;
203201
204- it ( 'set(..., {merge}) with no cached based doc' , async ( ) => {
205- let path : string | null = null ;
206- // Write an initial document in an isolated Firestore instance so it's not
207- // stored in our cache
208- await withTestDoc ( persistence , async docRef => {
209- path = docRef . path ;
210- await setDoc ( docRef , { array : [ 42 ] } ) ;
211- } ) ;
212-
213- await withTestDb ( persistence , async db => {
214- const docRef = doc ( db , path ! ) ;
215- await setDoc ( docRef , { array : arrayUnion ( 1 , 2 ) } , { merge : true } ) ;
216-
217- // Document will be cached but we'll be missing 42.
218- const snapshot = await getDocFromCache ( docRef ) ;
219- expect ( snapshot . data ( ) ) . to . deep . equal ( { array : [ 1 , 2 ] } ) ;
220- } ) ;
202+ it ( 'set(..., {merge}) with no cached based doc' , async ( ) => {
203+ let path : string | null = null ;
204+ // Write an initial document in an isolated Firestore instance so it's not
205+ // stored in our cache
206+ await withTestDoc ( persistence , async docRef => {
207+ path = docRef . path ;
208+ await setDoc ( docRef , { array : [ 42 ] } ) ;
221209 } ) ;
222210
223- it ( 'update() with cached base doc using arrayUnion()' , async ( ) => {
224- await withTestDoc ( persistence , async docRef => {
225- await setDoc ( docRef , { array : [ 42 ] } ) ;
226- await updateDoc ( docRef , { array : arrayUnion ( 1 , 2 ) } ) ;
227- const snapshot = await getDocFromCache ( docRef ) ;
228- expect ( snapshot . data ( ) ) . to . deep . equal ( { array : [ 42 , 1 , 2 ] } ) ;
229- } ) ;
211+ await withTestDb ( persistence , async db => {
212+ const docRef = doc ( db , path ! ) ;
213+ await setDoc ( docRef , { array : arrayUnion ( 1 , 2 ) } , { merge : true } ) ;
214+
215+ // Document will be cached but we'll be missing 42.
216+ const snapshot = await getDocFromCache ( docRef ) ;
217+ expect ( snapshot . data ( ) ) . to . deep . equal ( { array : [ 1 , 2 ] } ) ;
230218 } ) ;
219+ } ) ;
231220
232- it ( 'update() with cached base doc using arrayRemove()' , async ( ) => {
233- await withTestDoc ( persistence , async docRef => {
234- await setDoc ( docRef , { array : [ 42 , 1 , 2 ] } ) ;
235- await updateDoc ( docRef , { array : arrayRemove ( 1 , 2 ) } ) ;
236- const snapshot = await getDocFromCache ( docRef ) ;
237- expect ( snapshot . data ( ) ) . to . deep . equal ( { array : [ 42 ] } ) ;
238- } ) ;
221+ it ( 'update() with cached base doc using arrayUnion()' , async ( ) => {
222+ await withTestDoc ( persistence , async docRef => {
223+ await setDoc ( docRef , { array : [ 42 ] } ) ;
224+ await updateDoc ( docRef , { array : arrayUnion ( 1 , 2 ) } ) ;
225+ const snapshot = await getDocFromCache ( docRef ) ;
226+ expect ( snapshot . data ( ) ) . to . deep . equal ( { array : [ 42 , 1 , 2 ] } ) ;
239227 } ) ;
240- }
241- ) ;
228+ } ) ;
229+
230+ it ( 'update() with cached base doc using arrayRemove()' , async ( ) => {
231+ await withTestDoc ( persistence , async docRef => {
232+ await setDoc ( docRef , { array : [ 42 , 1 , 2 ] } ) ;
233+ await updateDoc ( docRef , { array : arrayRemove ( 1 , 2 ) } ) ;
234+ const snapshot = await getDocFromCache ( docRef ) ;
235+ expect ( snapshot . data ( ) ) . to . deep . equal ( { array : [ 42 ] } ) ;
236+ } ) ;
237+ } ) ;
238+ } ) ;
242239} ) ;
0 commit comments