5180 fichiers 38.5 Mo 0 téléchargements 236 vues mis à jour il y a 5 heures ui
nitro-v36-with-renderer-v36 / src / hooks / translation / translationCache.test.ts
translationCache.test.ts 810 o Télécharger le fichier
import { describe, expect, it } from 'vitest';
import { TranslationCache } from './translationCache';

describe('TranslationCache', () =>
{
    it('forgets the oldest entry past its size', () =>
    {
        const cache = new TranslationCache<string>(2);

        cache.set('a', '1');
        cache.set('b', '2');
        cache.set('c', '3');

        expect(cache.size).toBe(2);
        expect(cache.get('a')).toBeUndefined();
        expect(cache.get('c')).toBe('3');
    });

    it('keeps an entry that was read recently', () =>
    {
        const cache = new TranslationCache<string>(2);

        cache.set('a', '1');
        cache.set('b', '2');
        cache.get('a');
        cache.set('c', '3');

        expect(cache.get('a')).toBe('1');
        expect(cache.get('b')).toBeUndefined();
    });
});
15Sujets
1Dépôts
20Membres
2En ligne
Profile
Inscrit
Dernière visite
Messages
0
Votes positifs
0
Votes négatifs
0

Nous utilisons des cookies pour assurer le bon fonctionnement du site et améliorer votre expérience. en savoir plus

Autoriser