Skip to content
Myr

middleware.basic.js

This file

Path

test/middleware.basic.js

44 lines · 1.1 KiB · JavaScript

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than ad3ca25 point at it.

deps: qs@1.2.2Douglas Christopher Wilsonbefore adoptionad3ca25

lines 1–44why, one step back
1
2var express = require('../');3var request = require('supertest');45describe('middleware', function(){6 describe('.next()', function(){7 it('should behave like connect', function(done){8 var app = express()9 , calls = [];1011 app.use(function(req, res, next){12 calls.push('one');13 next();14 });1516 app.use(function(req, res, next){17 calls.push('two');18 next();19 });2021 app.use(function(req, res){22 var buf = '';23 res.setHeader('Content-Type', 'application/json');24 req.setEncoding('utf8');25 req.on('data', function(chunk){ buf += chunk });26 req.on('end', function(){27 res.end(buf);28 });29 });3031 request(app.listen())32 .get('/')33 .set('Content-Type', 'application/json')34 .send('{"foo":"bar"}')35 .end(function(err, res){36 if (err) return done(err);37 res.headers.should.have.property('content-type', 'application/json');38 res.statusCode.should.equal(200);39 res.text.should.equal('{"foo":"bar"}');40 done();41 })42 })43 })44})