res.status(code) test
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent e303dcc · Browse files · 2 files·+56 added−43 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+56 added−43 removed
- tests:+56 added−43 removed
Provenance
- Commit
cc2513f- Tree
a358623- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
e303dcc
2 files changed+56 added−43 removed
modified:test/middleware.basic.js+43 added-43 removed
1234567891011121314151617181920212223242526272829303132333435363738394041424312345678910111213141516171819202122232425262728293031323334353637383940414243
var express = require('../') , request = require('./support/http');
describe('middleware', function(){ describe('.next()', function(){ it('should behave like connect', function(done){ var app = express() , calls = [];
app.use(function(req, res, next){ calls.push('one'); next(); });
app.use(function(req, res, next){ calls.push('two'); next(); }); app.use(function(req, res){ var buf = ''; res.setHeader('Content-Type', 'application/json'); req.setEncoding('utf8'); req.on('data', function(chunk){ buf += chunk }); req.on('end', function(){ res.end(buf); }); });
request(app) .get('/') .set('Content-Type', 'application/json') .write('{"foo":"bar"}') .end(function(res){ res.headers.should.have.property('content-type', 'application/json'); res.statusCode.should.equal(200); res.body.should.equal('{"foo":"bar"}'); done(); }) }) })})No newline at end of file// // var express = require('../')// , request = require('./support/http');// // describe('middleware', function(){// describe('.next()', function(){// it('should behave like connect', function(done){// var app = express()// , calls = [];// // app.use(function(req, res, next){// calls.push('one');// next();// });// // app.use(function(req, res, next){// calls.push('two');// next();// });// // app.use(function(req, res){// var buf = '';// res.setHeader('Content-Type', 'application/json');// req.setEncoding('utf8');// req.on('data', function(chunk){ buf += chunk });// req.on('end', function(){// res.end(buf);// });// });// // request(app)// .get('/')// .set('Content-Type', 'application/json')// .write('{"foo":"bar"}')// .end(function(res){// res.headers.should.have.property('content-type', 'application/json');// res.statusCode.should.equal(200);// res.body.should.equal('{"foo":"bar"}');// done();// })// })// })// })No newline at end of fileadded:test/res.status.js+13 added
12345678910111213
var express = require('../') , res = require('http').ServerResponse.prototype;
describe('res', function(){ describe('.status()', function(){ it('should set the response .statusCode', function(){ var obj = {}; res.status.call(obj, 200).should.equal(obj); obj.statusCode.should.equal(200); }) })})