Browse Source

Test expired.in returns positive ms for valid cache

pull/5/head
Luke Childs 8 years ago
parent
commit
3b6a6d7775
  1. 1
      package.json
  2. 15
      test/expired.in.js

1
package.json

@ -34,6 +34,7 @@
"coveralls": "^2.11.15",
"date-fns": "^1.21.1",
"nyc": "^10.0.0",
"timekeeper": "^1.0.0",
"xo": "^0.17.1"
}
}

15
test/expired.in.js

@ -1,6 +1,21 @@
import test from 'ava';
import tk from 'timekeeper';
import expired from '../';
test('expired.in is a function', t => {
t.is(typeof expired.in, 'function');
});
test('expired.in returns positive ms for valid cache', t => {
const date = new Date().toUTCString();
const maxAge = 300;
const headers = {
date: date,
age: 0,
'cache-control': `public, max-age=${maxAge}`
};
tk.freeze(date);
t.is(expired.in(headers), maxAge * 1000);
tk.reset();
});

Loading…
Cancel
Save