Skip to content
Myr

res.cache.js

This file

Path

test/res.cache.js

40 lines · 937 bytes · JavaScript

Last changed by

refactoringTj Holowaychukbefore adoptionf961022

History of this file

Take it

Added res.cache(str)Tj Holowaychukbefore adoptioncaec590

lines 1–5why, one step back
1
2var express = require('../')3 , request = require('./support/http');45describe('res', function(){

Added res.cache() methodTj Holowaychukbefore adoptione21a79d

line 6why, one step back
6 describe('.cache(type)', function(){

Added res.cache(str)Tj Holowaychukbefore adoptioncaec590

lines 7–10why, one step back
7 it('should set Cache-Control', function(done){
8 var app = express();910 app.use(function(req, res){

Added res.cache() methodTj Holowaychukbefore adoptione21a79d

line 11why, one step back
11 res.cache('public').end('whoop');

Added res.cache(str)Tj Holowaychukbefore adoptioncaec590

lines 12–16why, one step back
12 });
1314 request(app)15 .get('/')16 .end(function(res){

Added res.cache() methodTj Holowaychukbefore adoptione21a79d

line 17why, one step back
17 res.headers['cache-control'].should.equal('public');

Added res.cache(str)Tj Holowaychukbefore adoptioncaec590

lines 18–19why, one step back
18 res.body.should.equal('whoop');
19 done();

Added res.cache() methodTj Holowaychukbefore adoptione21a79d

lines 20–38why, one step back
20 })
21 })22 23 describe('maxAge option', function(){24 it('should accept milliseconds', function(done){25 var app = express();2627 app.use(function(req, res){28 res.cache('private', { maxAge: 60 * 1000 }).end();29 });3031 request(app)32 .get('/')33 .end(function(res){34 res.headers['cache-control'].should.equal('private, max-age=60');35 done();36 })37 })38 })

Added res.cache(str)Tj Holowaychukbefore adoptioncaec590

lines 39–40why, one step back
39 })
40})