Mailspring/spec/n1-spec-runner/master-after-each.es6
Evan Morikawa 331dc59853 fix(spec):
Dramatically clean up and simply the spec bootup process.

Converting spec bootup system to es6 from coffee.

Converted old `jasmine-helper`, `spec-helper`, and `spec-suite` to a new
`n1-spec-runner` file.

Each of these old files had tons and tons of code related to various parts
of the spec bootup and running process.

Each of those parts have been extracted into individual files
2016-10-16 20:10:19 -07:00

39 lines
1.1 KiB
JavaScript

import pathwatcher from 'pathwatcher';
import ReactTestUtils from 'react-addons-test-utils';
class MasterAfterEach {
setup(loadSettings, afterEach) {
afterEach(() => {
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');
this.ensureNoPathSubscriptions();
for (const styleElement of NylasEnv.styles.styleElements) {
NylasEnv.styles.removeStyleElement(styleElement)
}
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()