@@ -1074,7 +1074,7 @@ apiDescribe('Database', (persistence: boolean) => {
1074
1074
1075
1075
// eslint-disable-next-line no-restricted-properties
1076
1076
( persistence ? it : it . skip ) (
1077
- 'can clear persistence if the client has not been initialized ' ,
1077
+ 'can clear persistence if the client has been terminated ' ,
1078
1078
async ( ) => {
1079
1079
await withTestDoc ( persistence , async docRef => {
1080
1080
const firestore = docRef . firestore ;
@@ -1096,6 +1096,30 @@ apiDescribe('Database', (persistence: boolean) => {
1096
1096
}
1097
1097
) ;
1098
1098
1099
+ // eslint-disable-next-line no-restricted-properties
1100
+ ( persistence ? it : it . skip ) (
1101
+ 'can clear persistence if the client has not been initialized' ,
1102
+ async ( ) => {
1103
+ await withTestDoc ( persistence , async docRef => {
1104
+ const firestore = docRef . firestore ;
1105
+ await docRef . set ( { foo : 'bar' } ) ;
1106
+ const app = docRef . firestore . app ;
1107
+ const name = app . name ;
1108
+ const options = app . options ;
1109
+
1110
+ await app . delete ( ) ;
1111
+ const app2 = firebase . initializeApp ( options , name ) ;
1112
+ const firestore2 = firebase . firestore ! ( app2 ) ;
1113
+ await firestore2 . clearPersistence ( ) ;
1114
+ await firestore2 . enablePersistence ( ) ;
1115
+ const docRef2 = firestore2 . doc ( docRef . path ) ;
1116
+ await expect (
1117
+ docRef2 . get ( { source : 'cache' } )
1118
+ ) . to . eventually . be . rejectedWith ( 'Failed to get document from cache.' ) ;
1119
+ } ) ;
1120
+ }
1121
+ ) ;
1122
+
1099
1123
// eslint-disable-next-line no-restricted-properties
1100
1124
( persistence ? it : it . skip ) (
1101
1125
'cannot clear persistence if the client has been initialized' ,
0 commit comments