summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/lru-cache/test/basic.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/lru-cache/test/basic.js')
-rw-r--r--deps/npm/node_modules/lru-cache/test/basic.js51
1 files changed, 25 insertions, 26 deletions
diff --git a/deps/npm/node_modules/lru-cache/test/basic.js b/deps/npm/node_modules/lru-cache/test/basic.js
index b47225f109..949113e9ce 100644
--- a/deps/npm/node_modules/lru-cache/test/basic.js
+++ b/deps/npm/node_modules/lru-cache/test/basic.js
@@ -93,6 +93,31 @@ test("reset", function (t) {
})
+// Note: `<cache>.dump()` is a debugging tool only. No guarantees are made
+// about the format/layout of the response.
+test("dump", function (t) {
+ var cache = new LRU(10)
+ var d = cache.dump();
+ t.equal(Object.keys(d).length, 0, "nothing in dump for empty cache")
+ cache.set("a", "A")
+ var d = cache.dump() // { a: { key: "a", value: "A", lu: 0 } }
+ t.ok(d.a)
+ t.equal(d.a.key, "a")
+ t.equal(d.a.value, "A")
+ t.equal(d.a.lu, 0)
+
+ cache.set("b", "B")
+ cache.get("b")
+ d = cache.dump()
+ t.ok(d.b)
+ t.equal(d.b.key, "b")
+ t.equal(d.b.value, "B")
+ t.equal(d.b.lu, 2)
+
+ t.end()
+})
+
+
test("basic with weighed length", function (t) {
var cache = new LRU({
max: 100,
@@ -157,32 +182,6 @@ test("lru recently gotten with weighed length", function (t) {
t.end()
})
-test("lru recently updated with weighed length", function (t) {
- var cache = new LRU({
- max: 8,
- length: function (item) { return item.length }
- })
- cache.set("a", "A")
- cache.set("b", "BB")
- cache.set("c", "CCC")
- t.equal(cache.length, 6) //CCC BB A
- cache.set("a", "+A")
- t.equal(cache.length, 7) //+A CCC BB
- cache.set("b", "++BB")
- t.equal(cache.length, 6) //++BB +A
- t.equal(cache.get("c"), undefined)
-
- cache.set("c", "oversized")
- t.equal(cache.length, 6) //++BB +A
- t.equal(cache.get("c"), undefined)
-
- cache.set("a", "oversized")
- t.equal(cache.length, 4) //++BB
- t.equal(cache.get("a"), undefined)
- t.equal(cache.get("b"), "++BB")
- t.end()
-})
-
test("set returns proper booleans", function(t) {
var cache = new LRU({
max: 5,