From b48d7c0a5574c86e27030f75f4837b155a754d9c Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Tue, 28 Nov 2017 16:49:58 +0700 Subject: [PATCH] Test cache is disabled by default --- test/cache.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/cache.js diff --git a/test/cache.js b/test/cache.js new file mode 100644 index 0000000..f6bfc37 --- /dev/null +++ b/test/cache.js @@ -0,0 +1,33 @@ +import test from 'ava'; +import nock from 'nock'; +import Onionoo from '../'; +import data from './fixtures/data'; + +test('Cache is disabled by default', async t => { + const onionoo = new Onionoo(); + + const defaultEndpoint = data.defaultEndpoints[0]; + const responseHeaders = { + date: new Date().toUTCString(), + age: 0, + 'cache-control': 'public, max-age=300' + }; + + const scope = nock(data.defaultBaseUrl) + .get(`/${defaultEndpoint}`) + .reply(200, data.dummyResponse, responseHeaders); + + const response = await onionoo[defaultEndpoint](); + + t.false(response.fromCache); + t.truthy(scope.isDone()); + + const scope2 = nock(data.defaultBaseUrl) + .get(`/${defaultEndpoint}`) + .reply(200, data.dummyResponse, responseHeaders); + + const response2 = await onionoo[defaultEndpoint](); + + t.false(response2.fromCache); + t.truthy(scope2.isDone()); +});