res.set.js
This file
Path
test/res.set.js
74 lines · 1.7 KiB · JavaScript
Last changed by
tests: add more etag testsDouglas Christopher Wilsonbefore adoption3e35845
History of this fileTake it
The walk stopped after 200 commits: lines older than a10f695 point at it.
pin jade dev dep so tests do not breakTJ Holowaychukbefore adoptiona10f695
lines 1–2why, one step back12var express = require('../')remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3
line 3why, one step back3 , request = require('supertest')pin jade dev dep so tests do not breakTJ Holowaychukbefore adoptiona10f695
lines 4–22why, one step back4 , 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 = {};tests: add more etag testsDouglas Christopher Wilsonbefore adoption3e35845
lines 23–24why, one step back23 res.set('X-Number', 123);24 res.get('X-Number').should.equal('123');pin jade dev dep so tests do not breakTJ Holowaychukbefore adoptiona10f695
lines 25–43why, one step back25 })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 = {};tests: add more etag testsDouglas Christopher Wilsonbefore adoption3e35845
lines 44–46why, one step back44 res.set('X-Numbers', [123, 456]);45 JSON.stringify(res.get('X-Numbers'))46 .should.equal('["123","456"]');pin jade dev dep so tests do not breakTJ Holowaychukbefore adoptiona10f695
lines 47–48why, one step back47 })48 })remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3
line 49why, one step back49pin jade dev dep so tests do not breakTJ Holowaychukbefore adoptiona10f695
lines 50–69why, one step back50 describe('.set(object)', function(){51 it('should set multiple fields', function(done){52 var app = express();5354 app.use(function(req, res){55 res.set({56 'X-Foo': 'bar',57 'X-Bar': 'baz'58 }).end();59 });6061 request(app)62 .get('/')63 .expect('X-Foo', 'bar')64 .expect('X-Bar', 'baz')65 .end(done);66 })6768 it('should coerce to a string', function(){69 res.headers = {};tests: add more etag testsDouglas Christopher Wilsonbefore adoption3e35845
lines 70–71why, one step back70 res.set({ 'X-Number': 123 });71 res.get('X-Number').should.equal('123');pin jade dev dep so tests do not breakTJ Holowaychukbefore adoptiona10f695
lines 72–74why, one step back72 })73 })74})