-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try to retrieve schema from all schemas cache if not found in individ…
…ual cache (#2912) * Try to get schema from main schema if not found in single schema * Add newline * Add missing return * Add missing done to tests
- Loading branch information
1 parent
af55cd1
commit 151bea2
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
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(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters