Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chakrit Wichian
committed
Jul 15, 2012
1 parent
a997b00
commit 7782da9
Showing
2 changed files
with
39 additions
and
2 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
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 |
---|---|---|
@@ -1,4 +1,41 @@ | ||
|
||
// test.js - Test index.js | ||
var index = require('./index'); | ||
// NOTE: must be run usingmocha (http://visionmedia.github.com/mocha/) | ||
(function() { | ||
|
||
// check for mocha context | ||
if (!describe || !it) { | ||
console.log("This file is intended to be run using mocha:"); | ||
console.log(" http://visionmedia.github.com/mocha/"); | ||
return; | ||
} | ||
|
||
|
||
var index = require('./index') | ||
, assert = require('assert'); | ||
|
||
describe('index.js', function() { | ||
describe('exports', function() { | ||
it('a middleware function', function() { | ||
assert(typeof index === 'function'); | ||
assert(index.length === 3); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('middleware function', function() { | ||
it('should generates an id', function(done) { | ||
var obj = { }; | ||
|
||
index(obj, null, function(e) { | ||
if (!!e) return done(e); | ||
|
||
assert('id' in obj); | ||
assert(typeof obj['id'] === 'string'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
})(); | ||
|