@@ -147,24 +147,32 @@ describe('Streaming', () => {
147147 } ) ;
148148
149149 itWithGenerators ( 'Should trigger upload connector when connected' , async ( createConnectedDatabase ) => {
150+ console . log ( 'connecting' ) ;
150151 const { powersync, uploadSpy } = await createConnectedDatabase ( ) ;
152+ console . log ( 'connected' )
151153 expect ( powersync . connected ) . toBe ( true ) ;
152154
153155 // do something which should trigger an upload
154156 await powersync . execute ( 'INSERT INTO users (id, name) VALUES (uuid(), ?)' , [ 'name' ] ) ;
157+ console . log ( 'executed a statement' ) ;
155158 // It should try and upload
156159 await vi . waitFor (
157160 ( ) => {
158161 // to-have-been-called seems to not work after failing the first check
162+ console . log ( 'number of calls, ' , uploadSpy . mock . calls . length )
159163 expect ( uploadSpy . mock . calls . length ) . equals ( 1 ) ;
160164 } ,
161165 {
162- timeout : UPLOAD_TIMEOUT_MS
166+ timeout : UPLOAD_TIMEOUT_MS ,
167+ interval : 500
163168 }
164169 ) ;
165170
171+ console . log ( 'disconnecting' ) ;
166172 await powersync . disconnectAndClear ( ) ;
173+ console . log ( 'disconnected' ) ;
167174 await powersync . close ( ) ;
175+ console . log ( 'closed' ) ;
168176 } ) ;
169177
170178 itWithGenerators ( 'Should retry failed uploads when connected' , async ( createConnectedDatabase ) => {
@@ -193,7 +201,8 @@ describe('Streaming', () => {
193201 expect ( uploadSpy . mock . calls . length ) . equals ( throwCounter + 1 ) ;
194202 } ,
195203 {
196- timeout : UPLOAD_TIMEOUT_MS
204+ timeout : UPLOAD_TIMEOUT_MS ,
205+ interval : 500
197206 }
198207 ) ;
199208
@@ -202,29 +211,41 @@ describe('Streaming', () => {
202211 } ) ;
203212
204213 itWithGenerators ( 'Should upload after reconnecting' , async ( createConnectedDatabase ) => {
214+ console . log ( 'connecting' ) ;
205215 const { connect, powersync, uploadSpy } = await createConnectedDatabase ( ) ;
216+ console . log ( 'connected' ) ;
206217 expect ( powersync . connected ) . toBe ( true ) ;
207218
219+ console . log ( 'disconnecting' ) ;
208220 await powersync . disconnect ( ) ;
221+ console . log ( 'disconnected' ) ;
209222
210223 // do something (offline) which should trigger an upload
211224 await powersync . execute ( 'INSERT INTO users (id, name) VALUES (uuid(), ?)' , [ 'name' ] ) ;
212225
226+ console . log ( 'connecting again' ) ;
213227 await connect ( ) ;
228+ console . log ( 'done connecting' ) ;
214229
215230 // It should try and upload
216231 await vi . waitFor (
217232 ( ) => {
218233 // to-have-been-called seems to not work after failing a check
234+ console . log ( 'upload has been called times: ' , uploadSpy . mock . calls . length )
219235 expect ( uploadSpy . mock . calls . length ) . equals ( 1 ) ;
220236 } ,
221237 {
222- timeout : UPLOAD_TIMEOUT_MS
238+ timeout : UPLOAD_TIMEOUT_MS ,
239+ interval : 500
223240 }
224241 ) ;
225242
243+ console . log ( 'cleanup' ) ;
244+
226245 await powersync . disconnectAndClear ( ) ;
227246 await powersync . close ( ) ;
247+ console . log ( 'cleanup done' ) ;
248+
228249 } ) ;
229250
230251 itWithGenerators ( 'Should update status when uploading' , async ( createConnectedDatabase ) => {
@@ -253,7 +274,8 @@ describe('Streaming', () => {
253274 expect ( powersync . currentStatus . dataFlowStatus . uploading ) . false ;
254275 } ,
255276 {
256- timeout : UPLOAD_TIMEOUT_MS
277+ timeout : UPLOAD_TIMEOUT_MS ,
278+ interval : 500
257279 }
258280 ) ;
259281
0 commit comments