hubot-nextbus 2.2.2 → 2.3.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.
@@ -1,16 +1,16 @@
1
1
  {
2
- "total": 95,
2
+ "total": 46,
3
3
  "page": 1,
4
4
  "per_page": 5,
5
5
  "data": [
6
6
  {
7
- "id": 204,
8
- "stop_gid": "CHA7AWN",
9
- "stop_code": "CHA7AWN",
10
- "stop_name": "CHARLOTTE AVE & 7TH AVE N WB",
11
- "stop_desc": null,
12
- "stop_lat": "36.165",
13
- "stop_lon": "-86.78406",
7
+ "id": 216884,
8
+ "stop_gid": "BRO12WN",
9
+ "stop_code": "BRO12WN",
10
+ "stop_name": "BROADWAY AVE & 12TH AVE N WB",
11
+ "stop_desc": "103 12TH AVE & BROADWAY AVE",
12
+ "stop_lat": "36.156751",
13
+ "stop_lon": "-86.787397",
14
14
  "zone_gid": null,
15
15
  "stop_url": null,
16
16
  "location_type": null,
@@ -18,35 +18,35 @@
18
18
  "parent_station_id": null,
19
19
  "stop_timezone": null,
20
20
  "wheelchair_boarding": "0",
21
- "created_at": "2022-08-02T21:14:07.970-05:00",
22
- "updated_at": "2022-08-02T21:14:07.970-05:00"
21
+ "created_at": "2026-02-01T23:37:21.829-06:00",
22
+ "updated_at": "2026-02-01T23:37:21.829-06:00"
23
23
  },
24
24
  {
25
- "id": 203,
26
- "stop_gid": "CHA7AEN",
27
- "stop_code": "CHA7AEN",
28
- "stop_name": "CHARLOTTE AVE & 7TH AVE N EB",
29
- "stop_desc": null,
30
- "stop_lat": "36.164714",
31
- "stop_lon": "-86.784416",
32
- "zone_gid": null,
25
+ "id": 217797,
26
+ "stop_gid": "BRO12AEF",
27
+ "stop_code": "BRO12AEF",
28
+ "stop_name": "BROADWAY AVE & 12TH AVE EB",
29
+ "stop_desc": "1232 BROADWAY AVE & 12TH AVE",
30
+ "stop_lat": "36.15665",
31
+ "stop_lon": "-86.787086",
32
+ "zone_gid": "0",
33
33
  "stop_url": null,
34
34
  "location_type": null,
35
35
  "parent_station_gid": null,
36
36
  "parent_station_id": null,
37
37
  "stop_timezone": null,
38
38
  "wheelchair_boarding": "0",
39
- "created_at": "2022-08-02T21:14:07.970-05:00",
40
- "updated_at": "2022-08-02T21:14:07.970-05:00"
39
+ "created_at": "2026-02-01T23:37:24.777-06:00",
40
+ "updated_at": "2026-02-01T23:37:24.777-06:00"
41
41
  },
42
42
  {
43
- "id": 1136,
44
- "stop_gid": "6AVDEASN",
45
- "stop_code": "6AVDEASN",
46
- "stop_name": "6TH AVE & DEADERICK ST SB",
47
- "stop_desc": "6TH AVE N & UNION ST",
48
- "stop_lat": "36.16483",
49
- "stop_lon": "-86.782945",
43
+ "id": 218007,
44
+ "stop_gid": "11APORSF",
45
+ "stop_code": "11APORSF",
46
+ "stop_name": "11TH AVE & PORTER ST SB",
47
+ "stop_desc": "303 11TH AVE & PORTER ST",
48
+ "stop_lat": "36.157903",
49
+ "stop_lon": "-86.786781",
50
50
  "zone_gid": null,
51
51
  "stop_url": null,
52
52
  "location_type": null,
@@ -54,44 +54,44 @@
54
54
  "parent_station_id": null,
55
55
  "stop_timezone": null,
56
56
  "wheelchair_boarding": null,
57
- "created_at": "2022-08-02T21:14:08.168-05:00",
58
- "updated_at": "2022-08-02T21:14:08.168-05:00"
57
+ "created_at": "2026-02-01T23:37:24.777-06:00",
58
+ "updated_at": "2026-02-01T23:37:24.777-06:00"
59
59
  },
60
60
  {
61
- "id": 838,
62
- "stop_gid": "6AVDEANN",
63
- "stop_code": "6AVDEANN",
64
- "stop_name": "6TH AVE N & DEADERICK ST NB",
65
- "stop_desc": "6TH AV N & DEADERICK ST",
66
- "stop_lat": "36.16466",
67
- "stop_lon": "-86.782651",
61
+ "id": 218012,
62
+ "stop_gid": "11APORNN",
63
+ "stop_code": "11APORNN",
64
+ "stop_name": "11TH AVE & PORTER ST NB",
65
+ "stop_desc": "302 11TH AVE & PORTER ST",
66
+ "stop_lat": "36.157887",
67
+ "stop_lon": "-86.786591",
68
68
  "zone_gid": null,
69
69
  "stop_url": null,
70
70
  "location_type": null,
71
71
  "parent_station_gid": null,
72
72
  "parent_station_id": null,
73
73
  "stop_timezone": null,
74
- "wheelchair_boarding": "0",
75
- "created_at": "2022-08-02T21:14:08.075-05:00",
76
- "updated_at": "2022-08-02T21:14:08.075-05:00"
74
+ "wheelchair_boarding": null,
75
+ "created_at": "2026-02-01T23:37:24.777-06:00",
76
+ "updated_at": "2026-02-01T23:37:24.777-06:00"
77
77
  },
78
78
  {
79
- "id": 722,
80
- "stop_gid": "UNI7AWN",
81
- "stop_code": "UNI7AWN",
82
- "stop_name": "UNION ST & 7TH AVE N WB",
83
- "stop_desc": "UNION & 7 AVE",
84
- "stop_lat": "36.163599",
85
- "stop_lon": "-86.783404",
86
- "zone_gid": null,
79
+ "id": 217849,
80
+ "stop_gid": "BRO10AEN",
81
+ "stop_code": "BRO10AEN",
82
+ "stop_name": "BROADWAY & 10TH AVE EB",
83
+ "stop_desc": "937 ",
84
+ "stop_lat": "36.157678",
85
+ "stop_lon": "-86.78468",
86
+ "zone_gid": "0",
87
87
  "stop_url": null,
88
- "location_type": null,
88
+ "location_type": "0",
89
89
  "parent_station_gid": null,
90
90
  "parent_station_id": null,
91
91
  "stop_timezone": null,
92
- "wheelchair_boarding": null,
93
- "created_at": "2022-08-02T21:14:08.075-05:00",
94
- "updated_at": "2022-08-02T21:14:08.075-05:00"
92
+ "wheelchair_boarding": "0",
93
+ "created_at": "2026-02-01T23:37:24.777-06:00",
94
+ "updated_at": "2026-02-01T23:37:24.777-06:00"
95
95
  }
96
96
  ]
97
97
  }
@@ -0,0 +1,147 @@
1
+ /* eslint-disable func-names */
2
+ /* global describe beforeEach afterEach context it */
3
+
4
+ const Helper = require('hubot-test-helper');
5
+ const chai = require('chai');
6
+ const nock = require('nock');
7
+
8
+ const {
9
+ expect,
10
+ } = chai;
11
+
12
+ const helper = new Helper([
13
+ './adapters/slack.js',
14
+ '../src/nextbus.js',
15
+ ]);
16
+
17
+ // Alter time as test runs
18
+ const originalDateNow = Date.now;
19
+
20
+ describe('hubot-nextbus for slack', () => {
21
+ beforeEach(() => {
22
+ nock.disableNetConnect();
23
+ nock('https://gtfs.transitnownash.org')
24
+ .get('/stops/near/36.156751,-86.787397/1000.json?per_page=5')
25
+ .replyWithFile(200, `${__dirname}/fixtures/stops-near-gps.json`);
26
+ nock('https://gtfs.transitnownash.org')
27
+ .get('/agencies.json')
28
+ .replyWithFile(200, `${__dirname}/fixtures/agencies.json`);
29
+ nock('https://gtfs.transitnownash.org')
30
+ .get('/stops/BRO12WN/next.json')
31
+ .replyWithFile(200, `${__dirname}/fixtures/stops-BRO12WN-next.json`);
32
+ });
33
+
34
+ afterEach(() => {
35
+ nock.cleanAll();
36
+ Date.now = originalDateNow;
37
+ });
38
+
39
+ context('regular tests with latitude/longitude set', () => {
40
+ beforeEach(function () {
41
+ Date.now = () => Date.parse('Mon Feb 02 2026 21:41:49 GMT-0600 (Central Standard Time)');
42
+ process.env.HUBOT_NEXTBUS_LAT_LON = '36.156751,-86.787397';
43
+ this.room = helper.createRoom();
44
+ });
45
+
46
+ afterEach(function () {
47
+ this.room.destroy();
48
+ delete process.env.HUBOT_NEXTBUS_LAT_LON;
49
+ });
50
+
51
+ // hubot nextbus
52
+ it('returns the next bus for closest stop', function (done) {
53
+ const selfRoom = this.room;
54
+ selfRoom.user.say('alice', '@hubot nextbus');
55
+ setTimeout(
56
+ () => {
57
+ try {
58
+ expect(selfRoom.messages).to.eql([
59
+ ['alice', '@hubot nextbus'],
60
+ [
61
+ 'hubot',
62
+ '⚠️ *Detour in effect on route 3 WEST END FROM DOWNTOWN*\n'
63
+ + '⚠️ *Detour in effect on route 3 WEST END TO DOWNTOWN*',
64
+ ],
65
+ [
66
+ 'hubot',
67
+ '🚏 *BROADWAY AVE & 12TH AVE N WB*\n'
68
+ + '```\n'
69
+ + ' 9:50 PM #3 - A -WHITE BRIDGE 🚌 in 9 minutes (On time)\n'
70
+ + ' 10:00 PM #7 - GREEN HILLS in 19 minutes (On time)\n'
71
+ + ' 10:05 PM #3 - B - BELLEVUE in 24 minutes (On time)\n'
72
+ + ' 10:20 PM #3 - A -WHITE BRIDGE in 39 minutes (5m late)\n'
73
+ + '```',
74
+ ],
75
+ ]);
76
+ done();
77
+ } catch (err) {
78
+ done(err);
79
+ }
80
+ },
81
+ 100,
82
+ );
83
+ });
84
+
85
+ // hubot nextbus stop <id>
86
+ it('returns the next bus for a particular stop', function (done) {
87
+ const selfRoom = this.room;
88
+ selfRoom.user.say('alice', '@hubot nextbus stop BRO12WN');
89
+ setTimeout(
90
+ () => {
91
+ try {
92
+ expect(selfRoom.messages).to.eql([
93
+ ['alice', '@hubot nextbus stop BRO12WN'],
94
+ [
95
+ 'hubot',
96
+ '⚠️ *Detour in effect on route 3 WEST END FROM DOWNTOWN*\n'
97
+ + '⚠️ *Detour in effect on route 3 WEST END TO DOWNTOWN*',
98
+ ],
99
+ [
100
+ 'hubot',
101
+ '🚏 *BROADWAY AVE & 12TH AVE N WB*\n'
102
+ + '```\n'
103
+ + ' 9:50 PM #3 - A -WHITE BRIDGE 🚌 in 9 minutes (On time)\n'
104
+ + ' 10:00 PM #7 - GREEN HILLS in 19 minutes (On time)\n'
105
+ + ' 10:05 PM #3 - B - BELLEVUE in 24 minutes (On time)\n'
106
+ + ' 10:20 PM #3 - A -WHITE BRIDGE in 39 minutes (5m late)\n'
107
+ + '```',
108
+ ],
109
+ ]);
110
+ done();
111
+ } catch (err) {
112
+ done(err);
113
+ }
114
+ },
115
+ 100,
116
+ );
117
+ });
118
+
119
+ // hubot nextbus stops
120
+ it('returns the list of nearby stops', function (done) {
121
+ const selfRoom = this.room;
122
+ selfRoom.user.say('alice', '@hubot nextbus stops');
123
+ setTimeout(
124
+ () => {
125
+ try {
126
+ expect(selfRoom.messages).to.eql([
127
+ ['alice', '@hubot nextbus stops'],
128
+ ['hubot', 'List of nearby stops:'],
129
+ [
130
+ 'hubot',
131
+ '- [BRO12WN] BROADWAY AVE & 12TH AVE N WB\n'
132
+ + '- [BRO12AEF] BROADWAY AVE & 12TH AVE EB\n'
133
+ + '- [11APORSF] 11TH AVE & PORTER ST SB\n'
134
+ + '- [11APORNN] 11TH AVE & PORTER ST NB\n'
135
+ + '- [BRO10AEN] BROADWAY & 10TH AVE EB',
136
+ ],
137
+ ]);
138
+ done();
139
+ } catch (err) {
140
+ done(err);
141
+ }
142
+ },
143
+ 100,
144
+ );
145
+ });
146
+ });
147
+ });
@@ -18,14 +18,17 @@ describe('hubot-nextbus', () => {
18
18
  beforeEach(() => {
19
19
  nock.disableNetConnect();
20
20
  nock('https://gtfs.transitnownash.org')
21
- .get('/stops/near/36.1650,-86.78404/1000.json?per_page=5')
21
+ .get('/stops/near/36.156751,-86.787397/1000.json?per_page=5')
22
22
  .replyWithFile(200, `${__dirname}/fixtures/stops-near-gps.json`);
23
23
  nock('https://gtfs.transitnownash.org')
24
24
  .get('/agencies.json')
25
25
  .replyWithFile(200, `${__dirname}/fixtures/agencies.json`);
26
26
  nock('https://gtfs.transitnownash.org')
27
- .get('/stops/CHA7AWN/trips.json?per_page=2000')
28
- .replyWithFile(200, `${__dirname}/fixtures/stops-CHA7AWN-trips.json`);
27
+ .get('/stops/BRO12WN/next.json')
28
+ .replyWithFile(200, `${__dirname}/fixtures/stops-BRO12WN-next.json`);
29
+ nock('https://gtfs.transitnownash.org')
30
+ .get('/stops/PORGRESF/next.json')
31
+ .replyWithFile(200, `${__dirname}/fixtures/stops-PORGRESF-next.json`);
29
32
  });
30
33
 
31
34
  afterEach(() => {
@@ -35,8 +38,8 @@ describe('hubot-nextbus', () => {
35
38
 
36
39
  context('regular tests with latitude/longitude set', () => {
37
40
  beforeEach(function () {
38
- Date.now = () => Date.parse('Fri, 1 Oct 2021 12:00:00 UTC');
39
- process.env.HUBOT_NEXTBUS_LAT_LON = '36.1650,-86.78404';
41
+ Date.now = () => Date.parse('Mon Feb 02 2026 21:41:49 GMT-0600 (Central Standard Time)');
42
+ process.env.HUBOT_NEXTBUS_LAT_LON = '36.156751,-86.787397';
40
43
  this.room = helper.createRoom();
41
44
  });
42
45
 
@@ -54,14 +57,18 @@ describe('hubot-nextbus', () => {
54
57
  try {
55
58
  expect(selfRoom.messages).to.eql([
56
59
  ['alice', '@hubot nextbus'],
57
- ['hubot', 'Upcoming Trips for [CHA7AWN] CHARLOTTE AVE & 7TH AVE N WB'],
58
60
  [
59
61
  'hubot',
60
- ' 7:01 AM #50 - CHARLOTTE WALMART in a minute \n'
61
- + ' 7:15 AM #17 - GREEN HILLS VIA 12TH AVE S in 16 minutes \n'
62
- + ' 7:16 AM #50 - CHARLOTTE WALMART in 16 minutes \n'
63
- + ' 7:31 AM #50 - CHARLOTTE WALMART in 31 minutes \n'
64
- + ' 7:35 AM #17 - GREEN HILLS VIA 12TH AVE S in 36 minutes ',
62
+ '⚠️ *Detour in effect on route 3 WEST END FROM DOWNTOWN*\n'
63
+ + '⚠️ *Detour in effect on route 3 WEST END TO DOWNTOWN*',
64
+ ],
65
+ [
66
+ 'hubot',
67
+ '🚏 *BROADWAY AVE & 12TH AVE N WB*\n'
68
+ + ' 9:50 PM #3 - A -WHITE BRIDGE 🚌 in 9 minutes (On time)\n'
69
+ + ' 10:00 PM #7 - GREEN HILLS in 19 minutes (On time)\n'
70
+ + ' 10:05 PM #3 - B - BELLEVUE in 24 minutes (On time)\n'
71
+ + ' 10:20 PM #3 - A -WHITE BRIDGE in 39 minutes (5m late)',
65
72
  ],
66
73
  ]);
67
74
  done();
@@ -76,20 +83,24 @@ describe('hubot-nextbus', () => {
76
83
  // hubot nextbus stop <id>
77
84
  it('returns the next bus for a particular stop', function (done) {
78
85
  const selfRoom = this.room;
79
- selfRoom.user.say('alice', '@hubot nextbus stop CHA7AWN');
86
+ selfRoom.user.say('alice', '@hubot nextbus stop BRO12WN');
80
87
  setTimeout(
81
88
  () => {
82
89
  try {
83
90
  expect(selfRoom.messages).to.eql([
84
- ['alice', '@hubot nextbus stop CHA7AWN'],
85
- ['hubot', 'Upcoming Trips for [CHA7AWN] CHARLOTTE AVE & 7TH AVE N WB'],
91
+ ['alice', '@hubot nextbus stop BRO12WN'],
92
+ [
93
+ 'hubot',
94
+ '⚠️ *Detour in effect on route 3 WEST END FROM DOWNTOWN*\n'
95
+ + '⚠️ *Detour in effect on route 3 WEST END TO DOWNTOWN*',
96
+ ],
86
97
  [
87
98
  'hubot',
88
- ' 7:01 AM #50 - CHARLOTTE WALMART in a minute \n'
89
- + ' 7:15 AM #17 - GREEN HILLS VIA 12TH AVE S in 16 minutes \n'
90
- + ' 7:16 AM #50 - CHARLOTTE WALMART in 16 minutes \n'
91
- + ' 7:31 AM #50 - CHARLOTTE WALMART in 31 minutes \n'
92
- + ' 7:35 AM #17 - GREEN HILLS VIA 12TH AVE S in 36 minutes ',
99
+ '🚏 *BROADWAY AVE & 12TH AVE N WB*\n'
100
+ + ' 9:50 PM #3 - A -WHITE BRIDGE 🚌 in 9 minutes (On time)\n'
101
+ + ' 10:00 PM #7 - GREEN HILLS in 19 minutes (On time)\n'
102
+ + ' 10:05 PM #3 - B - BELLEVUE in 24 minutes (On time)\n'
103
+ + ' 10:20 PM #3 - A -WHITE BRIDGE in 39 minutes (5m late)',
93
104
  ],
94
105
  ]);
95
106
  done();
@@ -113,11 +124,11 @@ describe('hubot-nextbus', () => {
113
124
  ['hubot', 'List of nearby stops:'],
114
125
  [
115
126
  'hubot',
116
- '- [CHA7AWN] CHARLOTTE AVE & 7TH AVE N WB\n'
117
- + '- [CHA7AEN] CHARLOTTE AVE & 7TH AVE N EB\n'
118
- + '- [6AVDEASN] 6TH AVE & DEADERICK ST SB\n'
119
- + '- [6AVDEANN] 6TH AVE N & DEADERICK ST NB\n'
120
- + '- [UNI7AWN] UNION ST & 7TH AVE N WB',
127
+ '- [BRO12WN] BROADWAY AVE & 12TH AVE N WB\n'
128
+ + '- [BRO12AEF] BROADWAY AVE & 12TH AVE EB\n'
129
+ + '- [11APORSF] 11TH AVE & PORTER ST SB\n'
130
+ + '- [11APORNN] 11TH AVE & PORTER ST NB\n'
131
+ + '- [BRO10AEN] BROADWAY & 10TH AVE EB',
121
132
  ],
122
133
  ]);
123
134
  done();
@@ -132,9 +143,9 @@ describe('hubot-nextbus', () => {
132
143
 
133
144
  context('regular tests with default stop ID set', () => {
134
145
  beforeEach(function () {
135
- Date.now = () => Date.parse('Fri, 1 Oct 2021 12:00:00 UTC');
146
+ Date.now = () => Date.parse('Mon Feb 02 2026 21:41:49 GMT-0600 (Central Standard Time)');
136
147
  process.env.HUBOT_NEXTBUS_LAT_LON = '0,0';
137
- process.env.HUBOT_NEXTBUS_STOP_ID = 'CHA7AWN';
148
+ process.env.HUBOT_NEXTBUS_STOP_ID = 'BRO12WN';
138
149
  this.room = helper.createRoom();
139
150
  });
140
151
 
@@ -153,14 +164,17 @@ describe('hubot-nextbus', () => {
153
164
  try {
154
165
  expect(selfRoom.messages).to.eql([
155
166
  ['alice', '@hubot nextbus'],
156
- ['hubot', 'Upcoming Trips for [CHA7AWN] CHARLOTTE AVE & 7TH AVE N WB'],
157
167
  [
158
168
  'hubot',
159
- ' 7:01 AM #50 - CHARLOTTE WALMART in a minute \n'
160
- + ' 7:15 AM #17 - GREEN HILLS VIA 12TH AVE S in 16 minutes \n'
161
- + ' 7:16 AM #50 - CHARLOTTE WALMART in 16 minutes \n'
162
- + ' 7:31 AM #50 - CHARLOTTE WALMART in 31 minutes \n'
163
- + ' 7:35 AM #17 - GREEN HILLS VIA 12TH AVE S in 36 minutes ',
169
+ '⚠️ *Detour in effect on route 3 WEST END FROM DOWNTOWN*\n'
170
+ + '⚠️ *Detour in effect on route 3 WEST END TO DOWNTOWN*'],
171
+ [
172
+ 'hubot',
173
+ '🚏 *BROADWAY AVE & 12TH AVE N WB*\n'
174
+ + ' 9:50 PM #3 - A -WHITE BRIDGE 🚌 in 9 minutes (On time)\n'
175
+ + ' 10:00 PM #7 - GREEN HILLS in 19 minutes (On time)\n'
176
+ + ' 10:05 PM #3 - B - BELLEVUE in 24 minutes (On time)\n'
177
+ + ' 10:20 PM #3 - A -WHITE BRIDGE in 39 minutes (5m late)',
164
178
  ],
165
179
  ]);
166
180
  done();
@@ -175,32 +189,27 @@ describe('hubot-nextbus', () => {
175
189
 
176
190
  context('time spans days', () => {
177
191
  beforeEach(function () {
178
- Date.now = () => Date.parse('Fri, 1 Oct 2021 04:00:00 UTC');
179
- process.env.HUBOT_NEXTBUS_LAT_LON = '36.1650,-86.78404';
192
+ Date.now = () => Date.parse('Mon Feb 02 2026 23:53:49 GMT-0600 (Central Standard Time)');
180
193
  this.room = helper.createRoom();
181
194
  });
182
195
 
183
196
  afterEach(function () {
184
197
  this.room.destroy();
185
- delete process.env.HUBOT_NEXTBUS_LAT_LON;
186
198
  });
187
199
 
188
- // hubot nextbus
189
- it('returns the next bus for closest stop', function (done) {
200
+ it('returns the next bus for specific stop', function (done) {
190
201
  const selfRoom = this.room;
191
- selfRoom.user.say('alice', '@hubot nextbus');
202
+ selfRoom.user.say('alice', '@hubot nextbus stop PORGRESF');
192
203
  setTimeout(
193
204
  () => {
194
205
  try {
195
206
  expect(selfRoom.messages).to.eql([
196
- ['alice', '@hubot nextbus'],
197
- ['hubot', 'Upcoming Trips for [CHA7AWN] CHARLOTTE AVE & 7TH AVE N WB'],
207
+ ['alice', '@hubot nextbus stop PORGRESF'],
198
208
  [
199
209
  'hubot',
200
- ' 11:16 PM #50 - CHARLOTTE WALMART in 16 minutes \n'
201
- + ' 11:15 PM #17 - GREEN HILLS VIA 12TH AVE S in 16 minutes \n'
202
- + ' 11:46 PM #50 - CHARLOTTE WALMART in an hour \n'
203
- + ' 12:16 AM #50 - CHARLOTTE WALMART in an hour ',
210
+ '🚏 *PORTER RD & GREENWOOD AVE SB*\n'
211
+ + ' 12:48 AM #4 - DOWNTOWN in an hour\n'
212
+ + ' 1:48 AM #4 - SHELBY PARK in 2 hours',
204
213
  ],
205
214
  ]);
206
215
  done();