Skip to content
Myr

res.set.js

This file

Path

test/res.set.js

73 lines · 1.7 KiB · JavaScript

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than 82731da point at it.

Merge pull request #1503 from shesek/settings-inheritanceTJ Holowaychukbefore adoption82731da

lines 1–73why, one step back
1
2var express = require('../')3 , request = require('./support/http')4 , res = express.response;56describe('res', function(){7 describe('.set(field, value)', function(){8 it('should set the response header field', function(done){9 var app = express();1011 app.use(function(req, res){12 res.set('Content-Type', 'text/x-foo').end();13 });1415 request(app)16 .get('/')17 .expect('Content-Type', 'text/x-foo')18 .end(done);19 })2021 it('should coerce to a string', function(){22 res.headers = {};23 res.set('ETag', 123);24 res.get('ETag').should.equal('123');25 })26 })2728 describe('.set(field, values)', function(){29 it('should set multiple response header fields', function(done){30 var app = express();3132 app.use(function(req, res){33 res.set('Set-Cookie', ["type=ninja", "language=javascript"]);34 res.send(res.get('Set-Cookie'));35 });3637 request(app)38 .get('/')39 .expect('["type=ninja","language=javascript"]', done);40 })4142 it('should coerce to an array of strings', function(){43 res.headers = {};44 res.set('ETag', [123, 456]);45 JSON.stringify(res.get('ETag')).should.equal('["123","456"]');46 })47 })48 49 describe('.set(object)', function(){50 it('should set multiple fields', function(done){51 var app = express();5253 app.use(function(req, res){54 res.set({55 'X-Foo': 'bar',56 'X-Bar': 'baz'57 }).end();58 });5960 request(app)61 .get('/')62 .expect('X-Foo', 'bar')63 .expect('X-Bar', 'baz')64 .end(done);65 })6667 it('should coerce to a string', function(){68 res.headers = {};69 res.set({ ETag: 123 });70 res.get('ETag').should.equal('123');71 })72 })73})