tests: add more tests
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent c21226a · Browse files · 3 files·+60 added−1 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+60 added−1 removed
- tests:+60 added−1 removed
Provenance
- Commit
8751d7e- Tree
69c29f5- Author
Douglas Christopher Wilson <doug@somethingdoug.com>- Committer
Douglas Christopher Wilson <doug@somethingdoug.com>- Parent
c21226a
3 files changed+60 added−1 removed
modified:test/app.router.js+24 added
562 unmodified lines563 })564 })565 })566 567+ describe('when next("route") is called', function(){568+ it('should jump to next route', function(done){569+ var app = express()570+571+ function fn(req, res, next){572+ res.set('X-Hit', '1')573+ next('route')574+ }575+576+ app.get('/foo', fn, function(req, res, next){577+ res.end('failure')578+ });579+580+ app.get('/foo', function(req, res){581+ res.end('success')582+ })583+584+ request(app)585+ .get('/foo')586+ .expect('X-Hit', '1')587+ .expect(200, 'success', done)588+ })589+ })590+591 describe('when next(err) is called', function(){592 it('should break out of app.router', function(done){593 var app = express()594 , calls = [];55 unmodified linesmodified:test/config.js+9 added
25 unmodified lines262728293031323334353637383940414275 unmodified lines25 unmodified lines app.set('etag', fn) app.get('etag fn').should.equal(fn) }) })
describe('"trust proxy"', function(){ it('should set "trust proxy fn"', function(){ var app = express() var fn = function(){} app.set('trust proxy', fn) app.get('trust proxy fn').should.equal(fn) }) }) })
describe('.get()', function(){ it('should return undefined when unset', function(){75 unmodified linesmodified:test/utils.js+27 added-1 removed
1 2 var utils = require('../lib/utils')3 , assert = require('assert');4 5+describe('utils.deprecate(fn, msg)', function(){6+ var env7+ before(function(){8+ env = process.env.NODE_ENV9+ })10+ after(function(){11+ process.env.NODE_ENV = env12+ })13+14+ it('should pass-through fn in test environment', function(){15+ var fn = function(){}16+ process.env.NODE_ENV = 'test'17+ utils.deprecate(fn).should.equal(fn)18+ })19+20+ it('should return new fn in other environment', function(){21+ var fn = function(){}22+ process.env.NODE_ENV = ''23+ utils.deprecate(fn).should.not.equal(fn)24+ })25+})26+27 describe('utils.etag(body, encoding)', function(){28 it('should support strings', function(){29 utils.etag('express!')30 .should.eql('"zZdv4imtWD49AHEviejT6A=="')44 unmodified lines75 assert(utils.isAbsolute('c:\\'));76 assert(!utils.isAbsolute(':\\'));77 })78 57- it('should unices', function(){79+ it('should support windows unc', function(){80+ assert(utils.isAbsolute('\\\\foo\\bar'))81+ })82+83+ it('should support unices', function(){84 assert(utils.isAbsolute('/foo/bar'));85 assert(!utils.isAbsolute('foo/bar'));86 })87 })192 unmodified lines