2016-06-10 20:27:21 -07:00
|
|
|
import AppCache from './cache';
|
2016-02-18 18:44:04 -08:00
|
|
|
|
2016-04-08 18:00:16 +01:00
|
|
|
//Used by tests
|
|
|
|
|
function destroyAllDataPermanently() {
|
|
|
|
|
if (process.env.TESTING) {
|
2016-06-10 20:27:21 -07:00
|
|
|
// This is super janky, but destroyAllDataPermanently is
|
|
|
|
|
// a janky interface, so we need to have some jankyness
|
|
|
|
|
// to support it
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}));
|
2016-04-08 18:00:16 +01:00
|
|
|
}
|
|
|
|
|
throw 'Only supported in test environment';
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-10 20:27:21 -07:00
|
|
|
module.exports = { destroyAllDataPermanently };
|