/
githubmirror
/
express
Обзор
Документация
Войти
/
githubmirror
/
express
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
4.17.2
test/middleware.basic.js
40 строк
1 KB
김정환
tests: assert calls order in middleware basic tests
17 апр 2019, 17:41
17 апр 2019, 17:41
8a97346
Код
Авторство
О чём код?
var assert = require('assert') var express = require('../'); var request = require('supertest'); describe('middleware', function(){ describe('.next()', function(){ it('should behave like connect', function(done){ var app = express() , calls = []; app.use(function(req, res, next){ calls.push('one'); next(); }); app.use(function(req, res, next){ calls.push('two'); next(); }); app.use(function(req, res){ var buf = ''; res.setHeader('Content-Type', 'application/json'); req.setEncoding('utf8'); req.on('data', function(chunk){ buf += chunk }); req.on('end', function(){ res.end(buf); }); }); request(app) .get('/') .set('Content-Type', 'application/json') .send('{"foo":"bar"}') .expect('Content-Type', 'application/json') .expect(function () { assert.deepEqual(calls, ['one', 'two']) }) .expect(200, '{"foo":"bar"}', done) }) }) })