Skip to content

Commit

Permalink
more timing slack
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jun 6, 2017
1 parent 8be4c24 commit 1c49494
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions test/basic.js
Expand Up @@ -205,31 +205,31 @@ test('set returns proper booleans', function (t) {
test('drop the old items', function (t) {
var cache = new LRU({
max: 5,
maxAge: 50
maxAge: 200
})

cache.set('a', 'A')

setTimeout(function () {
cache.set('b', 'b')
t.equal(cache.get('a'), 'A')
})
}, 100)

setTimeout(function () {
cache.set('c', 'C')
// timed out
t.notOk(cache.get('a'))
}, 60 + 25)
}, 300)

setTimeout(function () {
t.notOk(cache.get('b'))
t.equal(cache.get('c'), 'C')
}, 120)
}, 400)

setTimeout(function () {
t.notOk(cache.get('c'))
t.end()
}, 200)
}, 600)
})

test('manual pruning', function (t) {
Expand Down
10 changes: 5 additions & 5 deletions test/serialize.js
Expand Up @@ -106,8 +106,8 @@ test('load basic cache', function (t) {
})

test('load staled cache', function (t) {
var cache = new LRU({maxAge: 50})
var copy = new LRU({maxAge: 50})
var cache = new LRU({maxAge: 100})
var copy = new LRU({maxAge: 100})
var arr

// expires at 50
Expand All @@ -117,18 +117,18 @@ test('load staled cache', function (t) {
cache.set('b', 'B')
arr = cache.dump()
t.equal(arr.length, 2)
}, 30)
}, 50)

setTimeout(function () {
copy.load(arr)
t.equal(copy.get('a'), undefined)
t.equal(copy.get('b'), 'B')
}, 60)
}, 120)

setTimeout(function () {
t.equal(copy.get('b'), undefined)
t.end()
}, 90)
}, 180)
})

test('load to other size cache', function (t) {
Expand Down

0 comments on commit 1c49494

Please sign in to comment.