res.vary.js
This file
Path
test/res.vary.js
96 lines · 2.1 KiB · JavaScript
Last changed by
Merge tag '3.19.1'Douglas Christopher Wilsonbefore adoption82689d6
History of this fileTake it
The walk stopped after 200 commits: lines older than 6bc7574 point at it.
docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
line 1why, one step back1Merge tag '3.19.1'Douglas Christopher Wilsonbefore adoption82689d6
lines 2–4why, one step back2var assert = require('assert');3var express = require('..');4var request = require('supertest');docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 5–7why, one step back56describe('res.vary()', function(){7 describe('with no arguments', function(){Merge tag '3.19.1'Douglas Christopher Wilsonbefore adoption82689d6
lines 8–19why, one step back8 it('should not set Vary', function (done) {9 var app = express();1011 app.use(function (req, res) {12 res.vary();13 res.end();14 });1516 request(app)17 .get('/')18 .expect(shouldNotHaveHeader('Vary'))19 .expect(200, done);docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 20–23why, one step back20 })21 })2223 describe('with an empty array', function(){Merge tag '3.19.1'Douglas Christopher Wilsonbefore adoption82689d6
lines 24–35why, one step back24 it('should not set Vary', function (done) {25 var app = express();2627 app.use(function (req, res) {28 res.vary([]);29 res.end();30 });3132 request(app)33 .get('/')34 .expect(shouldNotHaveHeader('Vary'))35 .expect(200, done);docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 36–39why, one step back36 })37 })3839 describe('with an array', function(){Merge tag '3.19.1'Douglas Christopher Wilsonbefore adoption82689d6
lines 40–51why, one step back40 it('should set the values', function (done) {41 var app = express();4243 app.use(function (req, res) {44 res.vary(['Accept', 'Accept-Language', 'Accept-Encoding']);45 res.end();46 });4748 request(app)49 .get('/')50 .expect('Vary', 'Accept, Accept-Language, Accept-Encoding')51 .expect(200, done);docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 52–55why, one step back52 })53 })5455 describe('with a string', function(){Merge tag '3.19.1'Douglas Christopher Wilsonbefore adoption82689d6
lines 56–67why, one step back56 it('should set the value', function (done) {57 var app = express();5859 app.use(function (req, res) {60 res.vary('Accept');61 res.end();62 });6364 request(app)65 .get('/')66 .expect('Vary', 'Accept')67 .expect(200, done);docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 68–71why, one step back68 })69 })7071 describe('when the value is present', function(){Merge tag '3.19.1'Douglas Christopher Wilsonbefore adoption82689d6
lines 72–87why, one step back72 it('should not add it again', function (done) {73 var app = express();7475 app.use(function (req, res) {76 res.vary('Accept');77 res.vary('Accept-Encoding');78 res.vary('Accept-Encoding');79 res.vary('Accept-Encoding');80 res.vary('Accept');81 res.end();82 });8384 request(app)85 .get('/')86 .expect('Vary', 'Accept, Accept-Encoding')87 .expect(200, done);docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 88–90why, one step back88 })89 })90})Merge tag '3.19.1'Douglas Christopher Wilsonbefore adoption82689d6
lines 91–96why, one step back9192function shouldNotHaveHeader(header) {93 return function (res) {94 assert.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header);95 };96}