This repository has been archived by the owner on Aug 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
/
mta.js
117 lines (102 loc) · 3.05 KB
/
mta.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
var should = require('should');
var Mta = require('../lib/mta');
var config = {
key: process.env.MTA_API_KEY,
};
describe('MTA', function () {
var mta,
serviceType,
stopId,
stopIds;
before(function (done) {
mta = new Mta({
key: config.key
});
stopId = 635;
stopIds = [635, 636, 637];
serviceType = 'subway';
done();
});
it('should return info for all MTA subway stops', function () {
return mta.stop()
.then(function (result) {
result.should.be.an.Object;
});
});
it('should get info for 1 MTA subway stop', function () {
return mta.stop(stopId)
.then(function (result) {
result.stop_id.should.equal(stopId.toString());
result.should.have.property('stop_name');
});
});
it('should get info for S30S', function() {
return mta.stop('S30S')
.then(function (result) {
result.stop_id.should.equal('S30S');
result.should.have.property('stop_name');
});
});
it('should get info for multiple MTA subway stop', function () {
return mta.stop(stopIds)
.then(function (result) {
stopIds.forEach(function (val) {
result.should.have.property(val);
});
});
});
it('should get MTA service status for all types', function () {
return mta.status()
.then(function (result) {
result.should.have.property('subway');
result.should.have.property('bus');
result.should.have.property('BT');
result.should.have.property('LIRR');
result.should.have.property('MetroNorth');
});
});
it('should get MTA service status for 1 type', function () {
return mta.status(serviceType)
.then(function (result) {
result.should.be.an.Array;
});
});
it('MTA_API_KEY should be set', function (done) {
config.key.should.not.equal('');
done();
});
it('should get schedule info for 1 MTA subway station (number input)', function () {
return mta.schedule(stopId)
.then(function (result) {
result.should.have.property('schedule');
result.should.have.property('updatedOn');
result.schedule[stopId].should.exist;
});
});
it('should get schedule info for 1 MTA subway station (string input)', function () {
return mta.schedule('128')
.then(function (result) {
result.should.have.property('schedule');
result.should.have.property('updatedOn');
result.schedule['128'].should.exist;
});
});
it('should get schedule info for a station with a different feed_id', function () {
return mta.schedule('A15', 26)
.then(function (result) {
result.should.have.property('schedule');
result.should.have.property('updatedOn');
result.schedule['A15'].should.exist;
});
});
it('should get schedule info for multiple MTA subway stations', function () {
return mta.schedule(stopIds)
.then(function (result) {
result.should.have.property('schedule');
result.should.have.property('updatedOn');
stopIds.forEach(function (val) {
result.schedule.should.have.property(val);
});
});
});
});