Skip to content

Commit

Permalink
Test keys() and values()
Browse files Browse the repository at this point in the history
  • Loading branch information
HDegroote committed Jul 2, 2024
1 parent 7783e87 commit 5bc88ab
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,32 @@ test('iterator', t => {
}
})

test('keys()', t => {
const cache = new GlobalCache()
const sub = cache.sub()

cache.set('key', 'value')
cache.set('key2', 'value2')
sub.set('key', 'value')
sub.set('what2', 'ever2')

t.alike([...cache.keys()], ['key', 'key2'], 'expected keys')
t.alike([...sub.keys()], ['key', 'what2'], 'expected keys')
})

test('values()', t => {
const cache = new GlobalCache()
const sub = cache.sub()

cache.set('key', 'value')
cache.set('key2', 'value2')
sub.set('key', 'value')
sub.set('what2', 'ever2')

t.alike([...cache.values()], ['value', 'value2'], 'expected values')
t.alike([...sub.values()], ['value', 'ever2'], 'expected values')
})

test('internal structure remains consistent', t => {
const cache = new GlobalCache({ maxSize: 3 })

Expand Down

0 comments on commit 5bc88ab

Please sign in to comment.