gtfs 3.8.0 → 4.0.0

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.
Files changed (89) hide show
  1. package/@types/index.d.ts +35 -60
  2. package/@types/tests.ts +18 -13
  3. package/CHANGELOG.md +10 -0
  4. package/README.md +227 -207
  5. package/lib/advancedQuery.js +8 -17
  6. package/lib/db.js +29 -59
  7. package/lib/export.js +16 -10
  8. package/lib/gtfs/agencies.js +8 -6
  9. package/lib/gtfs/areas.js +8 -11
  10. package/lib/gtfs/attributions.js +8 -6
  11. package/lib/gtfs/calendar-dates.js +8 -6
  12. package/lib/gtfs/calendars.js +8 -6
  13. package/lib/gtfs/fare-attributes.js +8 -6
  14. package/lib/gtfs/fare-leg-rules.js +8 -6
  15. package/lib/gtfs/fare-products.js +8 -6
  16. package/lib/gtfs/fare-rules.js +8 -6
  17. package/lib/gtfs/fare-transfer-rules.js +8 -6
  18. package/lib/gtfs/feed-info.js +8 -6
  19. package/lib/gtfs/frequencies.js +8 -6
  20. package/lib/gtfs/levels.js +8 -11
  21. package/lib/gtfs/pathways.js +8 -6
  22. package/lib/gtfs/routes.js +8 -11
  23. package/lib/gtfs/shapes.js +34 -39
  24. package/lib/gtfs/stop-areas.js +8 -6
  25. package/lib/gtfs/stop-times.js +8 -6
  26. package/lib/gtfs/stops.js +27 -33
  27. package/lib/gtfs/transfers.js +8 -6
  28. package/lib/gtfs/translations.js +8 -6
  29. package/lib/gtfs/trips.js +8 -11
  30. package/lib/gtfs-realtime/service-alerts.js +9 -7
  31. package/lib/gtfs-realtime/stop-times-updates.js +9 -7
  32. package/lib/gtfs-realtime/trip-updates.js +9 -7
  33. package/lib/gtfs-realtime/vehicle-positions.js +9 -7
  34. package/lib/gtfs-ride/board-alights.js +8 -6
  35. package/lib/gtfs-ride/ride-feed-infos.js +8 -6
  36. package/lib/gtfs-ride/rider-trips.js +8 -6
  37. package/lib/gtfs-ride/riderships.js +8 -6
  38. package/lib/gtfs-ride/trip-capacities.js +8 -6
  39. package/lib/gtfs.js +3 -9
  40. package/lib/import.js +195 -202
  41. package/lib/non-standard/directions.js +8 -6
  42. package/lib/non-standard/stop-attributes.js +8 -6
  43. package/lib/non-standard/timetable-notes-references.js +8 -6
  44. package/lib/non-standard/timetable-notes.js +8 -6
  45. package/lib/non-standard/timetable-pages.js +8 -6
  46. package/lib/non-standard/timetable-stop-order.js +8 -6
  47. package/lib/non-standard/timetables.js +8 -6
  48. package/lib/non-standard/trips-dated-vehicle-journey.js +9 -7
  49. package/package.json +2 -3
  50. package/test/mocha/advanced-query.js +9 -15
  51. package/test/mocha/export-gtfs.js +5 -6
  52. package/test/mocha/fare-transfer-rules.js +32 -0
  53. package/test/mocha/get-agencies.js +13 -19
  54. package/test/mocha/get-areas.js +27 -0
  55. package/test/mocha/get-attributions.js +7 -13
  56. package/test/mocha/get-board-alights.js +7 -13
  57. package/test/mocha/get-calendar-dates.js +11 -17
  58. package/test/mocha/get-calendars.js +11 -17
  59. package/test/mocha/get-directions.js +7 -13
  60. package/test/mocha/get-fare-attributes.js +9 -15
  61. package/test/mocha/get-fare-leg-rules.js +27 -0
  62. package/test/mocha/get-fare-products.js +27 -0
  63. package/test/mocha/get-fare-rules.js +9 -15
  64. package/test/mocha/get-feed-info.js +7 -13
  65. package/test/mocha/get-frequencies.js +7 -13
  66. package/test/mocha/get-levels.js +7 -7
  67. package/test/mocha/get-pathways.js +7 -13
  68. package/test/mocha/get-ride-feed-infos.js +7 -13
  69. package/test/mocha/get-rider-trips.js +7 -13
  70. package/test/mocha/get-riderships.js +7 -13
  71. package/test/mocha/get-routes.js +13 -13
  72. package/test/mocha/get-shapes-as-geojson.js +14 -15
  73. package/test/mocha/get-shapes.js +25 -25
  74. package/test/mocha/get-stop-attributes.js +7 -13
  75. package/test/mocha/get-stops-as-geojson.js +13 -19
  76. package/test/mocha/get-stops.js +19 -19
  77. package/test/mocha/get-stoptimes.js +11 -17
  78. package/test/mocha/get-timetable-pages.js +7 -13
  79. package/test/mocha/get-timetable-stop-orders.js +6 -7
  80. package/test/mocha/get-timetables.js +7 -13
  81. package/test/mocha/get-transfers.js +7 -13
  82. package/test/mocha/get-translations.js +7 -13
  83. package/test/mocha/get-trip-capacities.js +7 -13
  84. package/test/mocha/get-trips.js +9 -9
  85. package/test/mocha/import-gtfs.js +11 -11
  86. package/test/mocha/{get-db.js → open-db.js} +37 -29
  87. package/test/mocha/raw-query.js +34 -0
  88. package/test/mocha/exec-raw-query.js +0 -39
  89. package/test/mocha/run-raw-query.js +0 -54
@@ -1,6 +1,6 @@
1
1
  import sqlString from 'sqlstring-sqlite';
2
2
 
3
- import { getDb } from '../db.js';
3
+ import { openDb } from '../db.js';
4
4
 
5
5
  import {
6
6
  formatOrderByClause,
@@ -12,19 +12,21 @@ import timetableNotesReferences from '../../models/non-standard/timetable-notes-
12
12
  /*
13
13
  * Returns an array of all timetable notes references that match the query parameters.
14
14
  */
15
- export async function getTimetableNotesReferences(
15
+ export function getTimetableNotesReferences(
16
16
  query = {},
17
17
  fields = [],
18
18
  orderBy = [],
19
19
  options = {}
20
20
  ) {
21
- const db = options.db ?? (await getDb());
21
+ const db = options.db ?? openDb();
22
22
  const tableName = sqlString.escapeId(timetableNotesReferences.filenameBase);
23
23
  const selectClause = formatSelectClause(fields);
24
24
  const whereClause = formatWhereClauses(query);
25
25
  const orderByClause = formatOrderByClause(orderBy);
26
26
 
27
- return db.all(
28
- `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
29
- );
27
+ return db
28
+ .prepare(
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
30
+ )
31
+ .all();
30
32
  }
@@ -1,6 +1,6 @@
1
1
  import sqlString from 'sqlstring-sqlite';
2
2
 
3
- import { getDb } from '../db.js';
3
+ import { openDb } from '../db.js';
4
4
 
5
5
  import {
6
6
  formatOrderByClause,
@@ -12,19 +12,21 @@ import timetableNotes from '../../models/non-standard/timetable-notes.js';
12
12
  /*
13
13
  * Returns an array of all timetable notes that match the query parameters.
14
14
  */
15
- export async function getTimetableNotes(
15
+ export function getTimetableNotes(
16
16
  query = {},
17
17
  fields = [],
18
18
  orderBy = [],
19
19
  options = {}
20
20
  ) {
21
- const db = options.db ?? (await getDb());
21
+ const db = options.db ?? openDb();
22
22
  const tableName = sqlString.escapeId(timetableNotes.filenameBase);
23
23
  const selectClause = formatSelectClause(fields);
24
24
  const whereClause = formatWhereClauses(query);
25
25
  const orderByClause = formatOrderByClause(orderBy);
26
26
 
27
- return db.all(
28
- `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
29
- );
27
+ return db
28
+ .prepare(
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
30
+ )
31
+ .all();
30
32
  }
@@ -1,6 +1,6 @@
1
1
  import sqlString from 'sqlstring-sqlite';
2
2
 
3
- import { getDb } from '../db.js';
3
+ import { openDb } from '../db.js';
4
4
 
5
5
  import {
6
6
  formatOrderByClause,
@@ -12,19 +12,21 @@ import timetablePages from '../../models/non-standard/timetable-pages.js';
12
12
  /*
13
13
  * Returns an array of all timetable pages that match the query parameters.
14
14
  */
15
- export async function getTimetablePages(
15
+ export function getTimetablePages(
16
16
  query = {},
17
17
  fields = [],
18
18
  orderBy = [],
19
19
  options = {}
20
20
  ) {
21
- const db = options.db ?? (await getDb());
21
+ const db = options.db ?? openDb();
22
22
  const tableName = sqlString.escapeId(timetablePages.filenameBase);
23
23
  const selectClause = formatSelectClause(fields);
24
24
  const whereClause = formatWhereClauses(query);
25
25
  const orderByClause = formatOrderByClause(orderBy);
26
26
 
27
- return db.all(
28
- `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
29
- );
27
+ return db
28
+ .prepare(
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
30
+ )
31
+ .all();
30
32
  }
@@ -1,6 +1,6 @@
1
1
  import sqlString from 'sqlstring-sqlite';
2
2
 
3
- import { getDb } from '../db.js';
3
+ import { openDb } from '../db.js';
4
4
 
5
5
  import {
6
6
  formatOrderByClause,
@@ -12,19 +12,21 @@ import timetableStopOrder from '../../models/non-standard/timetable-stop-order.j
12
12
  /*
13
13
  * Returns an array of all timetable stop orders that match the query parameters.
14
14
  */
15
- export async function getTimetableStopOrders(
15
+ export function getTimetableStopOrders(
16
16
  query = {},
17
17
  fields = [],
18
18
  orderBy = [],
19
19
  options = {}
20
20
  ) {
21
- const db = options.db ?? (await getDb());
21
+ const db = options.db ?? openDb();
22
22
  const tableName = sqlString.escapeId(timetableStopOrder.filenameBase);
23
23
  const selectClause = formatSelectClause(fields);
24
24
  const whereClause = formatWhereClauses(query);
25
25
  const orderByClause = formatOrderByClause(orderBy);
26
26
 
27
- return db.all(
28
- `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
29
- );
27
+ return db
28
+ .prepare(
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
30
+ )
31
+ .all();
30
32
  }
@@ -1,6 +1,6 @@
1
1
  import sqlString from 'sqlstring-sqlite';
2
2
 
3
- import { getDb } from '../db.js';
3
+ import { openDb } from '../db.js';
4
4
 
5
5
  import {
6
6
  formatOrderByClause,
@@ -12,19 +12,21 @@ import timetables from '../../models/non-standard/timetables.js';
12
12
  /*
13
13
  * Returns an array of all timetables that match the query parameters.
14
14
  */
15
- export async function getTimetables(
15
+ export function getTimetables(
16
16
  query = {},
17
17
  fields = [],
18
18
  orderBy = [],
19
19
  options = {}
20
20
  ) {
21
- const db = options.db ?? (await getDb());
21
+ const db = options.db ?? openDb();
22
22
  const tableName = sqlString.escapeId(timetables.filenameBase);
23
23
  const selectClause = formatSelectClause(fields);
24
24
  const whereClause = formatWhereClauses(query);
25
25
  const orderByClause = formatOrderByClause(orderBy);
26
26
 
27
- return db.all(
28
- `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
29
- );
27
+ return db
28
+ .prepare(
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
30
+ )
31
+ .all();
30
32
  }
@@ -1,6 +1,6 @@
1
1
  import sqlString from 'sqlstring-sqlite';
2
2
 
3
- import { getDb } from '../db.js';
3
+ import { openDb } from '../db.js';
4
4
 
5
5
  import {
6
6
  formatOrderByClause,
@@ -10,21 +10,23 @@ import {
10
10
  import directions from '../../models/non-standard/trips-dated-vehicle-journey.js';
11
11
 
12
12
  /*
13
- * Returns an array of all directions that match the query parameters.
13
+ * Returns an array of all trips dated vehicle journeys that match the query parameters.
14
14
  */
15
- export async function getTripsDatedVehicleJourneys(
15
+ export function getTripsDatedVehicleJourneys(
16
16
  query = {},
17
17
  fields = [],
18
18
  orderBy = [],
19
19
  options = {}
20
20
  ) {
21
- const db = options.db ?? (await getDb());
21
+ const db = options.db ?? openDb();
22
22
  const tableName = sqlString.escapeId(directions.filenameBase);
23
23
  const selectClause = formatSelectClause(fields);
24
24
  const whereClause = formatWhereClauses(query);
25
25
  const orderByClause = formatOrderByClause(orderBy);
26
26
 
27
- return db.all(
28
- `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
29
- );
27
+ return db
28
+ .prepare(
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
30
+ )
31
+ .all();
30
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtfs",
3
- "version": "3.8.0",
3
+ "version": "4.0.0",
4
4
  "description": "Import GTFS transit data into SQLite and query routes, stops, times, fares and more",
5
5
  "keywords": [
6
6
  "transit",
@@ -74,6 +74,7 @@
74
74
  },
75
75
  "dependencies": {
76
76
  "@turf/helpers": "^6.5.0",
77
+ "better-sqlite3": "^8.0.1",
77
78
  "csv-parse": "^5.3.3",
78
79
  "csv-stringify": "^6.2.3",
79
80
  "gtfs-realtime-bindings": "^0.0.6",
@@ -85,8 +86,6 @@
85
86
  "promise-map-series": "^0.3.0",
86
87
  "recursive-copy": "^2.0.14",
87
88
  "sanitize-filename": "^1.6.3",
88
- "sqlite": "^4.1.2",
89
- "sqlite3": "^5.1.4",
90
89
  "sqlstring-sqlite": "^0.1.1",
91
90
  "strip-bom-stream": "^5.0.0",
92
91
  "tmp-promise": "^3.0.3",
@@ -3,26 +3,20 @@
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
- advancedQuery,
12
- } from '../../index.js';
6
+ import { openDb, closeDb, importGtfs, advancedQuery } from '../../index.js';
13
7
 
14
8
  describe('advancedQuery():', () => {
15
9
  before(async () => {
16
- await openDb(config);
10
+ openDb(config);
17
11
  await importGtfs(config);
18
12
  });
19
13
 
20
- after(async () => {
21
- const db = getDb(config);
22
- await closeDb(db);
14
+ after(() => {
15
+ const db = openDb(config);
16
+ closeDb(db);
23
17
  });
24
18
 
25
- it('should return empty array if no trips', async () => {
19
+ it('should return empty array if no trips', () => {
26
20
  const routeId = 'fake-route-id';
27
21
 
28
22
  const advancedQueryOptions = {
@@ -38,13 +32,13 @@ describe('advancedQuery():', () => {
38
32
  },
39
33
  ],
40
34
  };
41
- const results = await advancedQuery('stop_times', advancedQueryOptions);
35
+ const results = advancedQuery('stop_times', advancedQueryOptions);
42
36
 
43
37
  should.exists(results);
44
38
  results.should.have.length(0);
45
39
  });
46
40
 
47
- it('should return expected trips with joined trip', async () => {
41
+ it('should return expected trips with joined trip', () => {
48
42
  const tripId = '329';
49
43
 
50
44
  const advancedQueryOptions = {
@@ -60,7 +54,7 @@ describe('advancedQuery():', () => {
60
54
  },
61
55
  ],
62
56
  };
63
- const results = await advancedQuery('stop_times', advancedQueryOptions);
57
+ const results = advancedQuery('stop_times', advancedQueryOptions);
64
58
 
65
59
  const expectedResults = [
66
60
  { trip_id: '329', arrival_time: '9:09:00' },
@@ -12,7 +12,6 @@ import { unzip, generateFolderName } from '../../lib/file-utils.js';
12
12
  import config from '../test-config.js';
13
13
  import {
14
14
  openDb,
15
- getDb,
16
15
  closeDb,
17
16
  importGtfs,
18
17
  exportGtfs,
@@ -22,13 +21,13 @@ import models from '../../models/models.js';
22
21
 
23
22
  describe('exportGtfs():', function () {
24
23
  before(async () => {
25
- await openDb(config);
24
+ openDb(config);
26
25
  await importGtfs(config);
27
26
  });
28
27
 
29
28
  after(async () => {
30
- const db = getDb(config);
31
- await closeDb(db);
29
+ const db = openDb(config);
30
+ closeDb(db);
32
31
  });
33
32
 
34
33
  this.timeout(10000);
@@ -86,7 +85,7 @@ describe('exportGtfs():', function () {
86
85
  });
87
86
 
88
87
  after(async () => {
89
- const agencies = await getAgencies({}, ['agency_name']);
88
+ const agencies = getAgencies({}, ['agency_name']);
90
89
  await rm(
91
90
  path.join(
92
91
  process.cwd(),
@@ -99,7 +98,7 @@ describe('exportGtfs():', function () {
99
98
 
100
99
  for (const model of models) {
101
100
  it(`should import the same number of ${model.filenameBase}`, async () => {
102
- const agencies = await getAgencies({}, ['agency_name']);
101
+ const agencies = getAgencies({}, ['agency_name']);
103
102
  const filePath = path.join(
104
103
  process.cwd(),
105
104
  'gtfs-export',
@@ -0,0 +1,32 @@
1
+ /* eslint-env mocha */
2
+
3
+ import should from 'should';
4
+
5
+ import config from '../test-config.js';
6
+ import {
7
+ openDb,
8
+ closeDb,
9
+ importGtfs,
10
+ getFareTransferRules,
11
+ } from '../../index.js';
12
+
13
+ describe('getFareTransferRules():', () => {
14
+ before(async () => {
15
+ openDb(config);
16
+ await importGtfs(config);
17
+ });
18
+
19
+ after(() => {
20
+ const db = openDb(config);
21
+ closeDb(db);
22
+ });
23
+
24
+ it('should return empty array if no fare_transfer_rules exist', () => {
25
+ const transferId = 'fake-transfer-id';
26
+ const results = getFareTransferRules({
27
+ transfer_id: transferId,
28
+ });
29
+ should.exists(results);
30
+ results.should.have.length(0);
31
+ });
32
+ });
@@ -2,36 +2,30 @@
2
2
  import should from 'should';
3
3
 
4
4
  import config from '../test-config.js';
5
- import {
6
- openDb,
7
- getDb,
8
- closeDb,
9
- importGtfs,
10
- getAgencies,
11
- } from '../../index.js';
5
+ import { openDb, closeDb, importGtfs, getAgencies } from '../../index.js';
12
6
 
13
7
  describe('getAgencies():', () => {
14
8
  before(async () => {
15
- await openDb(config);
9
+ openDb(config);
16
10
  await importGtfs(config);
17
11
  });
18
12
 
19
- after(async () => {
20
- const db = getDb(config);
21
- await closeDb(db);
13
+ after(() => {
14
+ const db = openDb(config);
15
+ closeDb(db);
22
16
  });
23
17
 
24
- it('should return empty array if no agencies exist', async () => {
18
+ it('should return empty array if no agencies exist', () => {
25
19
  const agencyId = 'fake-agency-id';
26
- const results = await getAgencies({
20
+ const results = getAgencies({
27
21
  agency_id: agencyId,
28
22
  });
29
23
  should.exists(results);
30
24
  results.should.have.length(0);
31
25
  });
32
26
 
33
- it('should return expected agencies with no query', async () => {
34
- const results = await getAgencies();
27
+ it('should return expected agencies with no query', () => {
28
+ const results = getAgencies();
35
29
 
36
30
  const expectedResult = {
37
31
  id: 1,
@@ -50,11 +44,11 @@ describe('getAgencies():', () => {
50
44
  expectedResult.should.match(results[0]);
51
45
  });
52
46
 
53
- it('should return expected agency for agency_id and agency_lang', async () => {
47
+ it('should return expected agency for agency_id and agency_lang', () => {
54
48
  const agencyId = 'CT';
55
49
  const agencyLand = 'en';
56
50
 
57
- const results = await getAgencies({
51
+ const results = getAgencies({
58
52
  agency_id: agencyId,
59
53
  agency_lang: agencyLand,
60
54
  });
@@ -76,10 +70,10 @@ describe('getAgencies():', () => {
76
70
  expectedResult.should.match(results[0]);
77
71
  });
78
72
 
79
- it('should return only specific keys for expected agency for agency_id', async () => {
73
+ it('should return only specific keys for expected agency for agency_id', () => {
80
74
  const agencyId = 'CT';
81
75
 
82
- const results = await getAgencies(
76
+ const results = getAgencies(
83
77
  {
84
78
  agency_id: agencyId,
85
79
  },
@@ -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, getAreas } from '../../index.js';
7
+
8
+ describe('getAreas():', () => {
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 areas exist', () => {
20
+ const areaId = 'fake-area-id';
21
+ const results = getAreas({
22
+ area_id: areaId,
23
+ });
24
+ should.exists(results);
25
+ results.should.have.length(0);
26
+ });
27
+ });
@@ -3,28 +3,22 @@
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
- getAttributions,
12
- } from '../../index.js';
6
+ import { openDb, closeDb, importGtfs, getAttributions } from '../../index.js';
13
7
 
14
8
  describe('getAttributions():', () => {
15
9
  before(async () => {
16
- await openDb(config);
10
+ openDb(config);
17
11
  await importGtfs(config);
18
12
  });
19
13
 
20
- after(async () => {
21
- const db = getDb(config);
22
- await closeDb(db);
14
+ after(() => {
15
+ const db = openDb(config);
16
+ closeDb(db);
23
17
  });
24
18
 
25
- it('should return empty array if no attributions exist', async () => {
19
+ it('should return empty array if no attributions exist', () => {
26
20
  const attributionId = 'fake-attribution-id';
27
- const results = await getAttributions({
21
+ const results = getAttributions({
28
22
  attribution_id: attributionId,
29
23
  });
30
24
  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
- getBoardAlights,
12
- } from '../../index.js';
6
+ import { openDb, closeDb, importGtfs, getBoardAlights } from '../../index.js';
13
7
 
14
8
  describe('getBoardAlights():', () => {
15
9
  before(async () => {
16
- await openDb(config);
10
+ openDb(config);
17
11
  await importGtfs(config);
18
12
  });
19
13
 
20
- after(async () => {
21
- const db = getDb(config);
22
- await closeDb(db);
14
+ after(() => {
15
+ const db = openDb(config);
16
+ closeDb(db);
23
17
  });
24
18
 
25
- it('should return empty array if no board alights (GTFS-ride)', async () => {
19
+ it('should return empty array if no board alights (GTFS-ride)', () => {
26
20
  const tripId = 'fake-trip-id';
27
21
 
28
- const results = await getBoardAlights({
22
+ const results = getBoardAlights({
29
23
  trip_id: tripId,
30
24
  });
31
25
  should.exists(results);
@@ -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
- await openDb(config);
10
+ openDb(config);
17
11
  await importGtfs(config);
18
12
  });
19
13
 
20
- after(async () => {
21
- const db = getDb(config);
22
- await closeDb(db);
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', async () => {
19
+ it('should return empty array if no calendar dates exist', () => {
26
20
  const serviceId = 'fake-service-id';
27
21
 
28
- const results = await getCalendarDates({
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', async () => {
29
+ it('should return expected calendar dates', () => {
36
30
  const serviceId = 'CT-16APR-Caltrain-Weekday-01';
37
31
 
38
- const results = await getCalendarDates({
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', async () => {
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 = await getCalendarDates(
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
- await openDb(config);
10
+ openDb(config);
17
11
  await importGtfs(config);
18
12
  });
19
13
 
20
- after(async () => {
21
- const db = getDb(config);
22
- await closeDb(db);
14
+ after(() => {
15
+ const db = openDb(config);
16
+ closeDb(db);
23
17
  });
24
18
 
25
- it('should return empty array if no calendars', async () => {
19
+ it('should return empty array if no calendars', () => {
26
20
  const serviceId = 'fake-service-id';
27
21
 
28
- const results = await getCalendars({
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', async () => {
36
- const results = await getCalendars({
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', async () => {
59
- const results = await getCalendars({
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',