-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsamples.test.mjs
148 lines (141 loc) · 3.65 KB
/
samples.test.mjs
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import { getSamples } from './data.mjs'
import { it } from 'vitest'
const centralParkData = {
name: 'HOBO Weather Station - SN 8388608',
timezone: 'UTC-300 minutes',
header: [
'Date_Time',
'Pressure_10660975_in_Hg',
'carbon_9807985_ppm',
'carbon2_9807972_ppm',
'Rain_10680977_in',
'Solar Radiation_10612119_W/m^2',
'Temperature_10693502_deg_F',
'RH_10693502b_%'
],
samples: [
[1561999500000, 29.702, 358.643, 0.244, 0.000, 701.875, 84.811, 72.700], // Mon Jul 1 12:45:00
[1562000400000, 29.690, 359.619, 0.244, 0.000, 406.875, 85.216, 70.300], // Mon Jul 1 13:00:00
[1562001300000, 29.693, 359.131, 0.244, 0.000, 558.125, 84.901, 71.000], // Mon Jul 1 13:15:00
[1562002200000, 29.687, 356.201, 0.244, 0.071, 151.875, 84.093, 70.500], // Mon Jul 1 13:30:00
[1562003100000, 29.681, 365.967, 0.244, 0.000, 35.625, 81.554, 73.900], // Mon Jul 1 13:45:00
[1562004000000, 29.693, 367.920, 0.244, 0.000, 28.125, 78.602, 78.600], // Mon Jul 1 14:00:00
[1562004900000, 29.687, 372.314, 0.244, 0.071, 68.125, 75.550, 88.600] // Mon Jul 1 14:15:00
]
}
const pier17Data = {
name: 'HOBO Weather Station - SN 8388608',
timezone: 'UTC-300 minutes',
header: [
'Date_Time',
'Pressure_10096011_mbar',
'Water Temperature_SDI_0_2_F',
'Sp Cond_SDI_0_3_mS/cm',
'Salinity_SDI_0_4_ppt',
'Depth_SDI_0_5_m',
'pH_SDI_0_6_H+',
'pH mV_SDI_0_7_V',
'Turbidity_SDI_0_8_NTU',
'Chl_SDI_0_9_ug/L',
'Percent Oxygen_SDI_0_10_%',
'Concentration Oxygen_SDI_0_11_mg/L',
'Battery_SDI_0_12_volts',
'Corrected Depth_SDI_0_12_m'
],
samples: [
[1562000400000, 1020, 73.75, 11, 6.25, 2.162, 7.13, -52.8, 10, 3.9, 70, 5.77, 11.1, 2.09], // Mon Jul 01 2019 13:00:00
[1562001300000, 1020, 73.75, 11, 6.25, 2.162, 7.13, -52.8, 10, 3.9, 70, 5.77, 11.1, 2.09], // Mon Jul 01 2019 13:15:00
[1562002200000, 1021, 73.75, 11, 6.25, 2.162, 7.13, -52.8, 10, 3.9, 70, 5.77, 11.1, 2.09], // Mon Jul 01 2019 13:30:00
[1562003100000, 1022, 73.75, 11, 6.25, 2.162, 7.13, -52.8, 10, 3.9, 70, 5.77, 11.1, 2.09], // Mon Jul 01 2019 13:45:00
[]
]
}
const noaaData = {
data: [
{
t: '2019-07-01 13:00 GMT',
s: '1.065',
d: '150',
b: '11'
},
{
t: '2019-07-01 13:06 GMT',
s: '1.065',
d: '150',
b: '11'
},
{
t: '2019-07-01 13:12 GMT',
s: '1.065',
d: '150',
b: '11'
},
{
t: '2019-07-01 13:18 GMT',
s: '1.065',
d: '150',
b: '11'
},
{
t: '2019-07-01 13:24 GMT',
s: '1.065',
d: '150',
b: '11'
},
{
t: '2019-07-01 13:30 GMT',
s: '1.065',
d: '150',
b: '11'
},
{
t: '2019-07-01 13:36 GMT',
s: '1.065',
d: '150',
b: '11'
},
{
t: '2019-07-01 13:42 GMT',
s: '1.065',
d: '150',
b: '11'
},
{
t: '2019-07-01 13:48 GMT',
s: '0.987',
d: '153',
b: '11'
},
{
t: '2019-07-01 13:54 GMT',
s: '0.881',
d: '158',
b: '11'
},
{
t: '2019-07-01 14:00 GMT',
s: '0.814',
d: '162',
b: '11'
}
]
}
it('gets data', ({expect}) => {
const { samples } = getSamples({ noaaData, pier17Data, centralParkData })
const firstSample = samples[0]
const lastSample = samples[samples.length - 1]
// check timestamp of first sample
expect(firstSample).toEqual(
expect.objectContaining({
noaaTime: 1561989600000
})
)
// check timestamp of last sample
expect(lastSample).toEqual(
expect.objectContaining({
noaaTime: 1561989600000
})
)
// check length
// expect(samples.length).toBe(8)
})