-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
47 lines (36 loc) · 926 Bytes
/
test.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
'use strict'
const test = require('tape')
const stations = require('.')
test('stations is an array with items', (t) => {
t.plan(2)
t.ok(Array.isArray(stations))
t.ok(stations.length > 0)
})
test('each station is valid', (t) => {
for (let s of stations) {
t.equal(typeof s.id, 'string')
t.ok(s.id)
t.equal(typeof s.name, 'string')
t.ok(s.name)
if (s.coordinates) {
t.equal(typeof s.coordinates.latitude, 'number')
t.equal(typeof s.coordinates.longitude, 'number')
}
if (s.city) {
t.equal(typeof s.city.id, 'string')
t.ok(s.city.id)
t.equal(typeof s.city.name, 'string')
t.ok(s.city.name)
}
t.equal(typeof s.weight, 'number')
if (s.tags) {
t.ok(Array.isArray(s.tags))
for (let tag of s.tags) t.equal(typeof tag, 'string')
}
t.equal(typeof s.country.id, 'string')
t.ok(s.country.id)
t.equal(typeof s.country.name, 'string')
t.ok(s.country.name)
}
t.end()
})