Created
July 27, 2011 06:46
-
-
Save indexzero/1108806 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var vows = require('vows'), | |
assert = require('assert'); | |
function wait(callback) { | |
setTimeout(function() { | |
callback('hello', 'world'); | |
}, 2000) | |
} | |
vows.describe('Playing with asynched functions').addBatch({ | |
'wait()': { | |
topic: function() { | |
wait(this.callback.bind(this, null)); | |
}, | |
'should return "hello" and "world"': function(_, arg1, arg2) { | |
assert.strictEqual(arg1, 'hello'); | |
assert.strictEqual(arg2, 'world'); // why is arg2 undefined? | |
} | |
} | |
}).export(module); |
This file contains hidden or 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
♢ Playing with asynched functions | |
wait() | |
✓ should return "hello" and "world" | |
✓ OK » 1 honored (2.004s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment