tests: fix tests that did not bubble errors
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 bd4fdfe · Browse files · 4 files·+37 added−34 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+37 added−34 removed
- tests:+37 added−34 removed
Provenance
- Commit
141914e- Tree
106560f- Author
Douglas Christopher Wilson <doug@somethingdoug.com>- Committer
Douglas Christopher Wilson <doug@somethingdoug.com>- Parent
bd4fdfe
4 files changed+37 added−34 removed
modified:test/app.all.js+7 added-5 removed
12345678910111213141514151616171819201819212223242512 unmodified lines
var after = require('after')var express = require('../') , request = require('supertest');
describe('app.all()', function(){ it('should add a router per method', function(done){ var app = express(); var cb = after(2, done)
app.all('/tobi', function(req, res){ res.end(req.method); });
request(app) .put('/tobi') .expect('PUT', function(){ request(app) .put('/tobi') .expect(200, 'PUT', cb)
request(app) .get('/tobi') .expect('GET', done); }); .expect(200, 'GET', cb) })
it('should run the callback for a method just once', function(done){ var app = express()12 unmodified linesmodified:test/app.head.js+6 added-9 removed
44 unmodified lines45464748494950525351525354555756575859606263646566616263646544 unmodified lines
describe('app.head()', function(){ it('should override', function(done){ var app = express() , called;
app.head('/tobi', function(req, res){ called = true; res.end(''); res.header('x-method', 'head') res.end() });
app.get('/tobi', function(req, res){ assert(0, 'should not call GET'); res.header('x-method', 'get') res.send('tobi'); });
request(app) .head('/tobi') .expect(200, function(){ assert(called); done(); }); .head('/tobi') .expect('x-method', 'head') .expect(200, done) })})modified:test/app.router.js+18 added-15 removed
634 unmodified lines635 })636 637 it('should work cross-segment', function(done){638 var app = express();639+ var cb = after(2, done)640 641 app.get('/api*', function(req, res){642 res.send(req.params[0]);643 });644 645 request(app)645- .get('/api')646- .expect('', function(){647- request(app)646+ .get('/api')647+ .expect(200, '', cb)648+649+ request(app)650 .get('/api/hey')649- .expect('/hey', done);650- });651+ .expect(200, '/hey', cb)652 })653 654 it('should allow naming', function(done){655 var app = express();207 unmodified lines863 864 describe('.:name', function(){865 it('should denote a format', function(done){866 var app = express();867+ var cb = after(2, done)868 869 app.get('/:name.:format', function(req, res){870 res.end(req.params.name + ' as ' + req.params.format);871 });872 873 request(app)872- .get('/foo.json')873- .expect('foo as json', function(){874- request(app)874+ .get('/foo.json')875+ .expect(200, 'foo as json', cb)876+877+ request(app)878 .get('/foo')876- .expect(404, done);877- });879+ .expect(404, cb)880 })881 })882 883 describe('.:name?', function(){884 it('should denote an optional format', function(done){885 var app = express();886+ var cb = after(2, done)887 888 app.get('/:name.:format?', function(req, res){889 res.end(req.params.name + ' as ' + (req.params.format || 'html'));890 });891 892 request(app)890- .get('/foo')891- .expect('foo as html', function(){892- request(app)893+ .get('/foo')894+ .expect(200, 'foo as html', cb)895+896+ request(app)897 .get('/foo.json')894- .expect('foo as json', done);895- });898+ .expect(200, 'foo as json', done)899 })900 })901 902 describe('when next() is called', function(){208 unmodified linesmodified:test/app.use.js+6 added-5 removed
35 unmodified lines36 it('should support mount-points', function(done){37 var blog = express()38 , forum = express()39 , app = express();40+ var cb = after(2, done)41 42 blog.get('/', function(req, res){43 res.end('blog');44 });5 unmodified lines50 app.use('/blog', blog);51 app.use('/forum', forum);52 53 request(app)53- .get('/blog')54- .expect('blog', function(){55- request(app)54+ .get('/blog')55+ .expect(200, 'blog', cb)56+57+ request(app)58 .get('/forum')57- .expect('forum', done);58- });59+ .expect(200, 'forum', done)60 })61 62 it('should set the child\'s .parent', function(){63 var blog = express()478 unmodified lines