-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(test) Added tests for error pass thru
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
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
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) |