Skip to content

Commit

Permalink
(test) Added tests for error pass thru
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Aug 21, 2011
1 parent 0108f1f commit 954386c
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions test/vows-error-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
var path = require('path'),
events = require('events'),
assert = require('assert'),
fs = require('fs'),
vows = require('../lib/vows');

function doSomethingAsync(callback) {
var err = null;
var testValue = 'a';

process.nextTick(function() {
callback(err, testValue);
});
}

function doSomethingAsyncWithError(callback) {
var err = true;
var testValue = 'a';

process.nextTick(function() {
callback(err, testValue);
});
}


vows.describe('vows/error').addBatch({
'Generate success response to async function': {
topic: function() {
doSomethingAsync(this.callback)
},
'Validate success': function(err, testValue) {
assert.ok(!err);
},
'Validate testValue': function(err, testValue) {
assert.equal(testValue, 'a');
}
},

'Generate error response to async function': {
topic: function() {
doSomethingAsyncWithError(this.callback)
},
'Validate error': function(err, testValue) {
assert.ok(err);
},
'Validate testValue': function(err, testValue) {
// This assertion fails. It shouldn't.
assert.equal(testValue, 'a');
}
}
}).export(module)

0 comments on commit 954386c

Please sign in to comment.