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
Showing
2 changed files
with
56 additions
and
43 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 |
---|---|---|
@@ -1,43 +1,43 @@ | ||
|
||
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(); | ||
}) | ||
}) | ||
}) | ||
}) | ||
// | ||
// 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(); | ||
// }) | ||
// }) | ||
// }) | ||
// }) |
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,13 @@ | ||
|
||
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); | ||
}) | ||
}) | ||
}) |