1 | "use strict";
|
2 | let helioviewer = require('../index.js').helioviewer;
|
3 | let chai = require('chai');
|
4 | let expect = chai.expect;
|
5 | let chaiXml = require('chai-xml');
|
6 | chai.use(chaiXml);
|
7 | let chaiSubset = require('chai-subset');
|
8 | let chaiFiles = require('chai-files');
|
9 | let file = chaiFiles.file;
|
10 | let dir = chaiFiles.dir;
|
11 | chai.use(chaiFiles);
|
12 | chai.use(chaiSubset);
|
13 |
|
14 | let fs = require('fs');
|
15 | let assert = chai.assert;
|
16 |
|
17 | describe('Helioviewer', function() {
|
18 | it('should return json with all args jp2Image', function(done) {
|
19 | helioviewer.getjp2image({date:"2014-01-01T23:59:59", sourceId:14})
|
20 | .then(function(data){
|
21 | assert.containSubset(JSON.parse(data), {uri: "jpip://helioviewer.org:8090/AIA/2014/01/02/335/2014_01_02__00_00_02_62__SDO_AIA_AIA_335.jp2"});
|
22 | done();
|
23 |
|
24 | }).catch(done);
|
25 |
|
26 | });
|
27 |
|
28 | it('should return valid xml data jp2Header', function(done) {
|
29 | helioviewer.getjp2header(7654321).then(function(data){
|
30 | expect(data).xml.to.be.valid();
|
31 | done();
|
32 | }).catch(done);
|
33 | });
|
34 |
|
35 | it('should return json with all args getJPX', function(done) {
|
36 | helioviewer.getJPX({
|
37 | startTime: "2014-01-01T00:00:00",
|
38 | endTime: "2014-01-01T00:45:00" ,
|
39 | sourceId: 14,
|
40 | cadence: 12,
|
41 | linked: true
|
42 | })
|
43 | .then(function(data){
|
44 | assert.containSubset(JSON.parse(data), {uri: "jpip://helioviewer.org:8090/movies/SDO_AIA_335_F2014-01-01T00.00.00Z_T2014-01-01T00.45.00ZB12L.jpx"});
|
45 | done();
|
46 |
|
47 | }).catch(done);
|
48 |
|
49 | });
|
50 |
|
51 | it('should return json with all args getJPXClosestToMidpoint', function(done) {
|
52 | helioviewer.getJPXClosestToMidPoint({
|
53 | startTimes: [1306886400,1306887000,1306887600],
|
54 | endTimes: [1306886700,1306887300,1306887900] ,
|
55 | sourceId: 14,
|
56 | linked: true
|
57 | })
|
58 | .then(function(data){
|
59 | assert.containSubset(JSON.parse(data), {uri: "jpip://helioviewer.org:8090/movies/SDO_AIA_335_F2011-06-01T00.00.00Z_T2011-06-01T00.25.00ZLCMP.jpx"});
|
60 | done();
|
61 |
|
62 | }).catch(done);
|
63 |
|
64 | });
|
65 |
|
66 | it('should return json with all args queueMovie', function(done) {
|
67 | helioviewer.queueMovie({
|
68 | startTime: "2010-03-01T12:12:12",
|
69 | endTime: "2010-03-04T12:12:12",
|
70 | layers: "[3,1,100],[4,1,100]",
|
71 | events: "[AR,HMI_HARP;,SPoCA,1],[CH,all,1]",
|
72 | eventsLabels: false,
|
73 | imageScale: 21.04,
|
74 | format: "mp4",
|
75 | frameRate: 15,
|
76 | maxFrames: 300,
|
77 | scale: true,
|
78 | scaleType: "earth",
|
79 | scaleX: -1000,
|
80 | scaleY: -500,
|
81 | movieLength: 4.3333,
|
82 | watermark: true,
|
83 | width: 1920,
|
84 | height: 1200,
|
85 | x0: 0,
|
86 | y0: 0,
|
87 | x1: -5000,
|
88 | y1: -5000,
|
89 | x2: 5000,
|
90 | y2: 5000,
|
91 |
|
92 | })
|
93 | .then(function(data){
|
94 | expect(JSON.parse(data)).to.include.keys("eta");
|
95 | done();
|
96 |
|
97 | }).catch(done);
|
98 |
|
99 | });
|
100 | it('should return json with all args queueMovie', function(done) {
|
101 | helioviewer.queueMovie({
|
102 | startTime: "2010-03-01T12:12:12",
|
103 | endTime: "2010-03-04T12:12:12",
|
104 | layers: "[3,1,100],[4,1,100]",
|
105 | events: "[AR,HMI_HARP;,SPoCA,1],[CH,all,1]",
|
106 | eventsLabels: false,
|
107 | imageScale: 21.04,
|
108 | width: 1920,
|
109 | height: 1200,
|
110 | x0: 1,
|
111 | y0: 1
|
112 |
|
113 | })
|
114 | .then(function(data){
|
115 | expect(JSON.parse(data)).to.include.keys("eta");
|
116 | done();
|
117 |
|
118 | }).catch(done);
|
119 |
|
120 | });
|
121 | it('should return json with callback queueMovie', function(done) {
|
122 | helioviewer.queueMovie({
|
123 | startTime: "2010-03-01T12:12:12",
|
124 | endTime: "2010-03-04T12:12:12",
|
125 | layers: "[3,1,100],[4,1,100]",
|
126 | events: "[AR,HMI_HARP;,SPoCA,1],[CH,all,1]",
|
127 | eventsLabels: false,
|
128 | imageScale: 21.04,
|
129 | width: 1920,
|
130 | height: 1200,
|
131 | x0: 1,
|
132 | y0: 1,
|
133 | callback: ""
|
134 |
|
135 | })
|
136 | .then(function(data){
|
137 | expect(JSON.parse(data)).to.include.keys("eta");
|
138 | done();
|
139 |
|
140 | }).catch(done);
|
141 |
|
142 | });
|
143 | it('should return json with all args getMovieStatus', function(done) {
|
144 | helioviewer.getMovieStatus({
|
145 | id: "F3Dh5",
|
146 | format: "mp4",
|
147 | verbose: true,
|
148 |
|
149 |
|
150 | })
|
151 | .then(function(data){
|
152 | expect(JSON.parse(data)).to.include.keys("duration");
|
153 | done();
|
154 |
|
155 | }).catch(done);
|
156 |
|
157 | });
|
158 | it('should return json with token getMovieStatus', function(done) {
|
159 | helioviewer.getMovieStatus({
|
160 | id: "F3Dh5",
|
161 |
|
162 |
|
163 |
|
164 | token: "4673d6db4e2a3365ab361267f2a9a112"
|
165 | })
|
166 | .then(function(data){
|
167 | expect(JSON.parse(data)).to.include.keys("status");
|
168 | done();
|
169 |
|
170 | }).catch(done);
|
171 |
|
172 | });
|
173 | it('should return json with callback getMovieStatus', function(done) {
|
174 | helioviewer.getMovieStatus({
|
175 | id: "F3Dh5",
|
176 |
|
177 |
|
178 | callback: "",
|
179 | token: "4673d6db4e2a3365ab361267f2a9a112"
|
180 | })
|
181 | .then(function(data){
|
182 | expect(JSON.parse(data)).to.include.keys("status");
|
183 | done();
|
184 |
|
185 | }).catch(done);
|
186 |
|
187 | });
|
188 |
|
189 | it('should return json with all args reQueueMovie', function(done) {
|
190 | helioviewer.reQueueMovie("VXvX5")
|
191 | .then(function(data){
|
192 | expect(JSON.parse(data)).to.include.keys("error");
|
193 | done();
|
194 |
|
195 | }).catch(done);
|
196 |
|
197 | });
|
198 |
|
199 | it('should download file with all args downloadMovie', function() {
|
200 | helioviewer.downloadMovie({
|
201 | id: "VXvX5",
|
202 | format: "mp4",
|
203 | hq: true
|
204 | });
|
205 | expect(file('VXvX5.mp4')).to.exist;
|
206 |
|
207 | });
|
208 |
|
209 | it('should return req_url with all args playMovie', function() {
|
210 | let r = helioviewer.playMovie({
|
211 | id: "F3Dh5",
|
212 | format: "mp4",
|
213 | height: 1920,
|
214 | hq: true,
|
215 | width:1200
|
216 | });
|
217 | expect(r).to.equal("https://api.helioviewer.org/v2/playMovie/?id=F3Dh5&format=mp4&height=1920&hq=true&width=1200")
|
218 |
|
219 | });
|
220 |
|
221 | it('should return json with all args takeScreenshot', function(done) {
|
222 | this.timeout(30000);
|
223 | helioviewer.takeScreenshot({
|
224 | date: "2014-01-01T23:59:59",
|
225 | imageScale: 2.4204409,
|
226 | layers: "[SDO,AIA,AIA,335,1,100]",
|
227 | eventLabels: false,
|
228 | height: 1200,
|
229 | events: "[AR,HMI_HARP;SPoCA,1],[CH,all,1]",
|
230 | scale: true,
|
231 | scaleType: "earth",
|
232 | scaleX: -1000,
|
233 | scaleY: -500,
|
234 | width: 1920,
|
235 | x0: 1,
|
236 | y0: 1,
|
237 | x1: -5000,
|
238 | y1: -5000,
|
239 | x2: 5000,
|
240 | y2: 5000,
|
241 | display: false,
|
242 | watermark: true,
|
243 | callback: ""
|
244 | }).then(function(data){
|
245 | expect(JSON.parse(data)).to.include.keys("id");
|
246 | done();
|
247 | }).catch(done);
|
248 | });
|
249 | it('should return json with display true takeScreenshot', function(done) {
|
250 | this.timeout(30000);
|
251 | let url = helioviewer.takeScreenshot({
|
252 | date: "2014-01-01T23:59:59",
|
253 | imageScale: 2.4204409,
|
254 | layers: "[SDO,AIA,AIA,335,1,100]",
|
255 | eventLabels: false,
|
256 | height: 1200,
|
257 | events: "[AR,HMI_HARP;SPoCA,1],[CH,all,1]",
|
258 | width: 1920,
|
259 | x0: 1,
|
260 | y0: 1,
|
261 | display: true
|
262 |
|
263 | });
|
264 | expect(url).to.equal("https://api.helioviewer.org/v2/takeScreenshot/?date=2014-01-01T23:59:59Z&imageScale=2.4204409&layers=[SDO,AIA,AIA,335,1,100]&height=1200&events=[AR,HMI_HARP;SPoCA,1],[CH,all,1]&width=1920&x0=1&y0=1&display=true");
|
265 | done();
|
266 | });
|
267 | it('should return json with all args getClosestImage', function(done) {
|
268 | helioviewer.getClosestImage({date: "2014-01-01T23:59:59", sourceId: 14, callback: ""}).then(function(data){
|
269 | expect(JSON.parse(data)).to.include.keys("id");
|
270 | done();
|
271 | }).catch(done);
|
272 | });
|
273 |
|
274 | it('should download file with all args downloadScreenshot', function() {
|
275 | helioviewer.downloadScreenshot(3240748);
|
276 | expect(file('3240748.png')).to.exist;
|
277 |
|
278 | });
|
279 |
|
280 | it('should return json with all args getDataSources', function(done) {
|
281 | helioviewer.getDataSources({
|
282 | verbose: true,
|
283 | enable: "[Yohkoh,STEREO_A,STEREO_B]",
|
284 | callback: ""
|
285 | }).then(function(data){
|
286 | expect(JSON.parse(data)).to.include.keys("Yohkoh");
|
287 | done();
|
288 | }).catch(done);
|
289 | });
|
290 | it('should return json with no args getDataSources', function(done) {
|
291 | helioviewer.getDataSources().then(function(data){
|
292 | expect(JSON.parse(data)).to.include.keys("Yohkoh");
|
293 | done();
|
294 | }).catch(done);
|
295 | });
|
296 |
|
297 | it('should return req_url with all args getTile', function(done) {
|
298 | let r = helioviewer.getTile({
|
299 | id: 36275490,
|
300 | x: -1,
|
301 | y: -1,
|
302 | imageScale: 2.42044088
|
303 | });
|
304 | expect(r).to.equal("https://api.helioviewer.org/v2/getTile/?id=36275490&x=-1&y=-1&imageScale=2.42044088");
|
305 | done()
|
306 | });
|
307 |
|
308 | it('should return json with all args shortenUrl', function(done) {
|
309 | let r = helioviewer.shortenURL("date%3D2014-02-25T15%3A18%3A07.000Z%26imageScale%3D2.4204409%26centerX%3D-410.06307838566283%26centerY%3D-244.6662219973343%26imageLayers%3D%255BSDO%2CAIA%2CAIA%2C304%2C1%2C100%255D%26eventLayers%3D%26eventLabels%3Dtrue","")
|
310 | .then(function(data){
|
311 | expect(JSON.parse(data)).to.include.keys("data");
|
312 | done();
|
313 | }).catch(done);
|
314 | });
|
315 |
|
316 | it('should return json with all args getNewsFeed', function(done) {
|
317 | let r = helioviewer.getNewsFeed("")
|
318 | .then(function(data){
|
319 | expect(data).xml.to.be.valid();
|
320 | done();
|
321 | }).catch(done);
|
322 | });
|
323 |
|
324 | it('should return req_url with all args checkYouTubeAuth', function(done) {
|
325 | helioviewer.checkYouTubeAuth("")
|
326 | .then(function (data) {
|
327 | expect(JSON.parse(data)).to.equal(false);
|
328 | done();
|
329 | }).catch(done);
|
330 | });
|
331 |
|
332 | it('should return req_url with all args getYouTubeAuth', function(done) {
|
333 | let r = helioviewer.getYouTubeAuth({
|
334 | id: "F3Dh5",
|
335 | title: "Test",
|
336 | description: "This movie was produced by Helioviewer.org. See the original at http://helioviewer.org/?movieId=F3Dh5 or download a high-quality version from http://api.helioviewer.org/v2/downloadMovie/?id=F3Dh5&format=mp4&hq=true",
|
337 | tags: "test",
|
338 | share: true
|
339 | });
|
340 | expect(r).to.equal("https://api.helioviewer.org/v2/getYouTubeAuth/?id=F3Dh5&title=Test&description=This movie was produced by Helioviewer.org. See the original at http://helioviewer.org/?movieId=F3Dh5 or download a high-quality version from http://api.helioviewer.org/v2/downloadMovie/?id=F3Dh5&format=mp4&hq=true&tags=test&share=true");
|
341 | done()
|
342 | });
|
343 |
|
344 | it('should return req_url with all args getYouTubeAuth', function(done) {
|
345 | helioviewer.uploadMovieToYouTube({
|
346 | id: "F3Dh5",
|
347 | share: true,
|
348 | title: "test",
|
349 | description: "test",
|
350 | tags: "SDO,AIA,94"
|
351 | }).then(function(data){
|
352 | expect(JSON.parse(data)).to.include.keys("error");
|
353 | done()
|
354 | })
|
355 |
|
356 | });
|
357 |
|
358 | it('should return json with no args getUserVideos', function(done) {
|
359 | helioviewer.getUserVideos()
|
360 | .then(function(data){
|
361 | expect(JSON.parse(data)[0]).to.include.keys("id");
|
362 | done();
|
363 | }).catch(done);
|
364 | });
|
365 |
|
366 | it('should return json with all args getUserVideos', function(done) {
|
367 | helioviewer.getUserVideos({
|
368 | num: 5,
|
369 | since: "2014-01-01T23:59:59",
|
370 | force: true
|
371 | })
|
372 | .then(function(data){
|
373 | expect(JSON.parse(data)[0]).to.include.keys("id");
|
374 | done();
|
375 | }).catch(done);
|
376 | });
|
377 | });
|