Created
April 19, 2012 15:28
-
-
Save mhct/2421721 to your computer and use it in GitHub Desktop.
That is not the way to go.... testing asynchronous code execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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