Skip to content

Commit 468a47c

Browse files
committed
test(cache): add unicode and emoji character key handling
1 parent a69a12d commit 468a47c

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

lib/cache.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,28 @@ describe('TTLCache', () => {
556556
cache.destroy();
557557
});
558558
});
559+
560+
it('stores and retrieves values with unicode and emoji cache keys', () => {
561+
const cache = new TTLCache<string>();
562+
563+
const unicodeKey = 'cache_🔥_key';
564+
const emojiKey = '🚀_rocket_🚀';
565+
const mixedKey = 'user_👤_data_🔐';
566+
567+
cache.set(unicodeKey, 'fire-value', 60_000);
568+
cache.set(emojiKey, 'rocket-value', 60_000);
569+
cache.set(mixedKey, 'secure-data', 60_000);
570+
571+
expect(cache.get(unicodeKey)).toBe('fire-value');
572+
expect(cache.get(emojiKey)).toBe('rocket-value');
573+
expect(cache.get(mixedKey)).toBe('secure-data');
574+
575+
expect(cache.has(unicodeKey)).toBe(true);
576+
expect(cache.has(emojiKey)).toBe(true);
577+
expect(cache.has(mixedKey)).toBe(true);
578+
579+
cache.destroy();
580+
});
559581
});
560582

561583
import { DistributedCache } from './cache';

0 commit comments

Comments
 (0)