2 var assert = require('assert')
3 var express = require('../');
4 var request = require('supertest');
6 describe('middleware', function(){
7 describe('.next()', function(){
8 it('should behave like connect', function(done){
12 app.use(function(req, res, next){
17 app.use(function(req, res, next){
22 app.use(function(req, res){
24 res.setHeader('Content-Type', 'application/json');
25 req.setEncoding('utf8');
26 req.on('data', function(chunk){ buf += chunk });
27 req.on('end', function(){
34 .set('Content-Type', 'application/json')
35 .send('{"foo":"bar"}')
36 .expect('Content-Type', 'application/json')
37 .expect(function () { assert.deepEqual(calls, ['one', 'two']) })
38 .expect(200, '{"foo":"bar"}', done)