BVB Source Codes

parse-server Show SchemaCache.spec.js Source code

Return Download parse-server: download SchemaCache.spec.js Source code - Download parse-server Source code - Type:.js
  1. var CacheController = require('../src/Controllers/CacheController.js').default;
  2. var InMemoryCacheAdapter = require('../src/Adapters/Cache/InMemoryCacheAdapter').default;
  3. var SchemaCache = require('../src/Controllers/SchemaCache').default;
  4.  
  5. describe('SchemaCache', () => {
  6.   let cacheController;
  7.  
  8.   beforeEach(() => {
  9.     const cacheAdapter = new InMemoryCacheAdapter({});
  10.     cacheController = new CacheController(cacheAdapter, 'appId');
  11.   });
  12.  
  13.   it('can retrieve a single schema after all schemas stored', (done) => {
  14.     const schemaCache = new SchemaCache(cacheController);
  15.     const allSchemas = [{
  16.       className: 'Class1'
  17.     }, {
  18.       className: 'Class2'
  19.     }];
  20.     schemaCache.setAllClasses(allSchemas).then(() => {
  21.       return schemaCache.getOneSchema('Class2');
  22.     }).then((schema) => {
  23.       expect(schema).not.toBeNull();
  24.       done();
  25.     });
  26.   });
  27.  
  28.   it('does not return all schemas after a single schema is stored', (done) => {
  29.     const schemaCache = new SchemaCache(cacheController);
  30.     const schema = {
  31.       className: 'Class1'
  32.     };
  33.     schemaCache.setOneSchema(schema.className, schema).then(() => {
  34.       return schemaCache.getAllClasses();
  35.     }).then((allSchemas) => {
  36.       expect(allSchemas).toBeNull();
  37.       done();
  38.     });
  39.   });
  40.  
  41.   it('doesn\'t persist cached data by default', (done) => {
  42.     const schemaCache = new SchemaCache(cacheController);
  43.     const schema = {
  44.       className: 'Class1'
  45.     };
  46.     schemaCache.setOneSchema(schema.className, schema).then(() => {
  47.       const anotherSchemaCache = new SchemaCache(cacheController);
  48.       return anotherSchemaCache.getOneSchema(schema.className).then((schema) => {
  49.         expect(schema).toBeNull();
  50.         done();
  51.       });
  52.     });
  53.   });
  54.  
  55.   it('can persist cached data', (done) => {
  56.     const schemaCache = new SchemaCache(cacheController, 5000, true);
  57.     const schema = {
  58.       className: 'Class1'
  59.     };
  60.     schemaCache.setOneSchema(schema.className, schema).then(() => {
  61.       const anotherSchemaCache = new SchemaCache(cacheController, 5000, true);
  62.       return anotherSchemaCache.getOneSchema(schema.className).then((schema) => {
  63.         expect(schema).not.toBeNull();
  64.         done();
  65.       });
  66.     });
  67.   });
  68. });
  69.  
downloadSchemaCache.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