/
githubmirror
/
express
Обзор
Документация
Войти
/
githubmirror
/
express
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/res.locals.js
40 строк
733 B
Douglas Christopher Wilson
tests: use strict mode
09 фев 2022, 09:07
09 фев 2022, 09:07
a659137
Код
Авторство
О чём код?
'use strict' var express = require('../') , request = require('supertest'); describe('res', function(){ describe('.locals', function(){ it('should be empty by default', function(done){ var app = express(); app.use(function(req, res){ res.json(res.locals) }); request(app) .get('/') .expect(200, {}, done) }) }) it('should work when mounted', function(done){ var app = express(); var blog = express(); app.use(blog); blog.use(function(req, res, next){ res.locals.foo = 'bar'; next(); }); app.use(function(req, res){ res.json(res.locals) }); request(app) .get('/') .expect(200, { foo: 'bar' }, done) }) })