UNPKG

liveperson-functions-client

Version:

JavaScript client for LivePerson Functions.

44 lines 2.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const isImplementedCache_1 = require("../src/helper/isImplementedCache"); const event = 'event'; let isImplementedCache; beforeEach(() => { isImplementedCache = new isImplementedCache_1.IsImplementedCache(2); }); describe('ImplementedCache', () => { describe('success flows', () => { it('should add an event with a specific name to cache' + 'and return it when called again', () => { var _a; isImplementedCache.add(event, true); expect(isImplementedCache.get(event)).toBeDefined(); expect((_a = isImplementedCache.get(event)) === null || _a === void 0 ? void 0 : _a.isImplemented).toBeTrue(); }); it('should overwrite a specific event that already exists in cache', () => { var _a; isImplementedCache.add(event, true); isImplementedCache.add(event, false); expect(isImplementedCache.get(event)).toBeDefined(); expect((_a = isImplementedCache.get(event)) === null || _a === void 0 ? void 0 : _a.isImplemented).toBeFalse(); }); it('should not return an event that is expired', () => { isImplementedCache = new isImplementedCache_1.IsImplementedCache(-2); isImplementedCache.add(event, true); expect(isImplementedCache.get(event)).toBeUndefined(); }); it('should return the event with the provided skillId', () => { var _a, _b; isImplementedCache.add(event, true, 'sampleSkill'); expect(isImplementedCache.get(event, 'sampleSkill')).toBeDefined(); expect((_a = isImplementedCache.get(event, 'sampleSkill')) === null || _a === void 0 ? void 0 : _a.skillId).toBeString(); expect((_b = isImplementedCache.get(event, 'sampleSkill')) === null || _b === void 0 ? void 0 : _b.skillId).toEqual('sampleSkill'); }); it('should not return an undefined if no entry for provided skillId was found', () => { isImplementedCache.add(event, true, 'skill'); expect(isImplementedCache.get(event, 'skillsample')).toBeUndefined(); }); }); // No unhappy flows since cache does not throw any errors }); //# sourceMappingURL=isImplementedCache.test.js.map