@@ -157,7 +157,7 @@ let wasmFunctionTable: WebAssembly.Table // The table of callback functions in t
157
157
* Maps request ids to a tuple of the returned data's pointer, and the data's size
158
158
*/
159
159
const promiseResults = new Map < bigint , [ number , number ] > ( )
160
- const failedRequests : bigint [ ] = [ ] ;
160
+ const failedRequests : bigint [ ] = [ ]
161
161
162
162
wasmInstance = new WebAssembly . Instance ( wasmModule , {
163
163
wasi_snapshot_preview1 : wasiSystem . wasiImport ,
@@ -223,20 +223,20 @@ wasmInstance = new WebAssembly.Instance(wasmModule, {
223
223
func ( requestId , 200 , ctx )
224
224
} )
225
225
. catch ( err => {
226
- failedRequests . push ( requestId ) ;
226
+ failedRequests . push ( requestId )
227
227
} )
228
228
229
229
return requestId
230
230
} ,
231
231
fsNetworkHttpRequestGetState : ( requestId : bigint ) => {
232
- if ( failedRequests . includes ( requestId ) ) {
232
+ if ( failedRequests . includes ( requestId ) ) {
233
233
return 4 // FS_NETWORK_HTTP_REQUEST_STATE_FAILED
234
234
}
235
- if ( promiseResults . has ( requestId ) ) {
235
+ if ( promiseResults . has ( requestId ) ) {
236
236
return 3 // FS_NETWORK_HTTP_REQUEST_STATE_DATA_READY
237
237
}
238
238
return 2 // FS_NETWORK_HTTP_REQUEST_STATE_WAITING_FOR_DATA
239
- }
239
+ } ,
240
240
} ,
241
241
} ) as WasmInstance
242
242
@@ -290,6 +290,15 @@ beforeAll(async () => {
290
290
throw new Error ( "Please specify the env var `NAVIGATION_DATA_SIGNED_URL`" )
291
291
}
292
292
293
+ // Utility function to convert onReady to a promise
294
+ const waitForReady = ( navDataInterface : NavigraphNavigationDataInterface ) : Promise < void > => {
295
+ return new Promise ( ( resolve , _reject ) => {
296
+ navDataInterface . onReady ( ( ) => resolve ( ) )
297
+ } )
298
+ }
299
+
300
+ await waitForReady ( navigationDataInterface )
301
+
293
302
await navigationDataInterface . download_navigation_data ( downloadUrl )
294
303
} , 30000 )
295
304
0 commit comments