Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
beforeEach(function() {
NylasEnv.testOrganizationUnit = null;
if (isCoreSpec) { Grim.clearDeprecations(); }
ComponentRegistry._clear();
global.localStorage.clear();
DatabaseStore._transactionQueue = undefined;
//# If we don't spy on DatabaseStore._query, then
//`DatabaseStore.inTransaction` will never complete and cause all tests
//that depend on transactions to hang.
//
// @_query("BEGIN IMMEDIATE TRANSACTION") never resolves because
// DatabaseStore._query never runs because the @_open flag is always
// false because we never setup the DB when `NylasEnv.inSpecMode` is
// true.
spyOn(DatabaseStore, '_query').andCallFake(() => Promise.resolve([]));
TaskQueue._queue = [];
return Grim.on('updated', function() {
const deprecations = Grim.getDeprecations().map(deprecation =>
deprecation.serialize()
);
Grim.clearDeprecations();
return global.emit('task:deprecations', deprecations);
});
};