middleware.basic.js
This file
Path
test/middleware.basic.js
42 lines · 1.0 KiB · JavaScript
Last changed by
tests: use strict modeDouglas Christopher Wilsonbefore adoptiona659137
History of this fileTake it
The walk stopped after 200 commits: lines older than 5c4f3e7 point at it.
tests: use strict modeDouglas Christopher Wilsonbefore adoptiona659137
line 1why, one step back1'use strict'build: supertest@6.0.1Douglas Christopher Wilsonbefore adoption5c4f3e7
lines 2–42why, one step back23var assert = require('assert')4var express = require('../');5var request = require('supertest');67describe('middleware', function(){8 describe('.next()', function(){9 it('should behave like connect', function(done){10 var app = express()11 , calls = [];1213 app.use(function(req, res, next){14 calls.push('one');15 next();16 });1718 app.use(function(req, res, next){19 calls.push('two');20 next();21 });2223 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 });3233 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)40 })41 })42})