gtfs 3.8.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/index.d.ts +130 -137
- package/@types/tests.ts +18 -13
- package/CHANGELOG.md +18 -0
- package/README.md +233 -212
- package/config-sample-rtupdates.json +6 -18
- package/lib/advancedQuery.js +8 -17
- package/lib/db.js +35 -59
- package/lib/export.js +16 -10
- package/lib/gtfs/agencies.js +8 -6
- package/lib/gtfs/areas.js +8 -11
- package/lib/gtfs/attributions.js +8 -6
- package/lib/gtfs/calendar-dates.js +8 -6
- package/lib/gtfs/calendars.js +8 -6
- package/lib/gtfs/fare-attributes.js +8 -6
- package/lib/gtfs/fare-leg-rules.js +8 -6
- package/lib/gtfs/fare-products.js +8 -6
- package/lib/gtfs/fare-rules.js +8 -6
- package/lib/gtfs/fare-transfer-rules.js +8 -6
- package/lib/gtfs/feed-info.js +8 -6
- package/lib/gtfs/frequencies.js +8 -6
- package/lib/gtfs/levels.js +8 -11
- package/lib/gtfs/pathways.js +8 -6
- package/lib/gtfs/routes.js +8 -11
- package/lib/gtfs/shapes.js +34 -39
- package/lib/gtfs/stop-areas.js +8 -6
- package/lib/gtfs/stop-times.js +8 -6
- package/lib/gtfs/stops.js +27 -33
- package/lib/gtfs/transfers.js +8 -6
- package/lib/gtfs/translations.js +8 -6
- package/lib/gtfs/trips.js +8 -11
- package/lib/gtfs-realtime/service-alerts.js +9 -7
- package/lib/gtfs-realtime/stop-times-updates.js +9 -7
- package/lib/gtfs-realtime/trip-updates.js +9 -7
- package/lib/gtfs-realtime/vehicle-positions.js +9 -7
- package/lib/gtfs-ride/board-alights.js +8 -6
- package/lib/gtfs-ride/ride-feed-infos.js +8 -6
- package/lib/gtfs-ride/rider-trips.js +8 -6
- package/lib/gtfs-ride/riderships.js +8 -6
- package/lib/gtfs-ride/trip-capacities.js +8 -6
- package/lib/gtfs.js +3 -9
- package/lib/import.js +213 -273
- package/lib/non-standard/directions.js +8 -6
- package/lib/non-standard/stop-attributes.js +8 -6
- package/lib/non-standard/timetable-notes-references.js +8 -6
- package/lib/non-standard/timetable-notes.js +8 -6
- package/lib/non-standard/timetable-pages.js +8 -6
- package/lib/non-standard/timetable-stop-order.js +8 -6
- package/lib/non-standard/timetables.js +8 -6
- package/lib/non-standard/trips-dated-vehicle-journey.js +9 -7
- package/package.json +4 -4
- package/test/mocha/advanced-query.js +9 -15
- package/test/mocha/export-gtfs.js +5 -6
- package/test/mocha/fare-transfer-rules.js +32 -0
- package/test/mocha/get-agencies.js +13 -19
- package/test/mocha/get-areas.js +27 -0
- package/test/mocha/get-attributions.js +7 -13
- package/test/mocha/get-board-alights.js +7 -13
- package/test/mocha/get-calendar-dates.js +11 -17
- package/test/mocha/get-calendars.js +11 -17
- package/test/mocha/get-directions.js +7 -13
- package/test/mocha/get-fare-attributes.js +9 -15
- package/test/mocha/get-fare-leg-rules.js +27 -0
- package/test/mocha/get-fare-products.js +27 -0
- package/test/mocha/get-fare-rules.js +9 -15
- package/test/mocha/get-feed-info.js +7 -13
- package/test/mocha/get-frequencies.js +7 -13
- package/test/mocha/get-levels.js +7 -7
- package/test/mocha/get-pathways.js +7 -13
- package/test/mocha/get-ride-feed-infos.js +7 -13
- package/test/mocha/get-rider-trips.js +7 -13
- package/test/mocha/get-riderships.js +7 -13
- package/test/mocha/get-routes.js +13 -13
- package/test/mocha/get-shapes-as-geojson.js +14 -15
- package/test/mocha/get-shapes.js +25 -25
- package/test/mocha/get-stop-attributes.js +7 -13
- package/test/mocha/get-stops-as-geojson.js +13 -19
- package/test/mocha/get-stops.js +19 -19
- package/test/mocha/get-stoptimes.js +11 -17
- package/test/mocha/get-timetable-pages.js +7 -13
- package/test/mocha/get-timetable-stop-orders.js +6 -7
- package/test/mocha/get-timetables.js +7 -13
- package/test/mocha/get-transfers.js +7 -13
- package/test/mocha/get-translations.js +7 -13
- package/test/mocha/get-trip-capacities.js +7 -13
- package/test/mocha/get-trips.js +9 -9
- package/test/mocha/import-gtfs.js +11 -11
- package/test/mocha/{get-db.js → open-db.js} +37 -29
- package/test/mocha/raw-query.js +34 -0
- package/test/mocha/exec-raw-query.js +0 -39
- package/test/mocha/run-raw-query.js +0 -54
|
@@ -3,39 +3,33 @@
|
|
|
3
3
|
import should from 'should';
|
|
4
4
|
|
|
5
5
|
import config from '../test-config.js';
|
|
6
|
-
import {
|
|
7
|
-
openDb,
|
|
8
|
-
getDb,
|
|
9
|
-
closeDb,
|
|
10
|
-
importGtfs,
|
|
11
|
-
getCalendarDates,
|
|
12
|
-
} from '../../index.js';
|
|
6
|
+
import { openDb, closeDb, importGtfs, getCalendarDates } from '../../index.js';
|
|
13
7
|
|
|
14
8
|
describe('getCalendarDates():', () => {
|
|
15
9
|
before(async () => {
|
|
16
|
-
|
|
10
|
+
openDb(config);
|
|
17
11
|
await importGtfs(config);
|
|
18
12
|
});
|
|
19
13
|
|
|
20
|
-
after(
|
|
21
|
-
const db =
|
|
22
|
-
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
23
17
|
});
|
|
24
18
|
|
|
25
|
-
it('should return empty array if no calendar dates exist',
|
|
19
|
+
it('should return empty array if no calendar dates exist', () => {
|
|
26
20
|
const serviceId = 'fake-service-id';
|
|
27
21
|
|
|
28
|
-
const results =
|
|
22
|
+
const results = getCalendarDates({
|
|
29
23
|
service_id: serviceId,
|
|
30
24
|
});
|
|
31
25
|
should.exists(results);
|
|
32
26
|
results.should.have.length(0);
|
|
33
27
|
});
|
|
34
28
|
|
|
35
|
-
it('should return expected calendar dates',
|
|
29
|
+
it('should return expected calendar dates', () => {
|
|
36
30
|
const serviceId = 'CT-16APR-Caltrain-Weekday-01';
|
|
37
31
|
|
|
38
|
-
const results =
|
|
32
|
+
const results = getCalendarDates({
|
|
39
33
|
service_id: serviceId,
|
|
40
34
|
});
|
|
41
35
|
|
|
@@ -78,10 +72,10 @@ describe('getCalendarDates():', () => {
|
|
|
78
72
|
}
|
|
79
73
|
});
|
|
80
74
|
|
|
81
|
-
it('should return only specific keys for expected calendar dates, sorted by date',
|
|
75
|
+
it('should return only specific keys for expected calendar dates, sorted by date', () => {
|
|
82
76
|
const serviceId = 'CT-16APR-Caltrain-Weekday-01';
|
|
83
77
|
|
|
84
|
-
const results =
|
|
78
|
+
const results = getCalendarDates(
|
|
85
79
|
{
|
|
86
80
|
service_id: serviceId,
|
|
87
81
|
},
|
|
@@ -3,37 +3,31 @@
|
|
|
3
3
|
import should from 'should';
|
|
4
4
|
|
|
5
5
|
import config from '../test-config.js';
|
|
6
|
-
import {
|
|
7
|
-
openDb,
|
|
8
|
-
getDb,
|
|
9
|
-
closeDb,
|
|
10
|
-
importGtfs,
|
|
11
|
-
getCalendars,
|
|
12
|
-
} from '../../index.js';
|
|
6
|
+
import { openDb, closeDb, importGtfs, getCalendars } from '../../index.js';
|
|
13
7
|
|
|
14
8
|
describe('getCalendars():', () => {
|
|
15
9
|
before(async () => {
|
|
16
|
-
|
|
10
|
+
openDb(config);
|
|
17
11
|
await importGtfs(config);
|
|
18
12
|
});
|
|
19
13
|
|
|
20
|
-
after(
|
|
21
|
-
const db =
|
|
22
|
-
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
23
17
|
});
|
|
24
18
|
|
|
25
|
-
it('should return empty array if no calendars',
|
|
19
|
+
it('should return empty array if no calendars', () => {
|
|
26
20
|
const serviceId = 'fake-service-id';
|
|
27
21
|
|
|
28
|
-
const results =
|
|
22
|
+
const results = getCalendars({
|
|
29
23
|
service_id: serviceId,
|
|
30
24
|
});
|
|
31
25
|
should.exists(results);
|
|
32
26
|
results.should.have.length(0);
|
|
33
27
|
});
|
|
34
28
|
|
|
35
|
-
it('should return expected calendars by day',
|
|
36
|
-
const results =
|
|
29
|
+
it('should return expected calendars by day', () => {
|
|
30
|
+
const results = getCalendars({
|
|
37
31
|
sunday: 1,
|
|
38
32
|
});
|
|
39
33
|
|
|
@@ -55,8 +49,8 @@ describe('getCalendars():', () => {
|
|
|
55
49
|
expectedResult.should.match(results[0]);
|
|
56
50
|
});
|
|
57
51
|
|
|
58
|
-
it('should return expected calendars by array of service_ids',
|
|
59
|
-
const results =
|
|
52
|
+
it('should return expected calendars by array of service_ids', () => {
|
|
53
|
+
const results = getCalendars({
|
|
60
54
|
service_id: [
|
|
61
55
|
'CT-16APR-Caltrain-Saturday-02',
|
|
62
56
|
'CT-16APR-Caltrain-Sunday-02',
|
|
@@ -3,29 +3,23 @@
|
|
|
3
3
|
import should from 'should';
|
|
4
4
|
|
|
5
5
|
import config from '../test-config.js';
|
|
6
|
-
import {
|
|
7
|
-
openDb,
|
|
8
|
-
getDb,
|
|
9
|
-
closeDb,
|
|
10
|
-
importGtfs,
|
|
11
|
-
getDirections,
|
|
12
|
-
} from '../../index.js';
|
|
6
|
+
import { openDb, closeDb, importGtfs, getDirections } from '../../index.js';
|
|
13
7
|
|
|
14
8
|
describe('getDirections():', () => {
|
|
15
9
|
before(async () => {
|
|
16
|
-
|
|
10
|
+
openDb(config);
|
|
17
11
|
await importGtfs(config);
|
|
18
12
|
});
|
|
19
13
|
|
|
20
|
-
after(
|
|
21
|
-
const db =
|
|
22
|
-
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
23
17
|
});
|
|
24
18
|
|
|
25
|
-
it('should return empty array if no directions',
|
|
19
|
+
it('should return empty array if no directions', () => {
|
|
26
20
|
const fareRouteId = 'not_real';
|
|
27
21
|
|
|
28
|
-
const results =
|
|
22
|
+
const results = getDirections({
|
|
29
23
|
route_id: fareRouteId,
|
|
30
24
|
});
|
|
31
25
|
should.exists(results);
|
|
@@ -3,29 +3,23 @@
|
|
|
3
3
|
import should from 'should';
|
|
4
4
|
|
|
5
5
|
import config from '../test-config.js';
|
|
6
|
-
import {
|
|
7
|
-
openDb,
|
|
8
|
-
getDb,
|
|
9
|
-
closeDb,
|
|
10
|
-
importGtfs,
|
|
11
|
-
getFareAttributes,
|
|
12
|
-
} from '../../index.js';
|
|
6
|
+
import { openDb, closeDb, importGtfs, getFareAttributes } from '../../index.js';
|
|
13
7
|
|
|
14
8
|
describe('getFareAttributes():', () => {
|
|
15
9
|
before(async () => {
|
|
16
|
-
|
|
10
|
+
openDb(config);
|
|
17
11
|
await importGtfs(config);
|
|
18
12
|
});
|
|
19
13
|
|
|
20
|
-
after(
|
|
21
|
-
const db =
|
|
22
|
-
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
23
17
|
});
|
|
24
18
|
|
|
25
|
-
it('should return empty array if no fare_attributes',
|
|
19
|
+
it('should return empty array if no fare_attributes', () => {
|
|
26
20
|
const fareId = 'not_real';
|
|
27
21
|
|
|
28
|
-
const results =
|
|
22
|
+
const results = getFareAttributes({
|
|
29
23
|
fare_id: fareId,
|
|
30
24
|
});
|
|
31
25
|
|
|
@@ -33,10 +27,10 @@ describe('getFareAttributes():', () => {
|
|
|
33
27
|
results.should.have.length(0);
|
|
34
28
|
});
|
|
35
29
|
|
|
36
|
-
it('should return expected fare_attributes',
|
|
30
|
+
it('should return expected fare_attributes', () => {
|
|
37
31
|
const fareId = 'OW_1_20160228';
|
|
38
32
|
|
|
39
|
-
const results =
|
|
33
|
+
const results = getFareAttributes({
|
|
40
34
|
fare_id: fareId,
|
|
41
35
|
});
|
|
42
36
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
|
|
3
|
+
import should from 'should';
|
|
4
|
+
|
|
5
|
+
import config from '../test-config.js';
|
|
6
|
+
import { openDb, closeDb, importGtfs, getFareLegRules } from '../../index.js';
|
|
7
|
+
|
|
8
|
+
describe('getFareLegRules():', () => {
|
|
9
|
+
before(async () => {
|
|
10
|
+
openDb(config);
|
|
11
|
+
await importGtfs(config);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should return empty array if no fare_leg_rules exist', () => {
|
|
20
|
+
const legGroupId = 'fake-leg-group-id';
|
|
21
|
+
const results = getFareLegRules({
|
|
22
|
+
leg_group_id: legGroupId,
|
|
23
|
+
});
|
|
24
|
+
should.exists(results);
|
|
25
|
+
results.should.have.length(0);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
|
|
3
|
+
import should from 'should';
|
|
4
|
+
|
|
5
|
+
import config from '../test-config.js';
|
|
6
|
+
import { openDb, closeDb, importGtfs, getFareProducts } from '../../index.js';
|
|
7
|
+
|
|
8
|
+
describe('getFareProducts():', () => {
|
|
9
|
+
before(async () => {
|
|
10
|
+
openDb(config);
|
|
11
|
+
await importGtfs(config);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should return empty array if no fare_products exist', () => {
|
|
20
|
+
const fareProductId = 'fake-fare-product-id';
|
|
21
|
+
const results = getFareProducts({
|
|
22
|
+
fare_product_id: fareProductId,
|
|
23
|
+
});
|
|
24
|
+
should.exists(results);
|
|
25
|
+
results.should.have.length(0);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -3,39 +3,33 @@
|
|
|
3
3
|
import should from 'should';
|
|
4
4
|
|
|
5
5
|
import config from '../test-config.js';
|
|
6
|
-
import {
|
|
7
|
-
openDb,
|
|
8
|
-
getDb,
|
|
9
|
-
closeDb,
|
|
10
|
-
importGtfs,
|
|
11
|
-
getFareRules,
|
|
12
|
-
} from '../../index.js';
|
|
6
|
+
import { openDb, closeDb, importGtfs, getFareRules } from '../../index.js';
|
|
13
7
|
|
|
14
8
|
describe('getFareRules():', () => {
|
|
15
9
|
before(async () => {
|
|
16
|
-
|
|
10
|
+
openDb(config);
|
|
17
11
|
await importGtfs(config);
|
|
18
12
|
});
|
|
19
13
|
|
|
20
|
-
after(
|
|
21
|
-
const db =
|
|
22
|
-
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
23
17
|
});
|
|
24
18
|
|
|
25
|
-
it('should return empty array if no fare_rules',
|
|
19
|
+
it('should return empty array if no fare_rules', () => {
|
|
26
20
|
const routeId = 'not_real';
|
|
27
21
|
|
|
28
|
-
const results =
|
|
22
|
+
const results = getFareRules({
|
|
29
23
|
route_id: routeId,
|
|
30
24
|
});
|
|
31
25
|
should.exists(results);
|
|
32
26
|
results.should.have.length(0);
|
|
33
27
|
});
|
|
34
28
|
|
|
35
|
-
it('should return expected fare_rules',
|
|
29
|
+
it('should return expected fare_rules', () => {
|
|
36
30
|
const routeId = 'Bu-16APR';
|
|
37
31
|
|
|
38
|
-
const results =
|
|
32
|
+
const results = getFareRules(
|
|
39
33
|
{
|
|
40
34
|
route_id: routeId,
|
|
41
35
|
},
|
|
@@ -3,29 +3,23 @@
|
|
|
3
3
|
import should from 'should';
|
|
4
4
|
|
|
5
5
|
import config from '../test-config.js';
|
|
6
|
-
import {
|
|
7
|
-
openDb,
|
|
8
|
-
getDb,
|
|
9
|
-
closeDb,
|
|
10
|
-
importGtfs,
|
|
11
|
-
getFeedInfo,
|
|
12
|
-
} from '../../index.js';
|
|
6
|
+
import { openDb, closeDb, importGtfs, getFeedInfo } from '../../index.js';
|
|
13
7
|
|
|
14
8
|
describe('getFeedInfo():', () => {
|
|
15
9
|
before(async () => {
|
|
16
|
-
|
|
10
|
+
openDb(config);
|
|
17
11
|
await importGtfs(config);
|
|
18
12
|
});
|
|
19
13
|
|
|
20
|
-
after(
|
|
21
|
-
const db =
|
|
22
|
-
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
23
17
|
});
|
|
24
18
|
|
|
25
|
-
it('should return empty array if no feed info',
|
|
19
|
+
it('should return empty array if no feed info', () => {
|
|
26
20
|
const feedPublisherName = 'not_real';
|
|
27
21
|
|
|
28
|
-
const results =
|
|
22
|
+
const results = getFeedInfo({
|
|
29
23
|
feed_publisher_name: feedPublisherName,
|
|
30
24
|
});
|
|
31
25
|
should.exists(results);
|
|
@@ -3,29 +3,23 @@
|
|
|
3
3
|
import should from 'should';
|
|
4
4
|
|
|
5
5
|
import config from '../test-config.js';
|
|
6
|
-
import {
|
|
7
|
-
openDb,
|
|
8
|
-
getDb,
|
|
9
|
-
closeDb,
|
|
10
|
-
importGtfs,
|
|
11
|
-
getFrequencies,
|
|
12
|
-
} from '../../index.js';
|
|
6
|
+
import { openDb, closeDb, importGtfs, getFrequencies } from '../../index.js';
|
|
13
7
|
|
|
14
8
|
describe('getFrequencies():', () => {
|
|
15
9
|
before(async () => {
|
|
16
|
-
|
|
10
|
+
openDb(config);
|
|
17
11
|
await importGtfs(config);
|
|
18
12
|
});
|
|
19
13
|
|
|
20
|
-
after(
|
|
21
|
-
const db =
|
|
22
|
-
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
23
17
|
});
|
|
24
18
|
|
|
25
|
-
it('should return empty array if no frequencies',
|
|
19
|
+
it('should return empty array if no frequencies', () => {
|
|
26
20
|
const tripId = 'not_real';
|
|
27
21
|
|
|
28
|
-
const results =
|
|
22
|
+
const results = getFrequencies({
|
|
29
23
|
trip_id: tripId,
|
|
30
24
|
});
|
|
31
25
|
should.exists(results);
|
package/test/mocha/get-levels.js
CHANGED
|
@@ -3,23 +3,23 @@
|
|
|
3
3
|
import should from 'should';
|
|
4
4
|
|
|
5
5
|
import config from '../test-config.js';
|
|
6
|
-
import { openDb,
|
|
6
|
+
import { openDb, closeDb, importGtfs, getLevels } from '../../index.js';
|
|
7
7
|
|
|
8
8
|
describe('getLevels():', () => {
|
|
9
9
|
before(async () => {
|
|
10
|
-
|
|
10
|
+
openDb(config);
|
|
11
11
|
await importGtfs(config);
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
after(
|
|
15
|
-
const db =
|
|
16
|
-
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
it('should return empty array if no levels',
|
|
19
|
+
it('should return empty array if no levels', () => {
|
|
20
20
|
const levelId = 'not_real';
|
|
21
21
|
|
|
22
|
-
const results =
|
|
22
|
+
const results = getLevels({
|
|
23
23
|
level_id: levelId,
|
|
24
24
|
});
|
|
25
25
|
should.exists(results);
|
|
@@ -3,29 +3,23 @@
|
|
|
3
3
|
import should from 'should';
|
|
4
4
|
|
|
5
5
|
import config from '../test-config.js';
|
|
6
|
-
import {
|
|
7
|
-
openDb,
|
|
8
|
-
getDb,
|
|
9
|
-
closeDb,
|
|
10
|
-
importGtfs,
|
|
11
|
-
getPathways,
|
|
12
|
-
} from '../../index.js';
|
|
6
|
+
import { openDb, closeDb, importGtfs, getPathways } from '../../index.js';
|
|
13
7
|
|
|
14
8
|
describe('getPathways():', () => {
|
|
15
9
|
before(async () => {
|
|
16
|
-
|
|
10
|
+
openDb(config);
|
|
17
11
|
await importGtfs(config);
|
|
18
12
|
});
|
|
19
13
|
|
|
20
|
-
after(
|
|
21
|
-
const db =
|
|
22
|
-
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
23
17
|
});
|
|
24
18
|
|
|
25
|
-
it('should return empty array if no pathways',
|
|
19
|
+
it('should return empty array if no pathways', () => {
|
|
26
20
|
const pathwayId = 'not_real';
|
|
27
21
|
|
|
28
|
-
const results =
|
|
22
|
+
const results = getPathways({
|
|
29
23
|
pathway_id: pathwayId,
|
|
30
24
|
});
|
|
31
25
|
should.exists(results);
|
|
@@ -3,27 +3,21 @@
|
|
|
3
3
|
import should from 'should';
|
|
4
4
|
|
|
5
5
|
import config from '../test-config.js';
|
|
6
|
-
import {
|
|
7
|
-
openDb,
|
|
8
|
-
getDb,
|
|
9
|
-
closeDb,
|
|
10
|
-
importGtfs,
|
|
11
|
-
getRideFeedInfos,
|
|
12
|
-
} from '../../index.js';
|
|
6
|
+
import { openDb, closeDb, importGtfs, getRideFeedInfos } from '../../index.js';
|
|
13
7
|
|
|
14
8
|
describe('getRideFeedInfos():', () => {
|
|
15
9
|
before(async () => {
|
|
16
|
-
|
|
10
|
+
openDb(config);
|
|
17
11
|
await importGtfs(config);
|
|
18
12
|
});
|
|
19
13
|
|
|
20
|
-
after(
|
|
21
|
-
const db =
|
|
22
|
-
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
23
17
|
});
|
|
24
18
|
|
|
25
|
-
it('should return empty array if no ride-feed-infos (GTFS-ride)',
|
|
26
|
-
const results =
|
|
19
|
+
it('should return empty array if no ride-feed-infos (GTFS-ride)', () => {
|
|
20
|
+
const results = getRideFeedInfos({});
|
|
27
21
|
should.exists(results);
|
|
28
22
|
results.should.have.length(0);
|
|
29
23
|
});
|
|
@@ -3,29 +3,23 @@
|
|
|
3
3
|
import should from 'should';
|
|
4
4
|
|
|
5
5
|
import config from '../test-config.js';
|
|
6
|
-
import {
|
|
7
|
-
openDb,
|
|
8
|
-
getDb,
|
|
9
|
-
closeDb,
|
|
10
|
-
importGtfs,
|
|
11
|
-
getRiderTrips,
|
|
12
|
-
} from '../../index.js';
|
|
6
|
+
import { openDb, closeDb, importGtfs, getRiderTrips } from '../../index.js';
|
|
13
7
|
|
|
14
8
|
describe('getRiderTrips():', () => {
|
|
15
9
|
before(async () => {
|
|
16
|
-
|
|
10
|
+
openDb(config);
|
|
17
11
|
await importGtfs(config);
|
|
18
12
|
});
|
|
19
13
|
|
|
20
|
-
after(
|
|
21
|
-
const db =
|
|
22
|
-
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
23
17
|
});
|
|
24
18
|
|
|
25
|
-
it('should return empty array if no rider trips (GTFS-ride)',
|
|
19
|
+
it('should return empty array if no rider trips (GTFS-ride)', () => {
|
|
26
20
|
const tripId = 'fake-trip-id';
|
|
27
21
|
|
|
28
|
-
const results =
|
|
22
|
+
const results = getRiderTrips({
|
|
29
23
|
trip_id: tripId,
|
|
30
24
|
});
|
|
31
25
|
should.exists(results);
|
|
@@ -3,29 +3,23 @@
|
|
|
3
3
|
import should from 'should';
|
|
4
4
|
|
|
5
5
|
import config from '../test-config.js';
|
|
6
|
-
import {
|
|
7
|
-
openDb,
|
|
8
|
-
getDb,
|
|
9
|
-
closeDb,
|
|
10
|
-
importGtfs,
|
|
11
|
-
getRiderships,
|
|
12
|
-
} from '../../index.js';
|
|
6
|
+
import { openDb, closeDb, importGtfs, getRiderships } from '../../index.js';
|
|
13
7
|
|
|
14
8
|
describe('getRiderships():', () => {
|
|
15
9
|
before(async () => {
|
|
16
|
-
|
|
10
|
+
openDb(config);
|
|
17
11
|
await importGtfs(config);
|
|
18
12
|
});
|
|
19
13
|
|
|
20
|
-
after(
|
|
21
|
-
const db =
|
|
22
|
-
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
23
17
|
});
|
|
24
18
|
|
|
25
|
-
it('should return empty array if no riderships (GTFS-ride)',
|
|
19
|
+
it('should return empty array if no riderships (GTFS-ride)', () => {
|
|
26
20
|
const routeId = 'fake-route-id';
|
|
27
21
|
|
|
28
|
-
const results =
|
|
22
|
+
const results = getRiderships({
|
|
29
23
|
route_id: routeId,
|
|
30
24
|
});
|
|
31
25
|
should.exists(results);
|
package/test/mocha/get-routes.js
CHANGED
|
@@ -3,31 +3,31 @@
|
|
|
3
3
|
import should from 'should';
|
|
4
4
|
|
|
5
5
|
import config from '../test-config.js';
|
|
6
|
-
import { openDb,
|
|
6
|
+
import { openDb, closeDb, importGtfs, getRoutes } from '../../index.js';
|
|
7
7
|
|
|
8
8
|
describe('getRoutes():', () => {
|
|
9
9
|
before(async () => {
|
|
10
|
-
|
|
10
|
+
openDb(config);
|
|
11
11
|
await importGtfs(config);
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
after(
|
|
15
|
-
const db =
|
|
16
|
-
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
it('should return empty array if no routes for given agency exist',
|
|
19
|
+
it('should return empty array if no routes for given agency exist', () => {
|
|
20
20
|
const routeId = 'fake-route-id';
|
|
21
21
|
|
|
22
|
-
const results =
|
|
22
|
+
const results = getRoutes({
|
|
23
23
|
route_id: routeId,
|
|
24
24
|
});
|
|
25
25
|
should.exists(results);
|
|
26
26
|
results.should.have.length(0);
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
it('should return expected routes',
|
|
30
|
-
const results =
|
|
29
|
+
it('should return expected routes', () => {
|
|
30
|
+
const results = getRoutes({}, [], [['route_long_name', 'ASC']]);
|
|
31
31
|
|
|
32
32
|
const expectedResults = [
|
|
33
33
|
{
|
|
@@ -97,8 +97,8 @@ describe('getRoutes():', () => {
|
|
|
97
97
|
expectedResults.should.match(results);
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
it('should return expected routes for a specific stop_id',
|
|
101
|
-
const results =
|
|
100
|
+
it('should return expected routes for a specific stop_id', () => {
|
|
101
|
+
const results = getRoutes(
|
|
102
102
|
{ stop_id: '70321' },
|
|
103
103
|
[],
|
|
104
104
|
[['route_long_name', 'ASC']]
|
|
@@ -127,8 +127,8 @@ describe('getRoutes():', () => {
|
|
|
127
127
|
expectedResults.should.match(results);
|
|
128
128
|
});
|
|
129
129
|
|
|
130
|
-
it('should return no routes for a invalid stop_id',
|
|
131
|
-
const results =
|
|
130
|
+
it('should return no routes for a invalid stop_id', () => {
|
|
131
|
+
const results = getRoutes(
|
|
132
132
|
{ stop_id: 'not-valid' },
|
|
133
133
|
[],
|
|
134
134
|
[['route_long_name', 'ASC']]
|