@@ -53,16 +53,26 @@ describe('swarm nodes', function() {
5353 var scope = nock ( 'https://api.foursquare.com:443' )
5454 . filteringPath ( / a f t e r T i m e s t a m p = [ ^ & ] * / g, 'afterTimestamp=foo' )
5555 . get ( '/v2/users/self/checkins?oauth_token=abcd1234&sort=newestfirst&m=swarm&v=20141016' )
56- . reply ( 200 , { "meta" :{ "code" :200 } , "response" :{ "checkins" :{ "count" :1 , "items" :[ { "id" :"b695edf5ewc2" , "createdAt" :1412861751 , "type" :"checkin" , "timeZoneOffset" :60 , "venue" :{ "id" :"49a8b774" , "name" :"Bobs House" } } ] } } } ) ;
56+ . reply ( 200 , { "meta" :{ "code" :200 } , "response" :{ "checkins" :{ "count" :1 ,
57+ "items" :[ { "id" :"b695edf5ewc2" , "createdAt" :1412861751 , "type" :"checkin" , "timeZoneOffset" :60 ,
58+ "venue" :{ "id" :"49a8b774" , "name" :"Bobs House" ,
59+ "location" :{ "lat" :"1234" , "lng" :"-1234" , "name" :"Bobs House" , "city" :"Winchester" , "country" :"England" } }
60+ } ] } } } ) ;
5761
5862 var n1 = helper . getNode ( "n1" ) ;
5963 var n2 = helper . getNode ( "n2" ) ;
6064 var n3 = helper . getNode ( "n3" ) ;
6165 n2 . should . have . property ( 'id' , 'n2' ) ;
6266 n1 . send ( { payload :"foo" } ) ;
6367 n3 . on ( 'input' , function ( msg ) {
64- var venue = msg . payload . venue ;
65- venue . should . have . property ( 'name' , "Bobs House" ) ;
68+ msg . payload . venue . should . have . property ( 'name' , "Bobs House" ) ;
69+ msg . should . have . property ( 'name' , "Bobs House" ) ;
70+ msg . should . have . property ( 'location' ) ;
71+ msg . location . should . have . property ( 'lat' , "1234" ) ;
72+ msg . location . should . have . property ( 'lon' , "-1234" ) ;
73+ msg . location . should . have . property ( 'city' , "Winchester" ) ;
74+ msg . location . should . have . property ( 'country' , "England" ) ;
75+ msg . location . should . have . property ( 'name' , "Bobs House" ) ;
6676 done ( ) ;
6777 } ) ;
6878 } ) ;
@@ -102,6 +112,39 @@ describe('swarm nodes', function() {
102112 n1 . send ( { payload :"foo" } ) ;
103113 } ) ;
104114 } ) ;
115+
116+ it ( 'passes on null msg.payload if no results from query' , function ( done ) {
117+ helper . load ( [ foursquareNode , swarmNode ] ,
118+ [ { id :"n1" , type :"helper" , wires :[ [ "n2" ] ] } ,
119+ { id :"n4" , type :"foursquare-credentials" } ,
120+ { id :"n2" , type :"swarm" , foursquare : "n4" , wires :[ [ "n3" ] ] } ,
121+ { id :"n3" , type :"helper" } ] ,
122+ {
123+ "n4" : {
124+ displayname : "John" ,
125+ clientid : "987654321" ,
126+ clientsecret :"123456789" ,
127+ accesstoken :"abcd1234" ,
128+ } ,
129+ } ,
130+ function ( ) {
131+ var scope = nock ( 'https://api.foursquare.com:443' )
132+ . filteringPath ( / a f t e r T i m e s t a m p = [ ^ & ] * / g, 'afterTimestamp=foo' )
133+ . get ( '/v2/users/self/checkins?oauth_token=abcd1234&sort=newestfirst&m=swarm&v=20141016' )
134+ . reply ( 200 , { "meta" :{ "code" :200 } , "response" :{ "checkins" :{ "count" :1 ,
135+ "items" :[ ] } } } ) ;
136+
137+ var n1 = helper . getNode ( "n1" ) ;
138+ var n2 = helper . getNode ( "n2" ) ;
139+ var n3 = helper . getNode ( "n3" ) ;
140+ n2 . should . have . property ( 'id' , 'n2' ) ;
141+ n1 . send ( { payload :"foo" } ) ;
142+ n3 . on ( 'input' , function ( msg ) {
143+ msg . should . have . property ( 'payload' , null ) ;
144+ done ( ) ;
145+ } ) ;
146+ } ) ;
147+ } ) ;
105148
106149 } }
107150 ) ;
@@ -129,16 +172,23 @@ describe('swarm nodes', function() {
129172 var scope = nock ( 'https://api.foursquare.com:443' )
130173 . filteringPath ( / a f t e r T i m e s t a m p = [ ^ & ] * / g, 'afterTimestamp=foo' )
131174 . get ( '/v2/users/self/checkins?oauth_token=abcd1234&sort=newestfirst&m=swarm&v=20141016&afterTimestamp=foo' )
132- . reply ( 200 , { "meta" :{ "code" :200 } , "response" :{ "checkins" :{ "count" :1 , "items" :[ { "id" :"b695edf5ewc2" , "createdAt" :1412861751 , "type" :"checkin" , "timeZoneOffset" :60 , "venue" :{ "id" :"49a8b774" , "name" :"Bobs House" } } ] } } } ) ;
175+ . reply ( 200 , { "meta" :{ "code" :200 } , "response" :{ "checkins" :{ "count" :1 ,
176+ "items" :[ { "id" :"b695edf5ewc2" , "createdAt" :1412861751 , "type" :"checkin" , "timeZoneOffset" :60 ,
177+ "location" :{ "lat" :"1234" , "lng" :"-1234" , "name" :"Bobs House" } } ] } } } ) ;
133178
134179 var n1 = helper . getNode ( "n1" ) ;
135180 var n2 = helper . getNode ( "n2" ) ;
136181 var n3 = helper . getNode ( "n3" ) ;
137182 n2 . should . have . property ( 'id' , 'n2' ) ;
138183 n2 . emit ( "input" , { } ) ;
139184 n3 . on ( 'input' , function ( msg ) {
140- var venue = msg . payload . venue ;
141- venue . should . have . property ( 'name' , "Bobs House" ) ;
185+ msg . should . have . property ( 'name' , "Bobs House" ) ;
186+ msg . should . have . property ( 'location' ) ;
187+ msg . location . should . have . property ( 'lat' , "1234" ) ;
188+ msg . location . should . have . property ( 'lon' , "-1234" ) ;
189+ msg . location . should . not . have . property ( 'city' ) ;
190+ msg . location . should . not . have . property ( 'country' ) ;
191+ msg . location . should . have . property ( 'name' , "Bobs House" ) ;
142192 done ( ) ;
143193 } ) ;
144194 } ) ;
0 commit comments