Skip to content

Commit 55cdb25

Browse files
committed
index_manager.test.ts: fix build
1 parent fc90b42 commit 55cdb25

File tree

1 file changed

+2
-105
lines changed

1 file changed

+2
-105
lines changed

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

Lines changed: 2 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,8 @@ import * as persistenceHelpers from './persistence_test_helpers';
6565
import { TestIndexManager } from './test_index_manager';
6666
import {
6767
IndexedDbIndexManager,
68-
IndexedDbIndexManagerFieldIndexPlugin,
69-
IndexedDbIndexManagerFieldIndexPluginFactory,
70-
IndexedDbIndexManagerFieldIndexPluginFactoryImpl
68+
indexedDbIndexManagerInstallFieldIndexPlugin
7169
} from '../../../src/local/indexeddb_index_manager';
72-
import { DatabaseId } from '../../../src/core/database_info';
73-
import { TEST_DATABASE_ID } from './persistence_test_helpers';
7470

7571
describe('index_manager.ts top-level functions', () => {
7672
describe('displayNameForIndexType()', () => {
@@ -118,9 +114,7 @@ describe('IndexedDbIndexManager', async () => {
118114
'an instance of IndexedDbIndexManager'
119115
);
120116
}
121-
indexManager.installFieldIndexPlugin(
122-
new IndexedDbIndexManagerFieldIndexPluginFactoryImpl()
123-
);
117+
indexedDbIndexManagerInstallFieldIndexPlugin(indexManager);
124118
return new TestIndexManager(persistence, indexManager);
125119
}
126120

@@ -1781,72 +1775,6 @@ describe('IndexedDbIndexManager', async () => {
17811775
await validateIsNoneIndex(query2);
17821776
});
17831777

1784-
it('fieldIndexPlugin is initially null', async () => {
1785-
const indexManager = await getIndexedDbIndexManager();
1786-
expect(indexManager.fieldIndexPlugin).is.null;
1787-
});
1788-
1789-
it('installFieldIndexPlugin() specifies the correct arguments to the factory', async () => {
1790-
const indexManager = await getIndexedDbIndexManager(new User('abc'));
1791-
const factory = new TestIndexedDbIndexManagerFieldIndexPluginFactory();
1792-
indexManager.installFieldIndexPlugin(factory);
1793-
const invocation = factory.invocations[0];
1794-
expect(invocation.uid).to.equal('abc');
1795-
expect(invocation.databaseId.isEqual(TEST_DATABASE_ID)).to.be.true;
1796-
});
1797-
1798-
it('installFieldIndexPlugin() initializes fieldIndexPlugin on first invocation', async () => {
1799-
const indexManager = await getIndexedDbIndexManager();
1800-
const factory = new TestIndexedDbIndexManagerFieldIndexPluginFactory([
1801-
'foo'
1802-
]);
1803-
indexManager.installFieldIndexPlugin(factory);
1804-
expect(indexManager.fieldIndexPlugin).to.equal('foo');
1805-
});
1806-
1807-
it('installFieldIndexPlugin() does not modify fieldIndexPlugin on subsequent invocations', async () => {
1808-
const indexManager = await getIndexedDbIndexManager();
1809-
const factory = new TestIndexedDbIndexManagerFieldIndexPluginFactory([
1810-
'foo',
1811-
'bar'
1812-
]);
1813-
indexManager.installFieldIndexPlugin(factory);
1814-
indexManager.installFieldIndexPlugin(factory);
1815-
expect(indexManager.fieldIndexPlugin).to.equal('foo');
1816-
});
1817-
1818-
it('installFieldIndexPlugin() returns the object that was created by the factory', async () => {
1819-
const indexManager = await getIndexedDbIndexManager();
1820-
const factory = new TestIndexedDbIndexManagerFieldIndexPluginFactory([
1821-
'foo'
1822-
]);
1823-
expect(indexManager.installFieldIndexPlugin(factory)).to.equal('foo');
1824-
});
1825-
1826-
it('installFieldIndexPlugin() returns the object that was created by the first invocation', async () => {
1827-
const indexManager = await getIndexedDbIndexManager();
1828-
const factory = new TestIndexedDbIndexManagerFieldIndexPluginFactory([
1829-
'foo',
1830-
'bar'
1831-
]);
1832-
indexManager.installFieldIndexPlugin(factory);
1833-
expect(indexManager.installFieldIndexPlugin(factory)).to.equal('foo');
1834-
});
1835-
1836-
it('installFieldIndexPlugin() throws if invoked with a different factory', async () => {
1837-
const indexManager = await getIndexedDbIndexManager();
1838-
const factory1 = new TestIndexedDbIndexManagerFieldIndexPluginFactory([
1839-
'foo'
1840-
]);
1841-
const factory2 = new TestIndexedDbIndexManagerFieldIndexPluginFactory([
1842-
'bar'
1843-
]);
1844-
indexManager.installFieldIndexPlugin(factory1);
1845-
expect(() => indexManager.installFieldIndexPlugin(factory2)).to.throw(
1846-
'factory object'
1847-
);
1848-
});
1849-
18501778
async function validateIsPartialIndex(query: Query): Promise<void> {
18511779
await validateIndexType(query, IndexType.PARTIAL);
18521780
}
@@ -1981,34 +1909,3 @@ function genericIndexManagerTests(
19811909
);
19821910
});
19831911
}
1984-
1985-
class TestIndexedDbIndexManagerFieldIndexPluginFactory
1986-
implements IndexedDbIndexManagerFieldIndexPluginFactory
1987-
{
1988-
private readonly returnValuesIterator: Iterator<unknown>;
1989-
1990-
private readonly _invocations: TestIndexedDbIndexManagerFieldIndexPluginFactoryInvocation[] =
1991-
[];
1992-
1993-
get invocations(): TestIndexedDbIndexManagerFieldIndexPluginFactoryInvocation[] {
1994-
return Array.from(this._invocations);
1995-
}
1996-
1997-
constructor(returnValues: unknown[] = []) {
1998-
this.returnValuesIterator = returnValues[Symbol.iterator]();
1999-
}
2000-
2001-
newIndexedDbIndexManagerFieldIndexPlugin(
2002-
uid: string,
2003-
databaseId: DatabaseId
2004-
): IndexedDbIndexManagerFieldIndexPlugin {
2005-
this._invocations.push({ uid, databaseId });
2006-
return this.returnValuesIterator.next()
2007-
.value as IndexedDbIndexManagerFieldIndexPlugin;
2008-
}
2009-
}
2010-
2011-
interface TestIndexedDbIndexManagerFieldIndexPluginFactoryInvocation {
2012-
uid: string;
2013-
databaseId: DatabaseId;
2014-
}

0 commit comments

Comments
 (0)