Copilot commented on code in PR #42409:
URL: https://github.com/apache/superset/pull/42409#discussion_r3659557895
##########
superset-frontend/packages/superset-ui-core/test/utils/lruCache.test.ts:
##########
@@ -53,6 +53,27 @@ test('LRU operations', () => {
expect(cache.capacity).toBe(3);
});
+test('overwriting an existing key does not evict another entry', () => {
+ const cache = lruCache<string>(2);
+ cache.set('a', 'a');
+ cache.set('b', 'b');
+ cache.set('b', 'b2');
+ expect(cache.size).toBe(2);
+ expect(cache.has('a')).toBeTruthy();
Review Comment:
Prefer `toBe(true)` / `toBe(false)` over `toBeTruthy()` / `toBeFalsy()`
here. Since `cache.has(...)` is already a boolean, using strict boolean
expectations makes failures clearer and avoids masking unexpected non-boolean
values.
##########
superset-frontend/packages/superset-ui-core/test/utils/lruCache.test.ts:
##########
@@ -53,6 +53,27 @@ test('LRU operations', () => {
expect(cache.capacity).toBe(3);
});
+test('overwriting an existing key does not evict another entry', () => {
+ const cache = lruCache<string>(2);
+ cache.set('a', 'a');
+ cache.set('b', 'b');
+ cache.set('b', 'b2');
+ expect(cache.size).toBe(2);
+ expect(cache.has('a')).toBeTruthy();
+ expect(cache.get('b')).toBe('b2');
+});
+
+test('overwriting an existing key refreshes its recency', () => {
+ const cache = lruCache<string>(2);
+ cache.set('a', 'a');
+ cache.set('b', 'b');
+ // `a` becomes the most recently used, so `b` is evicted next
+ cache.set('a', 'a2');
+ cache.set('c', 'c');
+ expect(cache.has('b')).toBeFalsy();
Review Comment:
Prefer `toBe(true)` / `toBe(false)` over `toBeTruthy()` / `toBeFalsy()`
here. Since `cache.has(...)` is already a boolean, using strict boolean
expectations makes failures clearer and avoids masking unexpected non-boolean
values.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]