UNPKG

@websolutespa/payload-plugin-bowl

Version:

Bowl PayloadCms plugin of the BOM Repository

33 lines (32 loc) 1.06 kB
// readme https://testing-library.com/ import { describe, expect } from 'vitest'; import { InMemoryCache } from './cache.service'; describe('InMemoryCache', ()=>{ test('set & has value', ()=>{ const cache = new InMemoryCache(); const key = 'cache'; const value = 'value'; cache.set(key, value); expect(cache.has(key)).toEqual(true); }); test('set & get value', ()=>{ const cache = new InMemoryCache(); const key = 'cache'; const value = 'value'; cache.set(key, value); expect(cache.get(key)).toEqual(value); }); test('expiration', async ()=>{ const duration = 1000; const cache = new InMemoryCache({ duration: duration }); const key = 'cache'; const value = 'value'; cache.set(key, value); expect(cache.has(key)).toEqual(true); await new Promise((r)=>setTimeout(r, duration + 1)); expect(cache.has(key)).toEqual(false); }); }); //# sourceMappingURL=cache.service.test.js.map