Skip to content

Commit eb1c67f

Browse files
committed
Add x-apicache-revalidate spec
1 parent b0927d5 commit eb1c67f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/apicache_test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,31 @@ describe('.middleware {MIDDLEWARE}', function() {
549549
})
550550
})
551551

552+
it('revalidates cache when using header "x-apicache-revalidate"', function(done) {
553+
var app = mockAPI.create('10 seconds')
554+
555+
request(app)
556+
.get('/api/movies')
557+
.expect(200, movies)
558+
.expect('Cache-Control', 'max-age=10')
559+
.then(assertNumRequestsProcessed(app, 1))
560+
.then(function() {
561+
setTimeout(function() {
562+
return request(app)
563+
.get('/api/movies')
564+
.set('x-apicache-revalidate', true)
565+
.expect(200, movies)
566+
.expect('Cache-Control', 'max-age=10')
567+
.then(function(res) {
568+
expect(res.headers['apicache-store']).to.be.undefined
569+
expect(res.headers['apicache-version']).to.be.undefined
570+
expect(app.requestsProcessed).to.equal(2)
571+
done()
572+
})
573+
}, 500)
574+
})
575+
})
576+
552577
it('does not cache header in headerBlacklist', function() {
553578
var app = mockAPI.create('10 seconds', { headerBlacklist: ['x-blacklisted'] })
554579

0 commit comments

Comments
 (0)