@@ -65,12 +65,8 @@ import * as persistenceHelpers from './persistence_test_helpers';
65
65
import { TestIndexManager } from './test_index_manager' ;
66
66
import {
67
67
IndexedDbIndexManager ,
68
- IndexedDbIndexManagerFieldIndexPlugin ,
69
- IndexedDbIndexManagerFieldIndexPluginFactory ,
70
- IndexedDbIndexManagerFieldIndexPluginFactoryImpl
68
+ indexedDbIndexManagerInstallFieldIndexPlugin
71
69
} from '../../../src/local/indexeddb_index_manager' ;
72
- import { DatabaseId } from '../../../src/core/database_info' ;
73
- import { TEST_DATABASE_ID } from './persistence_test_helpers' ;
74
70
75
71
describe ( 'index_manager.ts top-level functions' , ( ) => {
76
72
describe ( 'displayNameForIndexType()' , ( ) => {
@@ -118,9 +114,7 @@ describe('IndexedDbIndexManager', async () => {
118
114
'an instance of IndexedDbIndexManager'
119
115
) ;
120
116
}
121
- indexManager . installFieldIndexPlugin (
122
- new IndexedDbIndexManagerFieldIndexPluginFactoryImpl ( )
123
- ) ;
117
+ indexedDbIndexManagerInstallFieldIndexPlugin ( indexManager ) ;
124
118
return new TestIndexManager ( persistence , indexManager ) ;
125
119
}
126
120
@@ -1781,72 +1775,6 @@ describe('IndexedDbIndexManager', async () => {
1781
1775
await validateIsNoneIndex ( query2 ) ;
1782
1776
} ) ;
1783
1777
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
-
1850
1778
async function validateIsPartialIndex ( query : Query ) : Promise < void > {
1851
1779
await validateIndexType ( query , IndexType . PARTIAL ) ;
1852
1780
}
@@ -1981,34 +1909,3 @@ function genericIndexManagerTests(
1981
1909
) ;
1982
1910
} ) ;
1983
1911
}
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