UNPKG

11.9 kBJavaScriptView Raw
1"use strict";
2let ssd = require('../index.js').ssd;
3let chai = require('chai');
4let chaiSubset = require('chai-subset');
5let assert = chai.assert;
6chai.use(chaiSubset);
7
8describe('SSD', function() {
9 describe('CAD', function() {
10 it('should return json with no args ', function (done) {
11 this.timeout(5000);
12 ssd.cad()
13 .then(function (data) {
14 assert.containSubset(JSON.parse(data), {
15 signature: {
16 source: "NASA/JPL SBDB Close Approach Data API"
17 },
18 });
19 done();
20
21 }).catch(done);
22
23 });
24
25 it('should return json with all args ', function (done) {
26 this.timeout(10000);
27 ssd.cad({
28 date_min: "2015-03-01",
29 date_max: "2017-03-01",
30 dist_min: "10LD",
31 dist_max: "200LD",
32 h_min: 1,
33 h_max: 99,
34 v_inf_min: 1,
35 v_inf_max: 99,
36 v_rel_min: 1,
37 v_rel_max: 99,
38 class: "ATE",
39 pha: false,
40 nea: false,
41 comet: false,
42 nea_comet: false,
43 neo: false,
44 kind: "a",
45 //spk: 2000433,
46 //des: "433",
47 body: "Earth",
48 sort: "date",
49 limit: 100,
50 fullname: true
51 })
52 .then(function (data) {
53 assert.containSubset(JSON.parse(data), {
54 signature: {
55 source: "NASA/JPL SBDB Close Approach Data API"
56 },
57 });
58 done();
59
60 }).catch(done);
61
62 });
63 it('should return json with spk args ', function (done) {
64 this.timeout(10000);
65 ssd.cad({spk: 2000433})
66 .then(function (data) {
67 assert.containSubset(JSON.parse(data), {
68 signature: {
69 source: "NASA/JPL SBDB Close Approach Data API"
70 },
71 });
72 done();
73
74 }).catch(done);
75
76 });
77
78 it('should return json with des args ', function (done) {
79 this.timeout(10000);
80 ssd.cad({des: "433"})
81 .then(function (data) {
82 assert.containSubset(JSON.parse(data), {
83 signature: {
84 source: "NASA/JPL SBDB Close Approach Data API"
85 },
86 });
87 done();
88
89 }).catch(done);
90
91 });
92
93 it('should return json with pha args ', function (done) {
94 this.timeout(10000);
95 ssd.cad({pha: true})
96 .then(function (data) {
97 assert.containSubset(JSON.parse(data), {
98 signature: {
99 source: "NASA/JPL SBDB Close Approach Data API"
100 },
101 });
102 done();
103
104 }).catch(done);
105
106 });
107 it('should return json with nea args ', function (done) {
108 this.timeout(10000);
109 ssd.cad({nea: true})
110 .then(function (data) {
111 assert.containSubset(JSON.parse(data), {
112 signature: {
113 source: "NASA/JPL SBDB Close Approach Data API"
114 },
115 });
116 done();
117
118 }).catch(done);
119
120 });
121 it('should return json with comet args ', function (done) {
122 this.timeout(10000);
123 ssd.cad({comet: true})
124 .then(function (data) {
125 assert.containSubset(JSON.parse(data), {
126 signature: {
127 source: "NASA/JPL SBDB Close Approach Data API"
128 },
129 });
130 done();
131
132 }).catch(done);
133
134 });
135 it('should return json with nea-comet args ', function (done) {
136 this.timeout(10000);
137 ssd.cad({nea_comet: true})
138 .then(function (data) {
139 assert.containSubset(JSON.parse(data), {
140 signature: {
141 source: "NASA/JPL SBDB Close Approach Data API"
142 },
143 });
144 done();
145
146 }).catch(done);
147
148 });
149 it('should return json with neo args ', function (done) {
150 this.timeout(10000);
151 ssd.cad({neo: true})
152 .then(function (data) {
153 assert.containSubset(JSON.parse(data), {
154 signature: {
155 source: "NASA/JPL SBDB Close Approach Data API"
156 },
157 });
158 done();
159
160 }).catch(done);
161
162 });
163 });
164
165 describe('Fireballs', function(){
166
167 it('should return json with no args ', function (done) {
168 this.timeout(10000);
169 ssd.fireballs()
170 .then(function (data) {
171 assert.containSubset(JSON.parse(data), {
172 signature: {
173 source: "NASA/JPL Fireball Data API"
174 },
175 });
176 done();
177
178 }).catch(done);
179
180 });
181
182 it('should return json with all args ', function (done) {
183 this.timeout(10000);
184 ssd.fireballs({
185 date_min: "2015-03-01",
186 date_max: "2017-03-01",
187 energy_min: 1,
188 energy_max: 99,
189 impact_e_min: 1,
190 impact_e_max: 99,
191 vel_min: 1,
192 vel_max: 99,
193 req_loc: true,
194 req_alt: true,
195 req_vel: true,
196 req_vel_comp: true,
197 vel_comp: true,
198 sort: "date",
199 limit: 100
200 })
201 .then(function (data) {
202 assert.containSubset(JSON.parse(data), {
203 signature: {
204 source: "NASA/JPL Fireball Data API"
205 },
206 });
207 done();
208
209 }).catch(done);
210
211 });
212
213 });
214
215 describe('NHATS', function() {
216
217 it('should return json with no args ', function (done) {
218 this.timeout(10000);
219 ssd.nhats()
220 .then(function (data) {
221 assert.containSubset(JSON.parse(data), {
222 signature: {
223 source: "NASA/JPL NHATS Data API",
224 },
225 });
226 done();
227
228 }).catch(done);
229
230 });
231
232 it('should return json with all args ', function (done) {
233 this.timeout(10000);
234 ssd.nhats({
235 dv: 12,
236 dur: 450,
237 stay: 16,
238 launch: "2015-2020",
239 h: 30,
240 occ: 8,
241 //spk: 2000433,
242 //des: "433",
243 plot: true
244 })
245 .then(function (data) {
246 assert.containSubset(JSON.parse(data), {
247 signature: {
248 source: "NASA/JPL NHATS Data API",
249 },
250 });
251 done();
252
253 }).catch(done);
254
255 });
256
257 it('should return json with spk args ', function (done) {
258 this.timeout(10000);
259 ssd.nhats({
260 spk: 2000433,
261 plot: true
262 })
263 .then(function (data) {
264 assert.containSubset(JSON.parse(data), {
265 error: "specified NHATS object not found"
266 });
267 done();
268
269 }).catch(done);
270
271 });
272
273 it('should return json with des args ', function (done) {
274 this.timeout(10000);
275 ssd.nhats({
276 des: "433",
277 })
278 .then(function (data) {
279 assert.containSubset(JSON.parse(data),
280 {
281 error: "specified NHATS object not found"
282 }
283 );
284 done();
285
286 }).catch(done);
287
288 });
289 });
290
291 describe("Sentry", function (done) {
292 it('should return json with no args ', function (done) {
293 this.timeout(10000);
294 ssd.sentry()
295 .then(function (data) {
296 assert.containSubset(JSON.parse(data), {
297 signature: {
298 source: "NASA/JPL Sentry Data API",
299 },
300 });
301 done();
302
303 }).catch(done);
304
305 });
306
307 it('should return json with all args ', function (done) {
308 this.timeout(10000);
309 ssd.sentry({
310 //spk: 2029075,
311 //des: 29075,
312 h_max: 50,
313 ps_min: 10,
314 ip_min: 1e-3,
315 days: 7,
316 all: true,
317 //removed: false
318 })
319 .then(function (data) {
320 assert.containSubset(JSON.parse(data), {
321 signature: {
322 source: "NASA/JPL Sentry Data API",
323 },
324 });
325 done();
326
327 }).catch(done);
328
329 });
330 it('should return json with spk args ', function (done) {
331 this.timeout(10000);
332 ssd.sentry({
333 spk: 2029075
334 })
335 .then(function (data) {
336 assert.containSubset(JSON.parse(data), {
337 signature: {
338 source: "NASA/JPL Sentry Data API",
339 },
340 });
341 done();
342
343 }).catch(done);
344
345 });
346
347 it('should return json with des args ', function (done) {
348 this.timeout(10000);
349 ssd.sentry({
350 des: 29075
351 })
352 .then(function (data) {
353 assert.containSubset(JSON.parse(data), {
354 signature: {
355 source: "NASA/JPL Sentry Data API",
356 },
357 });
358 done();
359
360 }).catch(done);
361
362 });
363
364 it('should return json with removed args ', function (done) {
365 this.timeout(10000);
366 ssd.sentry({
367 removed: true
368 })
369 .then(function (data) {
370 assert.containSubset(JSON.parse(data), {
371 signature: {
372 source: "NASA/JPL Sentry Data API",
373 },
374 });
375 done();
376
377 }).catch(done);
378
379 });
380 });
381});
382