Style improvements (#2475)
* HooksRouter is enabled by default * Adds middleswares on PromiseRouter, fixes #2410 * Move testing line to helper * Modernize middlewares.js * Moves DB uniqueness initialization to DBController, modernize * Moves testing related code to spec folder * remove unused _removeHook function * Adds tests, docs for Analytics and improvements * nit * moves back TestUtils
This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
import { destroyAllDataPermanently } from './DatabaseAdapter';
|
||||
import AppCache from './cache';
|
||||
|
||||
let unsupported = function() {
|
||||
throw 'Only supported in test environment';
|
||||
};
|
||||
|
||||
let _destroyAllDataPermanently;
|
||||
if (process.env.TESTING) {
|
||||
_destroyAllDataPermanently = destroyAllDataPermanently;
|
||||
} else {
|
||||
_destroyAllDataPermanently = unsupported;
|
||||
//Used by tests
|
||||
function destroyAllDataPermanently() {
|
||||
if (!process.env.TESTING) {
|
||||
throw 'Only supported in test environment';
|
||||
}
|
||||
return Promise.all(Object.keys(AppCache.cache).map(appId => {
|
||||
const app = AppCache.get(appId);
|
||||
if (app.databaseController) {
|
||||
return app.databaseController.deleteEverything();
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
export default {
|
||||
destroyAllDataPermanently: _destroyAllDataPermanently};
|
||||
export {
|
||||
destroyAllDataPermanently
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user