Skip to content
Myr

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 file

Take it

The walk stopped after 200 commits: lines older than 6bc7574 point at it.

docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574

line 1why, one step back
1

Merge tag '3.19.1'Douglas Christopher Wilsonbefore adoption82689d6

lines 2–4why, one step back
2var assert = require('assert');
3var express = require('..');4var request = require('supertest');

docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574

lines 5–7why, one step back
5
6describe('res.vary()', function(){7 describe('with no arguments', function(){

Merge tag '3.19.1'Douglas Christopher Wilsonbefore adoption82689d6

lines 8–19why, one step back
8 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 back
20 })
21 })2223 describe('with an empty array', function(){

Merge tag '3.19.1'Douglas Christopher Wilsonbefore adoption82689d6

lines 24–35why, one step back
24 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 back
36 })
37 })3839 describe('with an array', function(){

Merge tag '3.19.1'Douglas Christopher Wilsonbefore adoption82689d6

lines 40–51why, one step back
40 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 back
52 })
53 })5455 describe('with a string', function(){

Merge tag '3.19.1'Douglas Christopher Wilsonbefore adoption82689d6

lines 56–67why, one step back
56 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 back
68 })
69 })7071 describe('when the value is present', function(){

Merge tag '3.19.1'Douglas Christopher Wilsonbefore adoption82689d6

lines 72–87why, one step back
72 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 back
88 })
89 })90})

Merge tag '3.19.1'Douglas Christopher Wilsonbefore adoption82689d6

lines 91–96why, one step back
91
92function shouldNotHaveHeader(header) {93 return function (res) {94 assert.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header);95 };96}