LearningSalesForceCommerceC.../storefront-reference-architecture/test/unit/modules/server/simpleCache.js

43 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2021-12-21 10:57:31 -08:00
'use strict';
var assert = require('chai').assert;
var SimpleCache = require('../../../../cartridges/modules/server/simpleCache');
describe('simpleCache', function () {
beforeEach(function () {
});
afterEach(function () {
});
it('should handle null argument for constructor', function () {
var cache = new SimpleCache(null);
assert.isTrue(cache !== null);
});
it('should accept a pre-filled KV store', function () {
var cache = new SimpleCache({ 'foo': 'bar' });
var value = cache.get('foo');
assert.isTrue(value === 'bar');
});
it('should get a value previously set', function () {
var cache = new SimpleCache({});
cache.set('foo', 'bar');
var value = cache.get('foo');
assert.isTrue(value === 'bar');
});
it('should correctly clear() values previously set', function () {
var cache = new SimpleCache({});
cache.set('foo', 'bar');
cache.clear();
var value = cache.get('foo');
assert.isTrue(value === null);
});
});