From c2c920fdb0ef4087334f274c4f2feb0f743c4585 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Tue, 23 May 2017 17:02:15 +0700 Subject: [PATCH] Test TTL is passed to cache --- test/cache.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/cache.js b/test/cache.js index ea5490f..007b8f1 100644 --- a/test/cache.js +++ b/test/cache.js @@ -105,6 +105,24 @@ test('Binary responses are cached', async t => { t.is(firstResponse.body.toString(), secondResponse.body.toString()); }); +test('TTL is passed to cache', async t => { + const endpoint = '/cache'; + const store = new Map(); + const cache = { + get: store.get.bind(store), + set: (key, val, ttl) => { + t.true(typeof ttl === 'number'); + t.true(ttl > 0); + return store.set(key, val, ttl); + }, + delete: store.delete.bind(store) + }; + + t.plan(2); + + await got(s.url + endpoint, {cache}); +}); + test('Cached response is re-encoded to current encoding option', async t => { const endpoint = '/cache'; const cache = new Map();