@@ -329,17 +329,23 @@ describe('instagram nodes', function() {
329
329
fetchUploadedPhotos ( done , true , false ) ;
330
330
} ) ;
331
331
332
- it ( 'handles like with init' , function ( done ) {
332
+ it ( 'handles like with init and gets metadata ' , function ( done ) {
333
333
334
334
var newPhotoURL = "http://new_liked_photo_standard.jpg" ;
335
335
var oldID = "MY_OLD_MEDIA_ID" ;
336
336
337
+ var injectedLat = "51.025115599" ;
338
+ var injectedLon = "-1.396541077" ;
339
+ var injectedTime = "1411724651" ;
340
+
341
+ var timeAsJSDate = new Date ( injectedTime * 1000 ) ;
342
+
337
343
// need to fake the HTTP requests of the init sequence, then straight away the sequence of getting a second photo
338
344
var scope = nock ( 'https://api.instagram.com' )
339
345
. get ( '/v1/users/self/media/liked?count=1&access_token=AN_ACCESS_TOKEN' )
340
346
. reply ( 200 , { "pagination" :{ } , "meta" :{ "code" :200 } , "data" :[ { "attribution" :null , "tags" :[ ] , "type" :"image" , "user_has_liked" :true , "id" :oldID } ] } )
341
347
. get ( '/v1/users/self/media/liked?access_token=AN_ACCESS_TOKEN' )
342
- . reply ( 200 , { "pagination" :{ } , "meta" :{ "code" :200 } , "data" :[ { "attribution" :null , "tags" :[ ] , "type" :"image" , "images" :{ "standard_resolution" :{ "url" :newPhotoURL } } } , { "attribution" :null , "tags" :[ ] , "type" :"image" , "id" :oldID } ] } ) ;
348
+ . reply ( 200 , { "pagination" :{ } , "meta" :{ "code" :200 } , "data" :[ { "attribution" :null , "tags" :[ ] , "type" :"image" , "images" :{ "standard_resolution" :{ "url" :newPhotoURL } } , "created_time" : injectedTime , "location" : { "latitude" : injectedLat , "name" : "IBM Hursley" , "longitude" : injectedLon } } , { "attribution" :null , "tags" :[ ] , "type" :"image" , "id" :oldID } ] } ) ;
343
349
344
350
helper . load ( instagramNode , [ { id :"instagramCredentials1" , type :"instagram-credentials" } ,
345
351
{ id :"instagramNode1" , type :"instagram" , instagram : "instagramCredentials1" , "inputType" :"like" , "outputType" :"link" , wires :[ [ "helperNode1" ] ] } ,
@@ -363,6 +369,9 @@ describe('instagram nodes', function() {
363
369
if ( testInterval !== null ) {
364
370
clearInterval ( testInterval ) ;
365
371
}
372
+ msg . lat . should . equal ( injectedLat ) ;
373
+ msg . lon . should . equal ( injectedLon ) ;
374
+ msg . time . toString ( ) . should . equal ( timeAsJSDate . toString ( ) ) ;
366
375
msg . payload . should . equal ( newPhotoURL ) ;
367
376
done ( ) ;
368
377
} catch ( err ) {
@@ -381,18 +390,24 @@ describe('instagram nodes', function() {
381
390
} ) ;
382
391
} ) ;
383
392
384
- it ( 'manages to buffer an image' , function ( done ) {
393
+ it ( 'manages to buffer an image and handles metadata ' , function ( done ) {
385
394
var photo = '/photo.jpg' ;
386
395
var apiURI = 'https://api.instagram.com' ;
387
396
var photoURI = apiURI + photo ;
388
397
389
398
var replyText = "Hello World" ;
390
399
400
+ var injectedLat = "51.025115599" ;
401
+ var injectedLon = "-1.396541077" ;
402
+ var injectedTime = "1411724651" ;
403
+
404
+ var timeAsJSDate = new Date ( injectedTime * 1000 ) ;
405
+
391
406
var scope = nock ( 'https://api.instagram.com' )
392
407
. get ( '/v1/users/self/media/recent?count=1&access_token=AN_ACCESS_TOKEN' ) // request to get the initial photos uploaded by the user
393
408
. reply ( 200 , { "pagination" :{ } , "meta" :{ "code" :200 } , "data" :[ { "attribution" :null , "tags" :[ ] , "type" :"image" , "id" :"MY_OLD_MEDIA_ID" } ] } )
394
409
. get ( '/v1/users/self/media/recent?min_id=MY_OLD_MEDIA_ID&access_token=AN_ACCESS_TOKEN' )
395
- . reply ( 200 , { "pagination" :{ } , "meta" :{ "code" :200 } , "data" :[ { "attribution" :null , "tags" :[ ] , "type" :"image" , "images" :{ "standard_resolution" :{ "url" :photoURI , "width" :640 , "height" :640 } } , "id" :"A_NEW_PHOTO_ID" } ] } )
410
+ . reply ( 200 , { "pagination" :{ } , "meta" :{ "code" :200 } , "data" :[ { "attribution" :null , "tags" :[ ] , "type" :"image" , "images" :{ "standard_resolution" :{ "url" :photoURI , "width" :640 , "height" :640 } } , "id" :"A_NEW_PHOTO_ID" , "created_time" : injectedTime , "location" : { "latitude" : injectedLat , "name" : "IBM Hursley" , "longitude" : injectedLon } } ] } )
396
411
. get ( photo )
397
412
. reply ( 200 , replyText ) ;
398
413
@@ -418,6 +433,11 @@ describe('instagram nodes', function() {
418
433
if ( testInterval !== null ) {
419
434
clearInterval ( testInterval ) ;
420
435
}
436
+
437
+ msg . lat . should . equal ( injectedLat ) ;
438
+ msg . lon . should . equal ( injectedLon ) ;
439
+ msg . time . toString ( ) . should . equal ( timeAsJSDate . toString ( ) ) ;
440
+
421
441
msg . payload . toString ( ) . should . equal ( replyText ) ;
422
442
done ( ) ;
423
443
} catch ( err ) {
0 commit comments