BVB Source Codes

parse-server Show InMemoryCacheAdapter.spec.js Source code

Return Download parse-server: download InMemoryCacheAdapter.spec.js Source code - Download parse-server Source code - Type:.js
  1. var InMemoryCacheAdapter = require('../src/Adapters/Cache/InMemoryCacheAdapter').default;
  2.  
  3. describe('InMemoryCacheAdapter', function() {
  4.   var KEY = 'hello';
  5.   var VALUE = 'world';
  6.  
  7.   function wait(sleep) {
  8.     return new Promise(function(resolve) {
  9.       setTimeout(resolve, sleep);
  10.     })
  11.   }
  12.  
  13.   it('should expose promisifyed methods', (done) => {
  14.     var cache = new InMemoryCacheAdapter({
  15.       ttl: NaN
  16.     });
  17.  
  18.     // Verify all methods return promises.
  19.     Promise.all([
  20.       cache.put(KEY, VALUE),
  21.       cache.del(KEY),
  22.       cache.get(KEY),
  23.       cache.clear()
  24.     ]).then(() => {
  25.       done();
  26.     });
  27.   });
  28.  
  29.   it('should get/set/clear', (done) => {
  30.     var cache = new InMemoryCacheAdapter({
  31.       ttl: NaN
  32.     });
  33.  
  34.     cache.put(KEY, VALUE)
  35.       .then(() => cache.get(KEY))
  36.       .then((value) => expect(value).toEqual(VALUE))
  37.       .then(() => cache.clear())
  38.       .then(() => cache.get(KEY))
  39.       .then((value) => expect(value).toEqual(null))
  40.       .then(done);
  41.   });
  42.  
  43.   it('should expire after ttl', (done) => {
  44.     var cache = new InMemoryCacheAdapter({
  45.       ttl: 10
  46.     });
  47.  
  48.     cache.put(KEY, VALUE)
  49.       .then(() => cache.get(KEY))
  50.       .then((value) => expect(value).toEqual(VALUE))
  51.       .then(wait.bind(null, 50))
  52.       .then(() => cache.get(KEY))
  53.       .then((value) => expect(value).toEqual(null))
  54.       .then(done);
  55.   })
  56.  
  57. });
  58.  
downloadInMemoryCacheAdapter.spec.js Source code - Download parse-server Source code
Related Source Codes/Software:
react-boilerplate - 2017-06-07
webtorrent - Streaming torrent client for the web ... 2017-06-06
machine-learning-for-software-engineers - A complete daily plan for studying to become a mac... 2017-06-06
upterm - A terminal emulator for the 21st century. 2017-06-06
lottie-android - Render After Effects animations natively on Androi... 2017-06-07
AsyncDisplayKit - Smooth asynchronous user interfaces for iOS apps. ... 2017-06-07
ionicons - The premium icon font for Ionic ... 2017-06-07
storybook - 2017-06-07
prettier - Prettier is an opinionated JavaScript formatter. ... 2017-06-08
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top