Skip to content

Commit 75665af

Browse files
committed
index_manager.test.ts: add tests
1 parent 9e7545a commit 75665af

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

packages/firestore/test/unit/local/index_manager.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,6 +1734,21 @@ describe('IndexedDbIndexManager', async () => {
17341734
await validateIsFullIndex(query_);
17351735
});
17361736

1737+
it('deleteAllFieldIndexes() deletes all indexes', async () => {
1738+
// Create some indexes.
1739+
const query1 = queryWithAddedFilter(query('coll'), filter('a', '==', 42));
1740+
await indexManager.createTargetIndexes(queryToTarget(query1));
1741+
await validateIsFullIndex(query1);
1742+
const query2 = queryWithAddedFilter(query('coll'), filter('b', '==', 42));
1743+
await indexManager.createTargetIndexes(queryToTarget(query2));
1744+
await validateIsFullIndex(query2);
1745+
1746+
// Verify that deleteAllFieldIndexes() deletes the indexes.
1747+
await indexManager.deleteAllFieldIndexes();
1748+
await validateIsNoneIndex(query1);
1749+
await validateIsNoneIndex(query2);
1750+
});
1751+
17371752
async function validateIsPartialIndex(query: Query): Promise<void> {
17381753
await validateIndexType(query, IndexType.PARTIAL);
17391754
}

packages/firestore/test/unit/local/test_index_manager.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ export class TestIndexManager {
7171
);
7272
}
7373

74+
deleteAllFieldIndexes(): Promise<void> {
75+
return this.persistence.runTransaction(
76+
'deleteAllFieldIndexes',
77+
'readwrite',
78+
txn => this.indexManager.deleteAllFieldIndexes(txn)
79+
);
80+
}
81+
7482
getFieldIndexes(collectionGroup?: string): Promise<FieldIndex[]> {
7583
return this.persistence.runTransaction('getFieldIndexes', 'readonly', txn =>
7684
collectionGroup

0 commit comments

Comments
 (0)