@@ -157,7 +157,7 @@ let wasmFunctionTable: WebAssembly.Table // The table of callback functions in t
157157 * Maps request ids to a tuple of the returned data's pointer, and the data's size
158158 */
159159const promiseResults = new Map < bigint , [ number , number ] > ( )
160- const failedRequests : bigint [ ] = [ ] ;
160+ const failedRequests : bigint [ ] = [ ]
161161
162162wasmInstance = new WebAssembly . Instance ( wasmModule , {
163163 wasi_snapshot_preview1 : wasiSystem . wasiImport ,
@@ -223,20 +223,20 @@ wasmInstance = new WebAssembly.Instance(wasmModule, {
223223 func ( requestId , 200 , ctx )
224224 } )
225225 . catch ( err => {
226- failedRequests . push ( requestId ) ;
226+ failedRequests . push ( requestId )
227227 } )
228228
229229 return requestId
230230 } ,
231231 fsNetworkHttpRequestGetState : ( requestId : bigint ) => {
232- if ( failedRequests . includes ( requestId ) ) {
232+ if ( failedRequests . includes ( requestId ) ) {
233233 return 4 // FS_NETWORK_HTTP_REQUEST_STATE_FAILED
234234 }
235- if ( promiseResults . has ( requestId ) ) {
235+ if ( promiseResults . has ( requestId ) ) {
236236 return 3 // FS_NETWORK_HTTP_REQUEST_STATE_DATA_READY
237237 }
238238 return 2 // FS_NETWORK_HTTP_REQUEST_STATE_WAITING_FOR_DATA
239- }
239+ } ,
240240 } ,
241241} ) as WasmInstance
242242
@@ -290,6 +290,15 @@ beforeAll(async () => {
290290 throw new Error ( "Please specify the env var `NAVIGATION_DATA_SIGNED_URL`" )
291291 }
292292
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+
293302 await navigationDataInterface . download_navigation_data ( downloadUrl )
294303} , 30000 )
295304
0 commit comments