From 4b30080999b74725a0160cbf509b9192d27f6c18 Mon Sep 17 00:00:00 2001 From: teepy <56241351+Tee-py@users.noreply.github.com> Date: Fri, 21 Feb 2025 02:56:04 +0100 Subject: [PATCH] cleanups --- tests/core/test.spec.ts | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/core/test.spec.ts b/tests/core/test.spec.ts index 83e1b2c..0952264 100644 --- a/tests/core/test.spec.ts +++ b/tests/core/test.spec.ts @@ -117,86 +117,86 @@ describe('Transaction Parser Utils', () => { describe('LRUCache Tests', () => { let cache: LRUCache; - + beforeEach(() => { cache = new LRUCache(3); }); - + test('should initialize with correct capacity', () => { expect(cache.size).toBe(0); const cache2 = new LRUCache(5); expect(cache2.size).toBe(0); }); - + test('should set and get values correctly', () => { cache.set('a', 1); expect(cache.get('a')).toBe(1); expect(cache.size).toBe(1); }); - + test('should return null for non-existent keys', () => { expect(cache.get('missing')).toBeNull(); }); - + test('should update existing keys', () => { cache.set('a', 1); cache.set('a', 2); expect(cache.get('a')).toBe(2); expect(cache.size).toBe(1); }); - + test('should evict least recently used item when capacity is reached', () => { cache.set('a', 1); cache.set('b', 2); cache.set('c', 3); cache.set('d', 4); - + expect(cache.get('a')).toBeNull(); expect(cache.get('b')).toBe(2); expect(cache.get('c')).toBe(3); expect(cache.get('d')).toBe(4); expect(cache.size).toBe(3); }); - + test('should maintain LRU order with gets', () => { cache.set('a', 1); cache.set('b', 2); cache.set('c', 3); - + cache.get('a'); - + cache.set('d', 4); - + expect(cache.get('b')).toBeNull(); expect(cache.get('a')).toBe(1); expect(cache.get('c')).toBe(3); expect(cache.get('d')).toBe(4); }); - + test('should clear the cache', () => { cache.set('a', 1); cache.set('b', 2); cache.clear(); - + expect(cache.size).toBe(0); expect(cache.get('a')).toBeNull(); expect(cache.get('b')).toBeNull(); }); - + // test('should handle complex sequence of operations', () => { // cache.set('a', 1); // cache.set('b', 2); - // cache.get('a'); + // cache.get('a'); // cache.set('c', 3); // cache.set('d', 4); - + // expect(cache.get('b')).toBeNull(); // expect(cache.get('a')).toBe(1); // expect(cache.get('c')).toBe(3); // expect(cache.get('d')).toBe(4); - + // cache.set('e', 5); - + // expect(cache.get('c')).toBeNull(); // expect(cache.get('a')).toBe(1); // expect(cache.get('d')).toBe(4);