-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
59 lines (49 loc) · 2.1 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
import test from 'ava'
import luqs from '.'
test('luqs()', async t => {
const stations = await luqs()
t.truthy(Array.isArray(stations))
t.truthy(stations.length > 160)
})
test('luqs({ allStations: true })', async t => {
const stations = await luqs({ allStations: true })
t.truthy(Array.isArray(stations))
t.truthy(stations.length > 578)
})
test('luqs.station() should reject with TypeError', async t => {
const error = await t.throwsAsync(luqs.station())
t.is(error.message, 'Expected a string')
})
test('luqs.station() should reject with Error is to short', async t => {
const error = await t.throwsAsync(luqs.station('AAH'))
t.is(error.message, 'Kuerzel is to short')
})
test('luqs.station() should reject with Error is to long', async t => {
const error = await t.throwsAsync(luqs.station('AAAAAAA'))
t.is(error.message, 'Kuerzel is to long')
})
test('luqs.station("unna") should return detailed information about a specific station', async t => {
const details = await luqs.station('unna')
t.truthy(Array.isArray(details))
t.is(details[0].kuerzel, 'UNNA')
})
test('luqs.aktuell() should resolve with array', async t => {
const currentMeasurements = await luqs.aktuell()
t.truthy(Array.isArray(currentMeasurements))
t.truthy(currentMeasurements.length >= 1)
})
test('luqs.aktuell() should resolve with array containing current measurements', async t => {
const currentMeasurements = await luqs.aktuell()
t.truthy(Array.isArray(currentMeasurements))
t.truthy(currentMeasurements.length >= 1)
})
test('luqs.aktuell() measurement object should have all keys', async t => {
const currentMeasurements = await luqs.aktuell()
const measurement = currentMeasurements[0]
t.truthy(Object.prototype.hasOwnProperty.call(measurement, 'station'))
t.truthy(Object.prototype.hasOwnProperty.call(measurement, 'kuerzel'))
t.truthy(Object.prototype.hasOwnProperty.call(measurement, 'ozon'))
t.truthy(Object.prototype.hasOwnProperty.call(measurement, 'so2'))
t.truthy(Object.prototype.hasOwnProperty.call(measurement, 'no2'))
t.truthy(Object.prototype.hasOwnProperty.call(measurement, 'pm10'))
})