* Try to get schema from main schema if not found in single schema * Add newline * Add missing return * Add missing done to tests
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
var CacheController = require('../src/Controllers/CacheController.js').default;
|
|
var InMemoryCacheAdapter = require('../src/Adapters/Cache/InMemoryCacheAdapter').default;
|
|
var SchemaCache = require('../src/Controllers/SchemaCache').default;
|
|
|
|
describe('SchemaCache', () => {
|
|
var schemaCache;
|
|
|
|
beforeEach(() => {
|
|
var cacheAdapter = new InMemoryCacheAdapter({});
|
|
var cacheController = new CacheController(cacheAdapter, 'appId');
|
|
schemaCache = new SchemaCache(cacheController);
|
|
});
|
|
|
|
it('can retrieve a single schema after all schemas stored', (done) => {
|
|
var allSchemas = [{
|
|
className: 'Class1'
|
|
}, {
|
|
className: 'Class2'
|
|
}];
|
|
schemaCache.setAllClasses(allSchemas);
|
|
schemaCache.getOneSchema('Class2').then((schema) => {
|
|
expect(schema).not.toBeNull();
|
|
done();
|
|
});
|
|
});
|
|
|
|
it('does not return all schemas after a single schema is stored', (done) => {
|
|
var schema = {
|
|
className: 'Class1'
|
|
};
|
|
schemaCache.setOneSchema('Class1', schema);
|
|
schemaCache.getAllClasses().then((allSchemas) => {
|
|
expect(allSchemas).toBeNull();
|
|
done();
|
|
});
|
|
});
|
|
});
|