@@ -329,17 +329,23 @@ describe('instagram nodes', function() {
329329 fetchUploadedPhotos ( done , true , false ) ;
330330 } ) ;
331331
332- it ( 'handles like with init' , function ( done ) {
332+ it ( 'handles like with init and gets metadata ' , function ( done ) {
333333
334334 var newPhotoURL = "http://new_liked_photo_standard.jpg" ;
335335 var oldID = "MY_OLD_MEDIA_ID" ;
336336
337+ var injectedLat = "51.025115599" ;
338+ var injectedLon = "-1.396541077" ;
339+ var injectedTime = "1411724651" ;
340+
341+ var timeAsJSDate = new Date ( injectedTime * 1000 ) ;
342+
337343 // need to fake the HTTP requests of the init sequence, then straight away the sequence of getting a second photo
338344 var scope = nock ( 'https://api.instagram.com' )
339345 . get ( '/v1/users/self/media/liked?count=1&access_token=AN_ACCESS_TOKEN' )
340346 . reply ( 200 , { "pagination" :{ } , "meta" :{ "code" :200 } , "data" :[ { "attribution" :null , "tags" :[ ] , "type" :"image" , "user_has_liked" :true , "id" :oldID } ] } )
341347 . 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 } ] } ) ;
343349
344350 helper . load ( instagramNode , [ { id :"instagramCredentials1" , type :"instagram-credentials" } ,
345351 { id :"instagramNode1" , type :"instagram" , instagram : "instagramCredentials1" , "inputType" :"like" , "outputType" :"link" , wires :[ [ "helperNode1" ] ] } ,
@@ -363,6 +369,9 @@ describe('instagram nodes', function() {
363369 if ( testInterval !== null ) {
364370 clearInterval ( testInterval ) ;
365371 }
372+ msg . lat . should . equal ( injectedLat ) ;
373+ msg . lon . should . equal ( injectedLon ) ;
374+ msg . time . toString ( ) . should . equal ( timeAsJSDate . toString ( ) ) ;
366375 msg . payload . should . equal ( newPhotoURL ) ;
367376 done ( ) ;
368377 } catch ( err ) {
@@ -381,18 +390,24 @@ describe('instagram nodes', function() {
381390 } ) ;
382391 } ) ;
383392
384- it ( 'manages to buffer an image' , function ( done ) {
393+ it ( 'manages to buffer an image and handles metadata ' , function ( done ) {
385394 var photo = '/photo.jpg' ;
386395 var apiURI = 'https://api.instagram.com' ;
387396 var photoURI = apiURI + photo ;
388397
389398 var replyText = "Hello World" ;
390399
400+ var injectedLat = "51.025115599" ;
401+ var injectedLon = "-1.396541077" ;
402+ var injectedTime = "1411724651" ;
403+
404+ var timeAsJSDate = new Date ( injectedTime * 1000 ) ;
405+
391406 var scope = nock ( 'https://api.instagram.com' )
392407 . get ( '/v1/users/self/media/recent?count=1&access_token=AN_ACCESS_TOKEN' ) // request to get the initial photos uploaded by the user
393408 . reply ( 200 , { "pagination" :{ } , "meta" :{ "code" :200 } , "data" :[ { "attribution" :null , "tags" :[ ] , "type" :"image" , "id" :"MY_OLD_MEDIA_ID" } ] } )
394409 . 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 } } ] } )
396411 . get ( photo )
397412 . reply ( 200 , replyText ) ;
398413
@@ -418,6 +433,11 @@ describe('instagram nodes', function() {
418433 if ( testInterval !== null ) {
419434 clearInterval ( testInterval ) ;
420435 }
436+
437+ msg . lat . should . equal ( injectedLat ) ;
438+ msg . lon . should . equal ( injectedLon ) ;
439+ msg . time . toString ( ) . should . equal ( timeAsJSDate . toString ( ) ) ;
440+
421441 msg . payload . toString ( ) . should . equal ( replyText ) ;
422442 done ( ) ;
423443 } catch ( err ) {
0 commit comments