quaerateum
Version:
Simple typescript ORM for node.js based on data-mapper, unit-of-work and identity-map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JS.
23 lines (18 loc) • 652 B
text/typescript
import { writeFileSync } from 'fs';
import { FileCacheAdapter } from '../lib/cache';
import { TEMP_DIR } from './bootstrap';
/**
* @class FileCacheAdapterTest
*/
describe('FileCacheAdapter', () => {
test('should ignore old cache', async () => {
const origin = TEMP_DIR + '/.origin';
const cache = new FileCacheAdapter({ cacheDir: TEMP_DIR });
writeFileSync(origin, 123);
cache.set('cache-test-handle', 123, origin);
expect(cache.get('cache-test-handle')).toBe(123);
await new Promise(resolve => setTimeout(resolve, 10));
writeFileSync(origin, '321');
expect(cache.get('cache-test-handle')).toBeNull();
});
});