2018-02-17 09:55:30 -05:00
|
|
|
const NullCacheAdapter = require('../src/Adapters/Cache/NullCacheAdapter').default;
|
2016-09-07 21:08:09 +09:00
|
|
|
|
|
|
|
|
describe('NullCacheAdapter', function() {
|
2018-02-17 09:55:30 -05:00
|
|
|
const KEY = 'hello';
|
|
|
|
|
const VALUE = 'world';
|
2016-09-07 21:08:09 +09:00
|
|
|
|
|
|
|
|
it('should expose promisifyed methods', (done) => {
|
2018-02-17 09:55:30 -05:00
|
|
|
const cache = new NullCacheAdapter({
|
2016-09-07 21:08:09 +09:00
|
|
|
ttl: NaN
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Verify all methods return promises.
|
|
|
|
|
Promise.all([
|
|
|
|
|
cache.put(KEY, VALUE),
|
|
|
|
|
cache.del(KEY),
|
|
|
|
|
cache.get(KEY),
|
|
|
|
|
cache.clear()
|
|
|
|
|
]).then(() => {
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should get/set/clear', (done) => {
|
2018-02-17 09:55:30 -05:00
|
|
|
const cache = new NullCacheAdapter({
|
2016-09-07 21:08:09 +09:00
|
|
|
ttl: NaN
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
cache.put(KEY, VALUE)
|
|
|
|
|
.then(() => cache.get(KEY))
|
|
|
|
|
.then((value) => expect(value).toEqual(null))
|
|
|
|
|
.then(() => cache.clear())
|
|
|
|
|
.then(() => cache.get(KEY))
|
|
|
|
|
.then((value) => expect(value).toEqual(null))
|
|
|
|
|
.then(done);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|