@@ -583,6 +583,88 @@ describe('foursquare nodes', function() {
583583 } ) ;
584584 } ) ;
585585
586+
587+ it ( 'can fetch multiple recommended sights for any day' , function ( done ) {
588+ helper . load ( foursquareNode ,
589+ [ { id :"n1" , type :"helper" , wires :[ [ "n2" ] ] } ,
590+ { id :"n4" , type :"foursquare-credentials" } ,
591+ { id :"n2" , type :"foursquare" , foursquare : "n4" , wires :[ [ "n3" ] ] , outputnumber :"10" , outputas :"single" , openday :"any" } ,
592+ { id :"n3" , type :"helper" } ] ,
593+ {
594+ "n4" : {
595+ displayname : "John" ,
596+ clientid : "987654321" ,
597+ clientsecret :"123456789" ,
598+ accesstoken :"abcd1234" ,
599+ } ,
600+ } ,
601+ function ( ) {
602+ var scope = nock ( 'https://api.foursquare.com:443' )
603+ . get ( '/v2/venues/explore?oauth_token=abcd1234§ion=sights&day=any&ll=51.03,-1.4&v=20141016&m=foursquare' )
604+ . reply ( 200 , { "meta" :{ "code" :200 } , "response" :{ "groups" :
605+ [ { "count" :1 , "items" :
606+ [ { "reasons" : { "count" : 1 , "items" : [ { "summary" : "You've been here 3 times" , "type" : "social" , "reasonName" : "friendAndSelfCheckinReason" , "count" : 0 } ] } ,
607+ "venue" : { "id" : "4da429a8b" , "name" : "Zoo" , "location" : { "lat" : 51.03 , "lng" : - 1.42 } } } ,
608+ { "reasons" : { "count" : 1 , "items" : [ { "summary" : "Very popular" , "type" : "social" , "reasonName" : "friendAndSelfCheckinReason" , "count" : 0 } ] } ,
609+ "venue" : { "id" : "5is0fe9fd" , "name" : "Playground" , "location" : { "lat" : 52.12 , "lng" : - 1.62 } } } ]
610+ } ] } } ) ;
611+
612+ var n1 = helper . getNode ( "n1" ) ;
613+ var n2 = helper . getNode ( "n2" ) ;
614+ var n3 = helper . getNode ( "n3" ) ;
615+ n2 . should . have . property ( 'id' , 'n2' ) ;
616+ n1 . send ( { payload :"nothing" , location :{ lat :"51.03" , lon :"-1.4" } , section :"sights" , foo :"bar" } ) ;
617+ n3 . on ( 'input' , function ( msg ) {
618+ msg . should . have . property ( 'foo' , "bar" ) ;
619+ msg . payload . should . be . an . instanceOf ( Array ) ;
620+ done ( ) ;
621+ } ) ;
622+
623+ } ) ;
624+ } ) ;
625+
626+
627+ it ( 'can fetch multiple recommended sights for any time' , function ( done ) {
628+ helper . load ( foursquareNode ,
629+ [ { id :"n1" , type :"helper" , wires :[ [ "n2" ] ] } ,
630+ { id :"n4" , type :"foursquare-credentials" } ,
631+ { id :"n2" , type :"foursquare" , foursquare : "n4" , wires :[ [ "n3" ] ] , outputnumber :"10" , outputas :"single" , opentime :"any" } ,
632+ { id :"n3" , type :"helper" } ] ,
633+ {
634+ "n4" : {
635+ displayname : "John" ,
636+ clientid : "987654321" ,
637+ clientsecret :"123456789" ,
638+ accesstoken :"abcd1234" ,
639+ } ,
640+ } ,
641+ function ( ) {
642+ var scope = nock ( 'https://api.foursquare.com:443' )
643+ . get ( '/v2/venues/explore?oauth_token=abcd1234§ion=sights&time=any&ll=51.03,-1.4&v=20141016&m=foursquare' )
644+ . reply ( 200 , { "meta" :{ "code" :200 } , "response" :{ "groups" :
645+ [ { "count" :1 , "items" :
646+ [ { "reasons" : { "count" : 1 , "items" : [ { "summary" : "You've been here 3 times" , "type" : "social" , "reasonName" : "friendAndSelfCheckinReason" , "count" : 0 } ] } ,
647+ "venue" : { "id" : "4da429a8b" , "name" : "Zoo" , "location" : { "lat" : 51.03 , "lng" : - 1.42 } } } ,
648+ { "reasons" : { "count" : 1 , "items" : [ { "summary" : "Very popular" , "type" : "social" , "reasonName" : "friendAndSelfCheckinReason" , "count" : 0 } ] } ,
649+ "venue" : { "id" : "5is0fe9fd" , "name" : "Playground" , "location" : { "lat" : 52.12 , "lng" : - 1.62 } } } ]
650+ } ] } } ) ;
651+
652+ var n1 = helper . getNode ( "n1" ) ;
653+ var n2 = helper . getNode ( "n2" ) ;
654+ var n3 = helper . getNode ( "n3" ) ;
655+ n2 . should . have . property ( 'id' , 'n2' ) ;
656+ n1 . send ( { payload :"nothing" , location :{ lat :"51.03" , lon :"-1.4" } , section :"sights" , foo :"bar" } ) ;
657+ n3 . on ( 'input' , function ( msg ) {
658+ msg . should . have . property ( 'foo' , "bar" ) ;
659+ msg . payload . should . be . an . instanceOf ( Array ) ;
660+ done ( ) ;
661+ } ) ;
662+
663+ } ) ;
664+ } ) ;
665+
666+
667+
586668 } }
587669 ) ;
588670} ) ;
0 commit comments