mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-15 06:06:35 +08:00
d46cfc1cb4
Summary: Clean up k2's test database after each spec. Depends on D3826 Test Plan: unit Reviewers: evan, halla, spang Reviewed By: halla, spang Differential Revision: https://phab.nylas.com/D3827
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
import pathwatcher from 'pathwatcher';
|
|
import ReactTestUtils from 'react-addons-test-utils';
|
|
// TODO the local-sync package should be moved as part of nylas-mail core,
|
|
// instead of being a separate package
|
|
import {destroyTestDatabase} from '../../internal_packages/local-sync/spec/helpers'
|
|
|
|
class MasterAfterEach {
|
|
setup(loadSettings, afterEach) {
|
|
const styleElementsToRestore = NylasEnv.styles.getSnapshot();
|
|
|
|
const self = this
|
|
afterEach(function masterAfterEach() {
|
|
destroyTestDatabase()
|
|
NylasEnv.packages.deactivatePackages();
|
|
NylasEnv.menu.template = [];
|
|
|
|
if (NylasEnv.state) {
|
|
delete NylasEnv.state.packageStates;
|
|
}
|
|
|
|
if (!window.debugContent) {
|
|
document.getElementById('jasmine-content').innerHTML = '';
|
|
}
|
|
ReactTestUtils.unmountAll();
|
|
|
|
jasmine.unspy(NylasEnv, 'saveSync');
|
|
self.ensureNoPathSubscriptions();
|
|
|
|
NylasEnv.styles.restoreSnapshot(styleElementsToRestore);
|
|
|
|
this.removeAllSpies();
|
|
waits(0);
|
|
}); // yield to ui thread to make screen update more frequently
|
|
}
|
|
|
|
ensureNoPathSubscriptions() {
|
|
const watchedPaths = pathwatcher.getWatchedPaths();
|
|
pathwatcher.closeAllWatchers();
|
|
if (watchedPaths.length > 0) {
|
|
throw new Error(`Leaking subscriptions for paths: ${watchedPaths.join(", ")}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
export default new MasterAfterEach()
|