@empathyco/x-storage-service
Version:
Storage service with TTL
36 lines • 1.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var in_memory_storage_service_1 = require("../in-memory-storage-service");
var storage;
var key = 'key';
var anotherKey = 'another-key';
var item = { a: 'item', b: true, c: 288 };
describe('testing InMemoryStorageService', function () {
beforeEach(function () {
storage = new in_memory_storage_service_1.InMemoryStorageService();
});
it('gets an item from storage', function () {
storage.setItem(key, item);
expect(storage.getItem(key)).toEqual(item);
});
it('removes an item from storage and returns it', function () {
storage.setItem(key, item);
expect(storage.removeItem(key)).toEqual(item);
});
it('clears all the items', function () {
storage.setItem(key, item);
storage.setItem(anotherKey, item);
expect(storage.clear()).toEqual(2);
expect(storage.getItem(key)).toBeNull();
expect(storage.getItem(anotherKey)).toBeNull();
});
it('does not allow you to save undefined values', function () {
storage.setItem(key, undefined);
expect(storage.getItem(key)).toBeNull();
});
it('allows you to save null values', function () {
storage.setItem(key, null);
expect(storage.getItem(key)).toBeNull();
});
});
//# sourceMappingURL=in-memory-storage-service.spec.js.map