diff --git a/packages/firestore/test/integration/api/database.test.ts b/packages/firestore/test/integration/api/database.test.ts index 7da9bb8af7c..8db1d428c2b 100644 --- a/packages/firestore/test/integration/api/database.test.ts +++ b/packages/firestore/test/integration/api/database.test.ts @@ -1074,7 +1074,7 @@ apiDescribe('Database', (persistence: boolean) => { // eslint-disable-next-line no-restricted-properties (persistence ? it : it.skip)( - 'can clear persistence if the client has not been initialized', + 'can clear persistence if the client has been terminated', async () => { await withTestDoc(persistence, async docRef => { const firestore = docRef.firestore; @@ -1096,6 +1096,29 @@ apiDescribe('Database', (persistence: boolean) => { } ); + // eslint-disable-next-line no-restricted-properties + (persistence ? it : it.skip)( + 'can clear persistence if the client has not been initialized', + async () => { + await withTestDoc(persistence, async docRef => { + await docRef.set({ foo: 'bar' }); + const app = docRef.firestore.app; + const name = app.name; + const options = app.options; + + await app.delete(); + const app2 = firebase.initializeApp(options, name); + const firestore2 = firebase.firestore!(app2); + await firestore2.clearPersistence(); + await firestore2.enablePersistence(); + const docRef2 = firestore2.doc(docRef.path); + await expect( + docRef2.get({ source: 'cache' }) + ).to.eventually.be.rejectedWith('Failed to get document from cache.'); + }); + } + ); + // eslint-disable-next-line no-restricted-properties (persistence ? it : it.skip)( 'cannot clear persistence if the client has been initialized',