Browse Source

Test expired returns true for stale cache

pull/7/head
Luke Childs 8 years ago
parent
commit
b552e87388
  1. 1
      package.json
  2. 11
      test/expired.js

1
package.json

@ -32,6 +32,7 @@
"devDependencies": {
"ava": "^0.17.0",
"coveralls": "^2.11.15",
"date-fns": "^1.21.1",
"nyc": "^10.0.0",
"xo": "^0.17.1"
}

11
test/expired.js

@ -1,4 +1,5 @@
import test from 'ava';
import subSeconds from 'date-fns/sub_seconds';
import expired from '../';
test('expired is a function', t => {
@ -14,3 +15,13 @@ test('expired returns false for valid cache', t => {
t.false(expired(headers));
});
test('expired returns true for stale cache', t => {
const headers = {
date: subSeconds(new Date().toUTCString(), 500),
age: 0,
'cache-control': 'public, max-age=300'
};
t.true(expired(headers));
});

Loading…
Cancel
Save