File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import { initDB } from "../clients/db";
11
11
12
12
describe ( "RoutingSvc" , ( ) => {
13
13
const osrm = new RoutingSvc ( ROUTING_API , fetch , new CongestionSvc ( initDB ( ) ) ) ;
14
+
14
15
test ( "route() returns routes" , async ( ) => {
15
16
const routes = await osrm . route (
16
17
// NTU nanyang circle
@@ -26,4 +27,21 @@ describe("RoutingSvc", () => {
26
27
) ;
27
28
expect ( routes . length ) . toBeGreaterThan ( 0 ) ;
28
29
} ) ;
30
+
31
+ test ( "geolookup() returns correct GeoLocation for a given postcode" , async ( ) => {
32
+ const postcode = "639798" ; // Example postcode for NTU area
33
+ const location = await osrm . geolookup ( postcode ) ;
34
+
35
+ expect ( location ) . toBeDefined ( ) ;
36
+ expect ( location . latitude ) . toBeCloseTo ( 1.3437504 , 4 ) ;
37
+ expect ( location . longitude ) . toBeCloseTo ( 103.6849923 , 4 ) ;
38
+ } ) ;
39
+
40
+ test ( "geolookup() throws an error for invalid postcode" , async ( ) => {
41
+ const invalidPostcode = "000000" ; // Example of an invalid postcode
42
+
43
+ await expect ( osrm . geolookup ( invalidPostcode ) ) . rejects . toThrow (
44
+ `No location found for postcode: ${ invalidPostcode } `
45
+ ) ;
46
+ } ) ;
29
47
} ) ;
You can’t perform that action at this time.
0 commit comments