From d28286117828b693c214a315f3756c5f03ed1b71 Mon Sep 17 00:00:00 2001 From: Julian Rojas Date: Thu, 7 Jul 2022 18:30:40 +0200 Subject: [PATCH] Extend test coverage --- lib/Gtfsrt2LC.js | 4 ++-- test/gtfsrt2lc.test.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/Gtfsrt2LC.js b/lib/Gtfsrt2LC.js index ee9a46a..552af8e 100644 --- a/lib/Gtfsrt2LC.js +++ b/lib/Gtfsrt2LC.js @@ -150,7 +150,7 @@ class Gtfsrt2LC { // Check if this is a new update based on recorded Connections history (if any) // and skip it if is not new. - if (this.historyDB && !(await this.differentiaUpdate({ + if (this.historyDB && !(await this.differentialUpdate({ route: r, trip: t, stopTimes: st, @@ -626,7 +626,7 @@ class Gtfsrt2LC { return update; } - async differentiaUpdate(params) { + async differentialUpdate(params) { const { route, trip, diff --git a/test/gtfsrt2lc.test.js b/test/gtfsrt2lc.test.js index 3c13c90..99c5c27 100644 --- a/test/gtfsrt2lc.test.js +++ b/test/gtfsrt2lc.test.js @@ -582,4 +582,19 @@ test('Cover GtfsIndex functions', async () => { try { await gti.getIndexes(); } catch (err) { } +}); + +test('Cover Gtfsrt2LC functions', async () => { + grt = new Gtfsrt2lc({ path: rt_path, uris: mock_uris, headers: {} }); + // Test for resolveScheduleRelationship + const notAvailable = grt.resolveScheduleRelationship(1, 1); + const mustPhone = grt.resolveScheduleRelationship(0, 2); + const mustCoordinate = grt.resolveScheduleRelationship(0, 3); + // Test for getting headers + const headers = grt.headers(); + + expect(notAvailable).toBe('gtfs:NotAvailable'); + expect(mustPhone).toBe('gtfs:MustPhone'); + expect(mustCoordinate).toBe('gtfs:MustCoordinateWithDriver'); + expect(headers).toBeDefined(); }); \ No newline at end of file