From 5bc88ab2552cdbada905383a963ef17541678abe Mon Sep 17 00:00:00 2001 From: HDegroote <75906619+HDegroote@users.noreply.github.com> Date: Tue, 2 Jul 2024 21:22:15 +0200 Subject: [PATCH] Test keys() and values() --- test.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test.js b/test.js index a6ffb2e..907ef20 100644 --- a/test.js +++ b/test.js @@ -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 })