Skip to content

Commit df44d12

Browse files
authored
Add an integration test for calling clearPersistence() on a new Firestore instance (#3005)
1 parent 9f7b7df commit df44d12

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

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

+24-1
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ apiDescribe('Database', (persistence: boolean) => {
10861086

10871087
// eslint-disable-next-line no-restricted-properties
10881088
(persistence ? it : it.skip)(
1089-
'can clear persistence if the client has not been initialized',
1089+
'can clear persistence if the client has been terminated',
10901090
async () => {
10911091
await withTestDoc(persistence, async docRef => {
10921092
const firestore = docRef.firestore;
@@ -1108,6 +1108,29 @@ apiDescribe('Database', (persistence: boolean) => {
11081108
}
11091109
);
11101110

1111+
// eslint-disable-next-line no-restricted-properties
1112+
(persistence ? it : it.skip)(
1113+
'can clear persistence if the client has not been initialized',
1114+
async () => {
1115+
await withTestDoc(persistence, async docRef => {
1116+
await docRef.set({ foo: 'bar' });
1117+
const app = docRef.firestore.app;
1118+
const name = app.name;
1119+
const options = app.options;
1120+
1121+
await app.delete();
1122+
const app2 = firebase.initializeApp(options, name);
1123+
const firestore2 = firebase.firestore!(app2);
1124+
await firestore2.clearPersistence();
1125+
await firestore2.enablePersistence();
1126+
const docRef2 = firestore2.doc(docRef.path);
1127+
await expect(
1128+
docRef2.get({ source: 'cache' })
1129+
).to.eventually.be.rejectedWith('Failed to get document from cache.');
1130+
});
1131+
}
1132+
);
1133+
11111134
// eslint-disable-next-line no-restricted-properties
11121135
(persistence ? it : it.skip)(
11131136
'cannot clear persistence if the client has been initialized',

0 commit comments

Comments
 (0)