Skip to content

Instantly share code, notes, and snippets.

@mhct
Created April 19, 2012 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhct/2421721 to your computer and use it in GitHub Desktop.
Save mhct/2421721 to your computer and use it in GitHub Desktop.
That is not the way to go.... testing asynchronous code execution
it 'should offer rideOffer to 2 taxis (see the Mock above)', (done) ->
client1 = io.connect socketUrl, options
taxi1 = io.connect socketUrl, options
taxi2 = io.connect socketUrl, options
async.parallel([
(fn) ->
taxi1.emit('locationUpdate', {locationUpdate:{taxiId:1}})
fn()
,
(fn) ->
taxi2.emit('locationUpdate', {locationUpdate:{taxiId:2}})
fn()
], ->
async.parallel([
(fn) -> taxi1.on('locationUpdated', -> fn() )
,
(fn) -> taxi2.on('locationUpdated', -> fn() )
], ->
client1.emit 'rideRequest', rideRequest
async.parallel([
(fn) -> taxi1.on('rideOffer', -> fn() )
,
(fn) -> taxi2.on('rideOffer', -> fn() )
], ->
taxisReceivedOffer = true
done()
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment