Skip to content

Commit

Permalink
Test expired.on takes age into account
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechilds committed Dec 23, 2016
1 parent a39747b commit 46b9291
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/expired.on.js
Expand Up @@ -51,3 +51,19 @@ test('expired.on returns correct expirey date for stale cache', t => {
t.true(isEqual(expired.on(headers), expiredOn));
tk.reset();
});

test('expired.on takes age into account', t => {
const date = new Date().toUTCString();
const age = 150;
const maxAge = 300;
const headers = {
date: date,
age: age,
'cache-control': `public, max-age=${maxAge}`
};
const expiredOn = addSeconds(date, (maxAge - age));

tk.freeze(date);
t.true(isEqual(expired.on(headers), expiredOn));
tk.reset();
});

0 comments on commit 46b9291

Please sign in to comment.