UNPKG

fume-fhir-converter

Version:

FHIR-Utilized Mapping Engine - Community

78 lines 3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * © Copyright Outburn Ltd. 2022-2024 All Rights Reserved * Project name: FUME-COMMUNITY */ const globals_1 = require("@jest/globals"); const simpleCache_1 = require("./simpleCache"); describe('SimpleCache', () => { (0, globals_1.test)('set \\ get works', async () => { const cache = new simpleCache_1.SimpleCache(); cache.set('key', 'value'); const res = cache.get('key'); expect(res).toEqual('value'); }); (0, globals_1.test)('set overrides existing value', async () => { const cache = new simpleCache_1.SimpleCache(); cache.set('key', 'value'); cache.set('key', 'value2'); const res = cache.get('key'); expect(res).toEqual('value2'); }); (0, globals_1.test)('get works value when not cached', async () => { const cache = new simpleCache_1.SimpleCache(); const res = cache.get('key'); expect(res).toEqual(undefined); }); (0, globals_1.test)('keys returns all current keys', async () => { const cache = new simpleCache_1.SimpleCache(); cache.set('key', 'value'); cache.set('key2', 'value2'); const res = cache.keys(); expect(res).toEqual(['key', 'key2']); }); (0, globals_1.test)('keys returns of empty cache', async () => { const cache = new simpleCache_1.SimpleCache(); const res = cache.keys(); expect(res).toEqual([]); }); (0, globals_1.test)('reset to clear cache', async () => { const cache = new simpleCache_1.SimpleCache(); cache.set('key', 'value'); cache.set('key2', 'value2'); cache.reset(); const res = cache.get('key'); const res2 = cache.get('key2'); expect(res).toEqual(undefined); expect(res2).toEqual(undefined); }); (0, globals_1.test)('getDict to return underlaying data', async () => { const cache = new simpleCache_1.SimpleCache(); cache.set('key', 'value'); cache.set('key2', 'value2'); const res = cache.getDict(); expect(res).toEqual({ key: 'value', key2: 'value2' }); }); (0, globals_1.test)('populate overrides cache', async () => { const cache = new simpleCache_1.SimpleCache(); cache.set('key', 'value'); cache.set('key2', 'value2'); const newCache = { key: 'apple', key3: 'banana' }; cache.populate(newCache); const res = cache.getDict(); expect(res).toEqual({ key: 'apple', key3: 'banana' }); }); (0, globals_1.test)('populate with undefined clears cache', async () => { const cache = new simpleCache_1.SimpleCache(); cache.set('key', 'value'); cache.set('key2', 'value2'); cache.populate(undefined); const res = cache.getDict(); expect(res).toEqual({}); }); }); //# sourceMappingURL=simpleCache.test.js.map