Add NullCacheAdapter (#2636)

* Add NullCacheAdapter

* clear returns promise explicitly

* Add NullCacheAdapter accessor
This commit is contained in:
Yuki Takeichi
2016-09-07 21:08:09 +09:00
committed by Florent Vilmart
parent 33e3993a37
commit fe62e92aa1
4 changed files with 65 additions and 1 deletions

View File

@@ -0,0 +1,37 @@
var NullCacheAdapter = require('../src/Adapters/Cache/NullCacheAdapter').default;
describe('NullCacheAdapter', function() {
var KEY = 'hello';
var VALUE = 'world';
it('should expose promisifyed methods', (done) => {
var cache = new NullCacheAdapter({
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) => {
var cache = new NullCacheAdapter({
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);
});
});