fix(deps)!: mime-types@^3.0.0 (#5882)
[express.git] / test / middleware.basic.js
blob19f00d9a2961763dd06ea237feda1150b0c242fb
1 'use strict'
3 var assert = require('assert')
4 var express = require('../');
5 var request = require('supertest');
7 describe('middleware', function(){
8 describe('.next()', function(){
9 it('should behave like connect', function(done){
10 var app = express()
11 , calls = [];
13 app.use(function(req, res, next){
14 calls.push('one');
15 next();
16 });
18 app.use(function(req, res, next){
19 calls.push('two');
20 next();
21 });
23 app.use(function(req, res){
24 var buf = '';
25 res.setHeader('Content-Type', 'application/json');
26 req.setEncoding('utf8');
27 req.on('data', function(chunk){ buf += chunk });
28 req.on('end', function(){
29 res.end(buf);
30 });
31 });
33 request(app)
34 .get('/')
35 .set('Content-Type', 'application/json')
36 .send('{"foo":"bar"}')
37 .expect('Content-Type', 'application/json')
38 .expect(function () { assert.deepEqual(calls, ['one', 'two']) })
39 .expect(200, '{"foo":"bar"}', done)