3 var express = require('..');
4 var request = require('supertest');
5 var utils = require('./support/utils');
7 describe('res.vary()', function(){
8 describe('with no arguments', function(){
9 it('should throw error', function (done) {
12 app.use(function (req, res) {
19 .expect(500, /field.*required/, done)
23 describe('with an empty array', function(){
24 it('should not set Vary', function (done) {
27 app.use(function (req, res) {
34 .expect(utils.shouldNotHaveHeader('Vary'))
39 describe('with an array', function(){
40 it('should set the values', function (done) {
43 app.use(function (req, res) {
44 res.vary(['Accept', 'Accept-Language', 'Accept-Encoding']);
50 .expect('Vary', 'Accept, Accept-Language, Accept-Encoding')
55 describe('with a string', function(){
56 it('should set the value', function (done) {
59 app.use(function (req, res) {
66 .expect('Vary', 'Accept')
71 describe('when the value is present', function(){
72 it('should not add it again', function (done) {
75 app.use(function (req, res) {
77 res.vary('Accept-Encoding');
78 res.vary('Accept-Encoding');
79 res.vary('Accept-Encoding');
86 .expect('Vary', 'Accept, Accept-Encoding')