-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmemory-test.js
More file actions
41 lines (34 loc) · 1.01 KB
/
memory-test.js
File metadata and controls
41 lines (34 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* node-http-cache.
* Copyright © 2012 Chris Corbyn.
*
* See LICENSE file for details.
*/
var helper = require('../../test-helper')
, shared = require('../../support/shared-examples')
, httpCache = helper.httpCache
, assert = require('assert')
, memo = helper.memo
;
describe('httpCache.storage.MemoryStorage', function(){
var storage = memo().is(function(){
return new httpCache.storage.MemoryStorage();
});
shared.behavesLikeACacheStorage(storage);
var method = memo().is(function(){ return 'GET' });
var headers = memo().is(function(){ return {} });
var req = memo().is(function(){
return helper.createRequest({
method: method(),
headers: headers()
});
});
var res = memo().is(function(){
return helper.createResponse(req());
});
it('tries to serve cache if cacheable', function(){
var serveCachedSpy = helper.sinon.spy(storage(), 'serveCached');
storage().handleRequest(req(), res());
assert(serveCachedSpy.called);
});
});