middleware.basic.js
This file
Path
test/middleware.basic.js
41 lines · 1.0 KiB · JavaScript
Last changed by
tests: assert calls order in middleware basic tests김정환before adoption8a97346
History of this fileTake it
The walk stopped after 200 commits: lines older than d32ed68 point at it.
4.15.1Douglas Christopher Wilsonbefore adoptiond32ed68
line 1why, one step back1tests: assert calls order in middleware basic tests김정환before adoption8a97346
line 2why, one step back2var assert = require('assert')4.15.1Douglas Christopher Wilsonbefore adoptiond32ed68
lines 3–31why, one step back3var express = require('../');4var request = require('supertest');56describe('middleware', function(){7 describe('.next()', function(){8 it('should behave like connect', function(done){9 var app = express()10 , calls = [];1112 app.use(function(req, res, next){13 calls.push('one');14 next();15 });1617 app.use(function(req, res, next){18 calls.push('two');19 next();20 });2122 app.use(function(req, res){23 var buf = '';24 res.setHeader('Content-Type', 'application/json');25 req.setEncoding('utf8');26 req.on('data', function(chunk){ buf += chunk });27 req.on('end', function(){28 res.end(buf);29 });30 });31tests: run mocha with --no-exit to detect hangsDouglas Christopher Wilsonbefore adoptionde129c2
line 32why, one step back32 request(app)4.15.1Douglas Christopher Wilsonbefore adoptiond32ed68
lines 33–36why, one step back33 .get('/')34 .set('Content-Type', 'application/json')35 .send('{"foo":"bar"}')36 .expect('Content-Type', 'application/json')tests: assert calls order in middleware basic tests김정환before adoption8a97346
line 37why, one step back37 .expect(function () { assert.deepEqual(calls, ['one', 'two']) })4.15.1Douglas Christopher Wilsonbefore adoptiond32ed68
lines 38–41why, one step back38 .expect(200, '{"foo":"bar"}', done)39 })40 })41})