-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.js
More file actions
43 lines (39 loc) · 788 Bytes
/
test.js
File metadata and controls
43 lines (39 loc) · 788 Bytes
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
42
43
var test = require('tape');
var Cache = require('./');
test('get-set', function (t) {
var cache = Cache();
cache.set('foo', 'bar');
t.equals(cache.get('foo'), 'bar');
cache.destroy();
t.end();
});
test('expire', function (t) {
var cache = Cache({
ttl: 10,
});
cache.set('foo', 'bar');
setTimeout(function () {
t.equals(cache.get('foo'), null);
cache.destroy();
t.end();
}, 50);
});
test('cleanup', function (t) {
var cache = Cache({
ttl: 10,
interval: 20,
});
cache.set('foo', 'bar');
setTimeout(function () {
t.equals(cache.length, 0);
cache.destroy();
t.end();
}, 50);
});
test('destroy', function (t) {
var cache = Cache()
cache.set('foo', 'bar');
cache.destroy();
t.equals(cache.length, 0);
t.end();
});