Skip to content

Instantly share code, notes, and snippets.

@indexzero
Created July 27, 2011 06:46
Show Gist options
  • Save indexzero/1108806 to your computer and use it in GitHub Desktop.
Save indexzero/1108806 to your computer and use it in GitHub Desktop.
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);
♢ 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