You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
580 B
27 lines
580 B
import test from 'ava';
|
|
import subSeconds from 'date-fns/sub_seconds';
|
|
import expired from '../';
|
|
|
|
test('expired is a function', t => {
|
|
t.is(typeof expired, 'function');
|
|
});
|
|
|
|
test('expired returns false for valid cache', t => {
|
|
const headers = {
|
|
date: new Date().toUTCString(),
|
|
age: 0,
|
|
'cache-control': 'public, max-age=300'
|
|
};
|
|
|
|
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));
|
|
});
|
|
|