v0.3.2
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { ResultCache, hashBlob } from '../src/background/cache';
|
||||
|
||||
describe('result cache', () => {
|
||||
it('evicts the least recently used entry', () => {
|
||||
const cache = new ResultCache<number>(2);
|
||||
cache.set('one', 1);
|
||||
cache.set('two', 2);
|
||||
expect(cache.get('one')).toBe(1);
|
||||
cache.set('three', 3);
|
||||
expect(cache.get('two')).toBeUndefined();
|
||||
expect(cache.get('one')).toBe(1);
|
||||
});
|
||||
|
||||
it('hashes identical content consistently', async () => {
|
||||
const first = await hashBlob(new Blob(['same content']));
|
||||
const second = await hashBlob(new Blob(['same content']));
|
||||
expect(first).toBe(second);
|
||||
expect(first).toMatch(/^[a-f0-9]{64}$/);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user