Skip to content

Commit 0f5d7e0

Browse files
committed
node-cache: added tests
1 parent 0123e36 commit 0f5d7e0

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

node-cache/node-cache-tests.ts

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/// <reference path="./node-cache.d.ts" />
2+
3+
import NodeCache = require('node-cache');
4+
5+
import Options = NodeCacheTypes.Options;
6+
import Stats = NodeCacheTypes.Stats;
7+
import Callback = NodeCacheTypes.Callback;
8+
9+
interface TypeSample {
10+
a: number;
11+
b: string;
12+
c: boolean;
13+
}
14+
15+
{
16+
let options: Options;
17+
let cache: NodeCacheTypes.NodeCache;
18+
cache = new NodeCache();
19+
cache = new NodeCache(options);
20+
}
21+
22+
{
23+
let cache: NodeCache;
24+
let key: string;
25+
let cb: Callback<TypeSample>;
26+
let result: TypeSample;
27+
result = cache.get<TypeSample>(key);
28+
result = cache.get<TypeSample>(key, cb);
29+
}
30+
31+
{
32+
let cache: NodeCache;
33+
let keys: string[];
34+
let cb: Callback<{[key: string]: TypeSample}>;
35+
let result: {[key: string]: TypeSample};
36+
result = cache.mget<TypeSample>(keys);
37+
result = cache.mget<TypeSample>(keys, cb);
38+
}
39+
40+
{
41+
let cache: NodeCache;
42+
let key: string;
43+
let value: TypeSample;
44+
let ttl: number|string;
45+
let cb: Callback<boolean>;
46+
let result: boolean;
47+
result = cache.set<TypeSample>(key, value);
48+
result = cache.set<TypeSample>(key, value, ttl);
49+
result = cache.set<TypeSample>(key, value, ttl, cb);
50+
result = cache.set<TypeSample>(key, value, cb);
51+
}
52+
53+
{
54+
let cache: NodeCache;
55+
let keys: string|string[];
56+
let cb: Callback<number>;
57+
let result: number;
58+
result = cache.del(keys);
59+
result = cache.del(keys, cb);
60+
}
61+
62+
{
63+
let cache: NodeCache;
64+
let key: string;
65+
let ttl: number;
66+
let cb: Callback<boolean>;
67+
let result: boolean;
68+
result = cache.ttl(key);
69+
result = cache.ttl(key, ttl);
70+
result = cache.ttl(key, ttl, cb);
71+
result = cache.ttl(key, cb);
72+
}
73+
74+
{
75+
let cache: NodeCache;
76+
let cb: Callback<string[]>;
77+
let result: string[];
78+
result = cache.keys();
79+
result = cache.keys(cb);
80+
}
81+
82+
{
83+
let cache: NodeCache;
84+
let result: Stats;
85+
result = cache.getStats();
86+
}
87+
88+
{
89+
let cache: NodeCache;
90+
let result: void;
91+
result = cache.flushAll();
92+
}
93+
94+
{
95+
let cache: NodeCache;
96+
let result: void;
97+
result = cache.close();
98+
}

0 commit comments

Comments
 (0)