2018-09-01 13:58:06 -04:00
|
|
|
const NullCacheAdapter = require('../lib/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
|
|
|
|
2018-09-01 13:58:06 -04:00
|
|
|
it('should expose promisifyed methods', done => {
|
2018-02-17 09:55:30 -05:00
|
|
|
const cache = new NullCacheAdapter({
|
2018-09-01 13:58:06 -04:00
|
|
|
ttl: NaN,
|
2016-09-07 21:08:09 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Verify all methods return promises.
|
|
|
|
|
Promise.all([
|
|
|
|
|
cache.put(KEY, VALUE),
|
|
|
|
|
cache.del(KEY),
|
|
|
|
|
cache.get(KEY),
|
2018-09-01 13:58:06 -04:00
|
|
|
cache.clear(),
|
2016-09-07 21:08:09 +09:00
|
|
|
]).then(() => {
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2018-09-01 13:58:06 -04:00
|
|
|
it('should get/set/clear', done => {
|
2018-02-17 09:55:30 -05:00
|
|
|
const cache = new NullCacheAdapter({
|
2018-09-01 13:58:06 -04:00
|
|
|
ttl: NaN,
|
2016-09-07 21:08:09 +09:00
|
|
|
});
|
|
|
|
|
|
2018-09-01 13:58:06 -04:00
|
|
|
cache
|
|
|
|
|
.put(KEY, VALUE)
|
2016-09-07 21:08:09 +09:00
|
|
|
.then(() => cache.get(KEY))
|
2018-09-01 13:58:06 -04:00
|
|
|
.then(value => expect(value).toEqual(null))
|
2016-09-07 21:08:09 +09:00
|
|
|
.then(() => cache.clear())
|
|
|
|
|
.then(() => cache.get(KEY))
|
2018-09-01 13:58:06 -04:00
|
|
|
.then(value => expect(value).toEqual(null))
|
2016-09-07 21:08:09 +09:00
|
|
|
.then(done);
|
|
|
|
|
});
|
|
|
|
|
});
|