@@ -114,15 +114,34 @@ describe('Parse module', () => {
114114
115115 it ( 'can enable LocalDatastore' , ( ) => {
116116 jest . spyOn ( console , 'log' ) . mockImplementationOnce ( ( ) => { } ) ;
117+ jest . spyOn ( EventuallyQueue , 'poll' ) . mockImplementationOnce ( ( ) => { } ) ;
118+
119+ Parse . initialize ( null , null ) ;
120+ Parse . enableLocalDatastore ( ) ;
121+ expect ( console . log ) . toHaveBeenCalledWith (
122+ "'enableLocalDataStore' must be called after 'initialize'"
123+ ) ;
124+
125+ Parse . initialize ( 'A' , 'B' ) ;
117126 Parse . LocalDatastore . isEnabled = false ;
118127 Parse . enableLocalDatastore ( ) ;
128+
119129 expect ( Parse . LocalDatastore . isEnabled ) . toBe ( true ) ;
120130 expect ( Parse . isLocalDatastoreEnabled ( ) ) . toBe ( true ) ;
131+ expect ( EventuallyQueue . poll ) . toHaveBeenCalledTimes ( 1 ) ;
132+ expect ( EventuallyQueue . poll ) . toHaveBeenCalledWith ( 2000 ) ;
133+
134+ EventuallyQueue . poll . mockClear ( ) ;
135+ const polling = false ;
136+ Parse . enableLocalDatastore ( polling ) ;
137+ expect ( EventuallyQueue . poll ) . toHaveBeenCalledTimes ( 0 ) ;
121138 } ) ;
122139
123140 it ( 'can dump LocalDatastore' , async ( ) => {
141+ jest . spyOn ( console , 'log' ) . mockImplementationOnce ( ( ) => { } ) ;
124142 Parse . LocalDatastore . isEnabled = false ;
125143 let LDS = await Parse . dumpLocalDatastore ( ) ;
144+ expect ( console . log ) . toHaveBeenCalledWith ( 'Parse.enableLocalDatastore() must be called first' ) ;
126145 expect ( LDS ) . toEqual ( { } ) ;
127146 Parse . LocalDatastore . isEnabled = true ;
128147 const controller = {
0 commit comments