Skip to content
Myr

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 file

Take it

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

tests: use strict modeDouglas Christopher Wilsonbefore adoptiona659137

line 1why, one step back
1'use strict'

tests: remove duplicate block in router testDouglas Christopher Wilsonbefore adoption972ada9

line 2why, one step back
2

tests: assert calls order in middleware basic tests김정환before adoption8a97346

line 3why, one step back
3var assert = require('assert')

tests: remove duplicate block in router testDouglas Christopher Wilsonbefore adoption972ada9

lines 4–37why, one step back
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')

tests: assert calls order in middleware basic tests김정환before adoption8a97346

line 38why, one step back
38 .expect(function () { assert.deepEqual(calls, ['one', 'two']) })

tests: remove duplicate block in router testDouglas Christopher Wilsonbefore adoption972ada9

lines 39–42why, one step back
39 .expect(200, '{"foo":"bar"}', done)
40 })41 })42})