Skip to content

Commit

Permalink
Test for Utils functions
Browse files Browse the repository at this point in the history
  • Loading branch information
julianrojas87 committed Sep 27, 2022
1 parent 21ade40 commit fb67f2e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/gtfsrt2lc.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const fs = require('fs');
const del = require('del');
const uri_templates = require('uri-templates');
const GtfsIndex = require('../lib/GtfsIndex');
const Gtfsrt2lc = require('../lib/Gtfsrt2LC');
const Utils = require('../lib/Utils');
Expand Down Expand Up @@ -582,4 +583,24 @@ test('Cover GtfsIndex functions', async () => {
try {
await gti.getIndexes();
} catch (err) { }
});

test('Cover Utils functions', async () => {
// Test for resolve ScheduleRelationship
const regular = Utils.resolveScheduleRelationship(0);
const notAvailable = Utils.resolveScheduleRelationship(1);
const mustPhone = Utils.resolveScheduleRelationship(2);
const mustCoordinate = Utils.resolveScheduleRelationship(3);

// Test for URI building function
const connTimes = Utils.resolveURI(
uri_templates("http://example.org/test/{connection.departureTime(yyyyMMdd'T'HHmm)}/{connection.arrivalTime(yyyyMMdd'T'HHmm)}"),
{ departureTime: new Date('Sep 27 2022 19:00:00 GMT+0200'), arrivalTime: new Date('Sep 27 2022 19:10:00 GMT+0200') }
);

expect(regular).toBe('gtfs:Regular');
expect(notAvailable).toBe('gtfs:NotAvailable');
expect(mustPhone).toBe('gtfs:MustPhone');
expect(mustCoordinate).toBe('gtfs:MustCoordinateWithDriver');
expect(connTimes).toBe("http://example.org/test/20220927T1900/20220927T1910")
});

0 comments on commit fb67f2e

Please sign in to comment.