tests: add fake timers to cache-headers tests (#2590)

This commit is contained in:
Caleb Cartwright
2018-12-24 19:10:11 +00:00
committed by chris48s
parent ea0d2fb641
commit 09ff426cba
+9 -1
View File
@@ -131,6 +131,14 @@ describe('Cache header functions', function() {
})
describe('serverHasBeenUpSinceResourceCached', function() {
beforeEach(function() {
sinon.useFakeTimers({ now: 1545674651924 })
})
afterEach(function() {
sinon.restore()
})
// The stringified req's are hard to understand. I thought Sazerac
// provided a way to override the describe message, though I can't find it.
context('when there is no If-Modified-Since header', function() {
@@ -163,7 +171,7 @@ describe('Cache header functions', function() {
function() {
it('returns true', function() {
const req = httpMocks.createRequest({
headers: { 'If-Modified-Since': new Date().toGMTString() },
headers: { 'If-Modified-Since': '2018-12-24T23:00:00.000Z' },
})
expect(serverHasBeenUpSinceResourceCached(req)).to.equal(true)
})