Skip to content

Commit

Permalink
Extend test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
julianrojas87 committed Jul 7, 2022
1 parent c440b9f commit d282861
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Gtfsrt2LC.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -626,7 +626,7 @@ class Gtfsrt2LC {
return update;
}

async differentiaUpdate(params) {
async differentialUpdate(params) {
const {
route,
trip,
Expand Down
15 changes: 15 additions & 0 deletions test/gtfsrt2lc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

0 comments on commit d282861

Please sign in to comment.