@@ -28,37 +28,44 @@ const navigationDataInterface = new NavigraphNavigationDataInterface()
2828describe ( "DFDv2" , ( ) => {
2929 // This will run once for each test file
3030 beforeAll ( async ( ) => {
31- let pkgs = await navigationDataInterface . list_available_packages ( true , false )
31+ const downloadUrl = process . env . NAVIGATION_DATA_SIGNED_URL_V2 ?? "local"
3232
33- // const target_package = pkgs.find(info => info.cycle.format === "dfdv2" && info.cycle.cycle === "2401")
34-
35- // if (!target_package) {
36- // throw new Error("V2 Database with cycle 2401 was not found in available packages")
37- // }
38-
39- navigationDataInterface
40- . set_active_package ( pkgs [ 1 ] . uuid )
41- . then ( val => {
42- console . log ( val )
43- } )
44- . catch ( err => {
45- console . error ( err )
33+ const waitForReady = ( navDataInterface : NavigraphNavigationDataInterface ) : Promise < void > => {
34+ return new Promise ( ( resolve , _reject ) => {
35+ navDataInterface . onReady ( ( ) => resolve ( ) )
4636 } )
37+ }
38+
39+ await waitForReady ( navigationDataInterface )
40+
41+ if ( downloadUrl === "local" ) {
42+ let pkgs = await navigationDataInterface . list_available_packages ( true , false )
43+
44+ const target_package = pkgs . find ( ( info ) => info . cycle . format === 'dfdv2' && info . cycle . cycle === '2410' )
45+
46+ if ( ! target_package ) {
47+ throw new Error ( 'V2 Database with cycle 2410 was not found in available packages' )
48+ }
49+
50+ navigationDataInterface . set_active_package ( target_package . uuid ) ;
51+ } else {
52+ await navigationDataInterface . download_navigation_data ( downloadUrl , true )
53+ }
4754 } , 30000 )
4855
4956 it ( "Active database" , async ( ) => {
5057 const packageInfo = await navigationDataInterface . get_active_package ( )
5158
5259 expect ( packageInfo ) . toStrictEqual ( {
5360 is_bundled : ! process . env . NAVIGATION_DATA_SIGNED_URL ,
54- path : "/active" ,
55- uuid : "12313 " ,
61+ path : "\\work/navigation-data /active" ,
62+ uuid : "37735bb9-635b-37be-be1b-c5f9a89b7672 " ,
5663 cycle : {
57- cycle : "2401 " ,
64+ cycle : "2410 " ,
5865 revision : "1" ,
5966 name : "Navigraph Avionics" ,
6067 format : "dfdv2" ,
61- validityPeriod : "2024-01-25 /2024-02-21" ,
68+ validityPeriod : "2024-10-03 /2024-10-30"
6269 } ,
6370 } satisfies PackageInfo )
6471 } )
@@ -67,31 +74,39 @@ describe("DFDv2", () => {
6774 const info = await navigationDataInterface . get_database_info ( )
6875
6976 expect ( info ) . toStrictEqual ( {
70- airac_cycle : "2313 " ,
71- effective_from_to : [ "28-12-2023 " , "25-01 -2024" ] ,
72- previous_from_to : [ "30-11-2023 " , "28-12-2023 " ] ,
77+ airac_cycle : "2410 " ,
78+ effective_from_to : [ "03-10-2024 " , "30-10 -2024" ] ,
79+ previous_from_to : [ "depricated " , "depricated " ] ,
7380 } satisfies DatabaseInfo )
7481 } )
7582
7683 it ( "Fetch airport" , async ( ) => {
7784 const airport = await navigationDataInterface . get_airport ( "KJFK" )
7885
7986 expect ( airport ) . toStrictEqual ( {
87+ airport_type : "C" ,
8088 area_code : "USA" ,
89+ city : "NEW YORK" ,
90+ continent : "NORTH AMERICA" ,
91+ country : "UNITED STATES" ,
92+ country_3letter : "USA" ,
8193 ident : "KJFK" ,
8294 icao_code : "K6" ,
8395 location : {
84- lat : 40.63992778 ,
85- long : - 73.77869167 ,
96+ lat : 40.63992777777778 ,
97+ long : - 73.77869166666666 ,
8698 } ,
8799 name : "KENNEDY INTL" ,
88100 ifr_capability : IfrCapability . Yes ,
89101 longest_runway_surface_code : RunwaySurfaceCode . Hard ,
102+ magnetic_variation : - 13 ,
90103 elevation : 13 ,
91104 transition_altitude : 18000 ,
92105 transition_level : 18000 ,
93106 speed_limit : 250 ,
94107 speed_limit_altitude : 10000 ,
108+ state : "NEW YORK" ,
109+ state_2letter : "NY" ,
95110 iata_ident : "JFK" ,
96111 } satisfies Airport )
97112 } )
@@ -103,11 +118,14 @@ describe("DFDv2", () => {
103118
104119 expect ( waypoints [ 0 ] ) . toStrictEqual ( {
105120 area_code : "SPA" ,
121+ continent : "PACIFIC" ,
122+ country : "NEW ZEALAND" ,
123+ datum_code : "WGE" ,
106124 icao_code : "NZ" ,
107125 ident : "GLENN" ,
108126 location : {
109- lat : - 42.88116389 ,
110- long : 172.83973889 ,
127+ lat : - 42.88116388888889 ,
128+ long : 172.8397388888889 ,
111129 } ,
112130 name : "GLENN" ,
113131 } satisfies Waypoint )
@@ -162,7 +180,7 @@ describe("DFDv2", () => {
162180 it ( "Get airports in range" , async ( ) => {
163181 const airports = await navigationDataInterface . get_airports_in_range ( { lat : 51.468 , long : - 0.4551 } , 640 )
164182
165- expect ( airports . length ) . toBe ( 1686 )
183+ expect ( airports . length ) . toBe ( 1506 )
166184 } )
167185
168186 it ( "Get waypoints in range" , async ( ) => {
0 commit comments