Created
August 31, 2011 01:41
-
-
Save anonymous/1182624 to your computer and use it in GitHub Desktop.
Vows asynchronous test confused my poor brain
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
var vows = require('vows'); | |
var assert = require('assert'); | |
var vowSuite = vows.describe('Vows'); | |
vowSuite.addBatch({ | |
'Call callback with error and one extra parameter':{ | |
topic: function(){ | |
var callback = this.callback; | |
setTimeout(function(){ | |
callback(null, [4,5,6]); | |
}, 100); | |
}, | |
'I DO NOT put error in my parameter list': function(array){ | |
console.log('Array 1', array); | |
assert.equal(array.length, 3); | |
}, | |
'I DO put error in my parameter list': function(error, array){ | |
console.log('Error 2', error); | |
console.log('Array 2', array); | |
assert.equal(array.length, 3); | |
} | |
}, | |
'Call callback with error and two extra parameters':{ | |
topic: function(){ | |
var callback = this.callback; | |
setTimeout(function(){ | |
callback(null, [4,5,6], 42); | |
}, 100); | |
}, | |
'I DO NOT put error in my parameter list': function(array, number){ | |
console.log('Array 3', array); | |
console.log('Number 3', number); | |
assert.equal(array.length, 3); | |
assert.equal(number, 42); | |
}, | |
'I DO put error in my parameter list': function(error, array, number){ | |
console.log('Error 4', error); | |
console.log('Array 4', array); | |
console.log('Number 4', number); | |
assert.equal(array.length, 3); | |
assert.equal(number, 42); | |
} | |
} | |
}); | |
vowSuite.export(module); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment