gtfs 3.1.1 → 3.2.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 (111) hide show
  1. package/.eslintrc.json +14 -19
  2. package/.husky/pre-commit +4 -0
  3. package/@types/index.d.ts +269 -0
  4. package/@types/tests.ts +26 -0
  5. package/@types/tsconfig.json +17 -0
  6. package/CHANGELOG.md +182 -1
  7. package/README.md +168 -149
  8. package/bin/gtfs-export.js +4 -5
  9. package/bin/gtfs-import.js +6 -7
  10. package/config-sample-full.json +2 -7
  11. package/docs/images/node-gtfs-logo.svg +18 -0
  12. package/lib/db.js +63 -12
  13. package/lib/export.js +27 -13
  14. package/lib/file-utils.js +26 -9
  15. package/lib/geojson-utils.js +51 -38
  16. package/lib/gtfs/agencies.js +15 -4
  17. package/lib/gtfs/attributions.js +15 -4
  18. package/lib/gtfs/calendar-dates.js +15 -4
  19. package/lib/gtfs/calendars.js +15 -4
  20. package/lib/gtfs/fare-attributes.js +15 -4
  21. package/lib/gtfs/fare-rules.js +15 -4
  22. package/lib/gtfs/feed-info.js +15 -4
  23. package/lib/gtfs/frequencies.js +15 -4
  24. package/lib/gtfs/levels.js +15 -4
  25. package/lib/gtfs/pathways.js +15 -4
  26. package/lib/gtfs/routes.js +22 -6
  27. package/lib/gtfs/shapes.js +59 -23
  28. package/lib/gtfs/stop-times.js +15 -4
  29. package/lib/gtfs/stops.js +57 -23
  30. package/lib/gtfs/transfers.js +15 -4
  31. package/lib/gtfs/translations.js +15 -4
  32. package/lib/gtfs/trips.js +15 -4
  33. package/lib/gtfs-ride/board-alights.js +15 -4
  34. package/lib/gtfs-ride/ride-feed-infos.js +15 -4
  35. package/lib/gtfs-ride/rider-trips.js +15 -4
  36. package/lib/gtfs-ride/riderships.js +15 -4
  37. package/lib/gtfs-ride/trip-capacities.js +15 -4
  38. package/lib/import.js +203 -128
  39. package/lib/log-utils.js +8 -4
  40. package/lib/non-standard/directions.js +15 -4
  41. package/lib/non-standard/stop-attributes.js +15 -4
  42. package/lib/non-standard/timetable-notes-references.js +15 -4
  43. package/lib/non-standard/timetable-notes.js +15 -4
  44. package/lib/non-standard/timetable-pages.js +15 -4
  45. package/lib/non-standard/timetable-stop-order.js +15 -4
  46. package/lib/non-standard/timetables.js +15 -4
  47. package/lib/utils.js +26 -12
  48. package/models/gtfs/agency.js +11 -11
  49. package/models/gtfs/attributions.js +14 -14
  50. package/models/gtfs/calendar-dates.js +7 -7
  51. package/models/gtfs/calendar.js +12 -12
  52. package/models/gtfs/fare-attributes.js +9 -9
  53. package/models/gtfs/fare-rules.js +8 -8
  54. package/models/gtfs/feed-info.js +12 -12
  55. package/models/gtfs/frequencies.js +10 -10
  56. package/models/gtfs/levels.js +5 -5
  57. package/models/gtfs/pathways.js +14 -14
  58. package/models/gtfs/routes.js +14 -14
  59. package/models/gtfs/shapes.js +8 -8
  60. package/models/gtfs/stop-times.js +17 -17
  61. package/models/gtfs/stops.js +17 -17
  62. package/models/gtfs/transfers.js +7 -7
  63. package/models/gtfs/translations.js +10 -10
  64. package/models/gtfs/trips.js +12 -12
  65. package/models/gtfs-ride/board-alight.js +24 -24
  66. package/models/gtfs-ride/ride-feed-info.js +8 -8
  67. package/models/gtfs-ride/rider-trip.js +21 -21
  68. package/models/gtfs-ride/ridership.js +23 -23
  69. package/models/gtfs-ride/trip-capacity.js +10 -10
  70. package/models/models.js +1 -1
  71. package/models/non-standard/directions.js +6 -6
  72. package/models/non-standard/stop-attributes.js +5 -5
  73. package/models/non-standard/timetable-notes-references.js +9 -9
  74. package/models/non-standard/timetable-notes.js +5 -5
  75. package/models/non-standard/timetable-pages.js +5 -5
  76. package/models/non-standard/timetable-stop-order.js +6 -6
  77. package/models/non-standard/timetables.js +27 -27
  78. package/package.json +35 -13
  79. package/test/mocha/export-gtfs.js +74 -44
  80. package/test/mocha/get-agencies.js +20 -14
  81. package/test/mocha/get-attributions.js +10 -4
  82. package/test/mocha/get-board-alights.js +10 -4
  83. package/test/mocha/get-calendar-dates.js +31 -24
  84. package/test/mocha/get-calendars.js +17 -11
  85. package/test/mocha/get-db.js +71 -5
  86. package/test/mocha/get-directions.js +10 -4
  87. package/test/mocha/get-fare-attributes.js +12 -6
  88. package/test/mocha/get-fare-rules.js +17 -13
  89. package/test/mocha/get-feed-info.js +10 -4
  90. package/test/mocha/get-frequencies.js +10 -4
  91. package/test/mocha/get-levels.js +4 -4
  92. package/test/mocha/get-pathways.js +10 -4
  93. package/test/mocha/get-ride-feed-infos.js +9 -3
  94. package/test/mocha/get-rider-trips.js +10 -4
  95. package/test/mocha/get-riderships.js +10 -4
  96. package/test/mocha/get-routes.js +12 -16
  97. package/test/mocha/get-shapes-as-geojson.js +12 -6
  98. package/test/mocha/get-shapes.js +31 -39
  99. package/test/mocha/get-stop-attributes.js +10 -4
  100. package/test/mocha/get-stops-as-geojson.js +11 -5
  101. package/test/mocha/get-stops.js +62 -51
  102. package/test/mocha/get-stoptimes.js +18 -10
  103. package/test/mocha/get-timetable-pages.js +10 -4
  104. package/test/mocha/get-timetable-stop-orders.js +10 -4
  105. package/test/mocha/get-timetables.js +10 -4
  106. package/test/mocha/get-transfers.js +10 -4
  107. package/test/mocha/get-translations.js +10 -4
  108. package/test/mocha/get-trip-capacities.js +10 -4
  109. package/test/mocha/get-trips.js +6 -6
  110. package/test/mocha/import-gtfs.js +63 -46
  111. package/test/test-config.js +9 -4
@@ -5,17 +5,17 @@ const model = {
5
5
  {
6
6
  name: 'note_id',
7
7
  type: 'varchar(255)',
8
- primary: true
8
+ primary: true,
9
9
  },
10
10
  {
11
11
  name: 'symbol',
12
- type: 'varchar(255)'
12
+ type: 'varchar(255)',
13
13
  },
14
14
  {
15
15
  name: 'note',
16
- type: 'varchar(2047)'
17
- }
18
- ]
16
+ type: 'varchar(2047)',
17
+ },
18
+ ],
19
19
  };
20
20
 
21
21
  export default model;
@@ -5,17 +5,17 @@ const model = {
5
5
  {
6
6
  name: 'timetable_page_id',
7
7
  type: 'varchar(255)',
8
- primary: true
8
+ primary: true,
9
9
  },
10
10
  {
11
11
  name: 'timetable_page_label',
12
- type: 'varchar(255)'
12
+ type: 'varchar(255)',
13
13
  },
14
14
  {
15
15
  name: 'filename',
16
- type: 'varchar(255)'
17
- }
18
- ]
16
+ type: 'varchar(255)',
17
+ },
18
+ ],
19
19
  };
20
20
 
21
21
  export default model;
@@ -5,24 +5,24 @@ const model = {
5
5
  {
6
6
  name: 'id',
7
7
  type: 'integer',
8
- primary: true
8
+ primary: true,
9
9
  },
10
10
  {
11
11
  name: 'timetable_id',
12
12
  type: 'varchar(255)',
13
- index: true
13
+ index: true,
14
14
  },
15
15
  {
16
16
  name: 'stop_id',
17
- type: 'varchar(255)'
17
+ type: 'varchar(255)',
18
18
  },
19
19
  {
20
20
  name: 'stop_sequence',
21
21
  type: 'integer',
22
22
  min: 0,
23
- index: true
24
- }
25
- ]
23
+ index: true,
24
+ },
25
+ ],
26
26
  };
27
27
 
28
28
  export default model;
@@ -5,134 +5,134 @@ const model = {
5
5
  {
6
6
  name: 'id',
7
7
  type: 'integer',
8
- primary: true
8
+ primary: true,
9
9
  },
10
10
  {
11
11
  name: 'timetable_id',
12
- type: 'varchar(255)'
12
+ type: 'varchar(255)',
13
13
  },
14
14
  {
15
15
  name: 'route_id',
16
- type: 'varchar(255)'
16
+ type: 'varchar(255)',
17
17
  },
18
18
  {
19
19
  name: 'direction_id',
20
20
  type: 'integer',
21
21
  min: 0,
22
- max: 1
22
+ max: 1,
23
23
  },
24
24
  {
25
25
  name: 'start_date',
26
- type: 'integer'
26
+ type: 'integer',
27
27
  },
28
28
  {
29
29
  name: 'end_date',
30
- type: 'integer'
30
+ type: 'integer',
31
31
  },
32
32
  {
33
33
  name: 'monday',
34
34
  type: 'integer',
35
35
  required: true,
36
36
  min: 0,
37
- max: 1
37
+ max: 1,
38
38
  },
39
39
  {
40
40
  name: 'tuesday',
41
41
  type: 'integer',
42
42
  required: true,
43
43
  min: 0,
44
- max: 1
44
+ max: 1,
45
45
  },
46
46
  {
47
47
  name: 'wednesday',
48
48
  type: 'integer',
49
49
  required: true,
50
50
  min: 0,
51
- max: 1
51
+ max: 1,
52
52
  },
53
53
  {
54
54
  name: 'thursday',
55
55
  type: 'integer',
56
56
  required: true,
57
57
  min: 0,
58
- max: 1
58
+ max: 1,
59
59
  },
60
60
  {
61
61
  name: 'friday',
62
62
  type: 'integer',
63
63
  required: true,
64
64
  min: 0,
65
- max: 1
65
+ max: 1,
66
66
  },
67
67
  {
68
68
  name: 'saturday',
69
69
  type: 'integer',
70
70
  required: true,
71
71
  min: 0,
72
- max: 1
72
+ max: 1,
73
73
  },
74
74
  {
75
75
  name: 'sunday',
76
76
  type: 'integer',
77
77
  required: true,
78
78
  min: 0,
79
- max: 1
79
+ max: 1,
80
80
  },
81
81
  {
82
82
  name: 'start_time',
83
- type: 'varchar(255)'
83
+ type: 'varchar(255)',
84
84
  },
85
85
  {
86
86
  name: 'start_timestamp',
87
- type: 'integer'
87
+ type: 'integer',
88
88
  },
89
89
  {
90
90
  name: 'end_time',
91
- type: 'varchar(255)'
91
+ type: 'varchar(255)',
92
92
  },
93
93
  {
94
94
  name: 'end_timestamp',
95
- type: 'integer'
95
+ type: 'integer',
96
96
  },
97
97
  {
98
98
  name: 'timetable_label',
99
- type: 'varchar(255)'
99
+ type: 'varchar(255)',
100
100
  },
101
101
  {
102
102
  name: 'service_notes',
103
- type: 'varchar(255)'
103
+ type: 'varchar(255)',
104
104
  },
105
105
  {
106
106
  name: 'orientation',
107
- type: 'varchar(255)'
107
+ type: 'varchar(255)',
108
108
  },
109
109
  {
110
110
  name: 'timetable_page_id',
111
- type: 'varchar(255)'
111
+ type: 'varchar(255)',
112
112
  },
113
113
  {
114
114
  name: 'timetable_sequence',
115
115
  type: 'integer',
116
116
  min: 0,
117
- index: true
117
+ index: true,
118
118
  },
119
119
  {
120
120
  name: 'direction_name',
121
- type: 'varchar(255)'
121
+ type: 'varchar(255)',
122
122
  },
123
123
  {
124
124
  name: 'include_exceptions',
125
125
  type: 'integer',
126
126
  min: 0,
127
- max: 1
127
+ max: 1,
128
128
  },
129
129
  {
130
130
  name: 'show_trip_continuation',
131
131
  type: 'integer',
132
132
  min: 0,
133
- max: 1
134
- }
135
- ]
133
+ max: 1,
134
+ },
135
+ ],
136
136
  };
137
137
 
138
138
  export default model;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtfs",
3
- "version": "3.1.1",
3
+ "version": "3.2.0",
4
4
  "description": "Import GTFS transit data into SQLite and query routes, stops, times, fares and more",
5
5
  "keywords": [
6
6
  "transit",
@@ -52,7 +52,8 @@
52
52
  "Oskari Groenroos <oskari@groenroos.fi>",
53
53
  "Devin Packer",
54
54
  "Darius MARTIN",
55
- "Mike Brocks"
55
+ "Mike Brocks",
56
+ "Matt Moran"
56
57
  ],
57
58
  "type": "module",
58
59
  "main": "index.js",
@@ -60,38 +61,59 @@
60
61
  "gtfs-export": "bin/gtfs-export.js",
61
62
  "gtfs-import": "bin/gtfs-import.js"
62
63
  },
64
+ "types": "@types",
63
65
  "scripts": {
66
+ "dtslint": "dtslint @types",
64
67
  "lint": "eslint **/*.js",
68
+ "lint-fix": "eslint **/*.js --fix",
65
69
  "test": "eslint **/*.js && NODE_ENV=test mocha ./test/mocha/**/*.js --timeout 2000"
66
70
  },
67
71
  "dependencies": {
68
72
  "@turf/helpers": "^6.5.0",
69
73
  "chalk": "^4.1.2",
70
- "copy-dir": "^1.3.0",
71
- "csv-parse": "^4.16.3",
72
- "csv-stringify": "^5.6.5",
74
+ "csv-parse": "^5.0.3",
75
+ "csv-stringify": "^6.0.4",
73
76
  "lodash-es": "^4.17.21",
74
- "node-fetch": "^3.0.0",
77
+ "node-fetch": "^3.1.0",
75
78
  "pluralize": "^8.0.0",
76
- "pretty-error": "^3.0.4",
79
+ "pretty-error": "^4.0.0",
77
80
  "promise-map-series": "^0.3.0",
81
+ "recursive-copy": "^2.0.13",
78
82
  "sanitize-filename": "^1.6.3",
79
83
  "sqlite": "^4.0.23",
80
- "sqlite3": "github:mapbox/node-sqlite3#593c9d",
84
+ "sqlite3": "^5.0.2",
81
85
  "sqlstring-sqlite": "^0.1.1",
82
86
  "strip-bom-stream": "^5.0.0",
83
- "tmp-promise": "^3.0.2",
87
+ "tmp-promise": "^3.0.3",
84
88
  "untildify": "^4.0.0",
85
89
  "unzipper": "^0.10.11",
86
- "yargs": "^17.1.1"
90
+ "yargs": "^17.2.1"
87
91
  },
88
92
  "devDependencies": {
89
- "eslint": "^7.32.0",
90
- "eslint-config-xo": "^0.38.0",
91
- "mocha": "^9.1.1",
93
+ "dtslint": "^4.2.0",
94
+ "eslint": "^8.2.0",
95
+ "eslint-config-prettier": "^8.3.0",
96
+ "eslint-config-xo": "^0.39.0",
97
+ "husky": "^7.0.4",
98
+ "mocha": "^9.1.3",
99
+ "prettier": "^2.4.1",
100
+ "pretty-quick": "^3.1.2",
92
101
  "should": "^13.2.3"
93
102
  },
94
103
  "engines": {
95
104
  "node": ">= 14.17.0"
105
+ },
106
+ "release-it": {
107
+ "github": {
108
+ "release": true
109
+ },
110
+ "plugins": {
111
+ "@release-it/keep-a-changelog": {
112
+ "filename": "CHANGELOG.md"
113
+ }
114
+ }
115
+ },
116
+ "prettier": {
117
+ "singleQuote": true
96
118
  }
97
119
  }
@@ -5,13 +5,19 @@ import path from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { createReadStream, existsSync } from 'node:fs';
7
7
  import { rm } from 'node:fs/promises';
8
- import parse from 'csv-parse';
8
+ import { parse } from 'csv-parse';
9
9
  import should from 'should';
10
10
 
11
- import { openDb, closeDb } from '../../lib/db.js';
12
11
  import { unzip, generateFolderName } from '../../lib/file-utils.js';
13
12
  import config from '../test-config.js';
14
- import { importGtfs, exportGtfs, getAgencies } from '../../index.js';
13
+ import {
14
+ openDb,
15
+ getDb,
16
+ closeDb,
17
+ importGtfs,
18
+ exportGtfs,
19
+ getAgencies,
20
+ } from '../../index.js';
15
21
  import models from '../../models/models.js';
16
22
 
17
23
  describe('exportGtfs():', function () {
@@ -21,7 +27,8 @@ describe('exportGtfs():', function () {
21
27
  });
22
28
 
23
29
  after(async () => {
24
- await closeDb();
30
+ const db = getDb(config);
31
+ await closeDb(db);
25
32
  });
26
33
 
27
34
  this.timeout(10000);
@@ -33,52 +40,72 @@ describe('exportGtfs():', function () {
33
40
 
34
41
  describe('Verify data exported', () => {
35
42
  const countData = {};
36
- const temporaryDir = path.join(path.dirname(fileURLToPath(import.meta.url)), '../fixture/tmp/');
43
+ const temporaryDir = path.join(
44
+ path.dirname(fileURLToPath(import.meta.url)),
45
+ '../fixture/tmp/'
46
+ );
37
47
 
38
48
  before(async () => {
39
49
  await unzip(config.agencies[0].path, temporaryDir);
40
50
 
41
- await Promise.all(models.map(model => {
42
- const filePath = path.join(temporaryDir, `${model.filenameBase}.txt`);
51
+ await Promise.all(
52
+ models.map((model) => {
53
+ const filePath = path.join(temporaryDir, `${model.filenameBase}.txt`);
43
54
 
44
- // GTFS has optional files
45
- if (!existsSync(filePath)) {
46
- countData[model.filenameBase] = 0;
47
- return false;
48
- }
49
-
50
- const parser = parse({
51
- columns: true,
52
- relax: true,
53
- trim: true
54
- }, (error, data) => {
55
- if (error) {
56
- throw new Error(error);
55
+ // GTFS has optional files
56
+ if (!existsSync(filePath)) {
57
+ countData[model.filenameBase] = 0;
58
+ return false;
57
59
  }
58
60
 
59
- countData[model.filenameBase] = data.length;
60
- });
61
-
62
- return createReadStream(filePath)
63
- .pipe(parser)
64
- .on('error', error => {
65
- countData[model.collection] = 0;
66
- throw new Error(error);
67
- });
68
- }));
61
+ const parser = parse(
62
+ {
63
+ columns: true,
64
+ relax: true,
65
+ trim: true,
66
+ },
67
+ (error, data) => {
68
+ if (error) {
69
+ throw new Error(error);
70
+ }
71
+
72
+ countData[model.filenameBase] = data.length;
73
+ }
74
+ );
75
+
76
+ return createReadStream(filePath)
77
+ .pipe(parser)
78
+ .on('error', (error) => {
79
+ countData[model.collection] = 0;
80
+ throw new Error(error);
81
+ });
82
+ })
83
+ );
69
84
 
70
85
  await importGtfs(config);
71
86
  });
72
87
 
73
88
  after(async () => {
74
89
  const agencies = await getAgencies({}, ['agency_name']);
75
- await rm(path.join(process.cwd(), 'gtfs-export', generateFolderName(agencies[0].agency_name)), { recursive: true, force: true });
90
+ await rm(
91
+ path.join(
92
+ process.cwd(),
93
+ 'gtfs-export',
94
+ generateFolderName(agencies[0].agency_name)
95
+ ),
96
+ { recursive: true, force: true }
97
+ );
76
98
  });
77
99
 
78
100
  for (const model of models) {
79
101
  it(`should import the same number of ${model.filenameBase}`, async () => {
80
102
  const agencies = await getAgencies({}, ['agency_name']);
81
- const filePath = path.join(process.cwd(), 'gtfs-export', generateFolderName(agencies[0].agency_name), `${model.filenameBase}.txt`);
103
+ const filePath = path.join(
104
+ process.cwd(),
105
+ 'gtfs-export',
106
+ generateFolderName(agencies[0].agency_name),
107
+ `${model.filenameBase}.txt`
108
+ );
82
109
 
83
110
  // GTFS has optional files
84
111
  if (!existsSync(filePath)) {
@@ -87,23 +114,26 @@ describe('exportGtfs():', function () {
87
114
  return;
88
115
  }
89
116
 
90
- const parser = parse({
91
- columns: true,
92
- relax: true,
93
- trim: true
94
- }, (error, data) => {
95
- if (error) {
96
- throw new Error(error);
97
- }
117
+ const parser = parse(
118
+ {
119
+ columns: true,
120
+ relax: true,
121
+ trim: true,
122
+ },
123
+ (error, data) => {
124
+ if (error) {
125
+ throw new Error(error);
126
+ }
98
127
 
99
- should.not.exist(error);
128
+ should.not.exist(error);
100
129
 
101
- data.length.should.equal(countData[model.filenameBase]);
102
- });
130
+ data.length.should.equal(countData[model.filenameBase]);
131
+ }
132
+ );
103
133
 
104
134
  return createReadStream(filePath)
105
135
  .pipe(parser)
106
- .on('error', error => {
136
+ .on('error', (error) => {
107
137
  should.not.exist(error);
108
138
  });
109
139
  });
@@ -1,9 +1,14 @@
1
1
  /* eslint-env mocha */
2
2
  import should from 'should';
3
3
 
4
- import { openDb, closeDb } from '../../lib/db.js';
5
4
  import config from '../test-config.js';
6
- import { importGtfs, getAgencies } from '../../index.js';
5
+ import {
6
+ openDb,
7
+ getDb,
8
+ closeDb,
9
+ importGtfs,
10
+ getAgencies,
11
+ } from '../../index.js';
7
12
 
8
13
  describe('getAgencies():', () => {
9
14
  before(async () => {
@@ -12,13 +17,14 @@ describe('getAgencies():', () => {
12
17
  });
13
18
 
14
19
  after(async () => {
15
- await closeDb();
20
+ const db = getDb(config);
21
+ await closeDb(db);
16
22
  });
17
23
 
18
24
  it('should return empty array if no agencies exist', async () => {
19
25
  const agencyId = 'fake-agency-id';
20
26
  const results = await getAgencies({
21
- agency_id: agencyId
27
+ agency_id: agencyId,
22
28
  });
23
29
  should.exists(results);
24
30
  results.should.have.length(0);
@@ -36,7 +42,7 @@ describe('getAgencies():', () => {
36
42
  agency_lang: 'en',
37
43
  agency_phone: '800-660-4287',
38
44
  agency_fare_url: null,
39
- agency_email: null
45
+ agency_email: null,
40
46
  };
41
47
 
42
48
  should.exist(results);
@@ -50,7 +56,7 @@ describe('getAgencies():', () => {
50
56
 
51
57
  const results = await getAgencies({
52
58
  agency_id: agencyId,
53
- agency_lang: agencyLand
59
+ agency_lang: agencyLand,
54
60
  });
55
61
 
56
62
  const expectedResult = {
@@ -62,7 +68,7 @@ describe('getAgencies():', () => {
62
68
  agency_lang: 'en',
63
69
  agency_phone: '800-660-4287',
64
70
  agency_fare_url: null,
65
- agency_email: null
71
+ agency_email: null,
66
72
  };
67
73
 
68
74
  should.exist(results);
@@ -73,16 +79,16 @@ describe('getAgencies():', () => {
73
79
  it('should return only specific keys for expected agency for agency_id', async () => {
74
80
  const agencyId = 'CT';
75
81
 
76
- const results = await getAgencies({
77
- agency_id: agencyId
78
- }, [
79
- 'agency_url',
80
- 'agency_lang'
81
- ]);
82
+ const results = await getAgencies(
83
+ {
84
+ agency_id: agencyId,
85
+ },
86
+ ['agency_url', 'agency_lang']
87
+ );
82
88
 
83
89
  const expectedResult = {
84
90
  agency_url: 'http://www.caltrain.com',
85
- agency_lang: 'en'
91
+ agency_lang: 'en',
86
92
  };
87
93
 
88
94
  should.exist(results);
@@ -2,9 +2,14 @@
2
2
 
3
3
  import should from 'should';
4
4
 
5
- import { openDb, closeDb } from '../../lib/db.js';
6
5
  import config from '../test-config.js';
7
- import { importGtfs, getAttributions } from '../../index.js';
6
+ import {
7
+ openDb,
8
+ getDb,
9
+ closeDb,
10
+ importGtfs,
11
+ getAttributions,
12
+ } from '../../index.js';
8
13
 
9
14
  describe('getAttributions():', () => {
10
15
  before(async () => {
@@ -13,13 +18,14 @@ describe('getAttributions():', () => {
13
18
  });
14
19
 
15
20
  after(async () => {
16
- await closeDb();
21
+ const db = getDb(config);
22
+ await closeDb(db);
17
23
  });
18
24
 
19
25
  it('should return empty array if no attributions exist', async () => {
20
26
  const attributionId = 'fake-attribution-id';
21
27
  const results = await getAttributions({
22
- attribution_id: attributionId
28
+ attribution_id: attributionId,
23
29
  });
24
30
  should.exists(results);
25
31
  results.should.have.length(0);
@@ -2,9 +2,14 @@
2
2
 
3
3
  import should from 'should';
4
4
 
5
- import { openDb, closeDb } from '../../lib/db.js';
6
5
  import config from '../test-config.js';
7
- import { importGtfs, getBoardAlights } from '../../index.js';
6
+ import {
7
+ openDb,
8
+ getDb,
9
+ closeDb,
10
+ importGtfs,
11
+ getBoardAlights,
12
+ } from '../../index.js';
8
13
 
9
14
  describe('getBoardAlights():', () => {
10
15
  before(async () => {
@@ -13,14 +18,15 @@ describe('getBoardAlights():', () => {
13
18
  });
14
19
 
15
20
  after(async () => {
16
- await closeDb();
21
+ const db = getDb(config);
22
+ await closeDb(db);
17
23
  });
18
24
 
19
25
  it('should return empty array if no board alights (GTFS-ride)', async () => {
20
26
  const tripId = 'fake-trip-id';
21
27
 
22
28
  const results = await getBoardAlights({
23
- trip_id: tripId
29
+ trip_id: tripId,
24
30
  });
25
31
  should.exists(results);
26
32
  results.should.have.length(0);