import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import chai from 'chai';
import chaiEnzyme from 'chai-enzyme';
configure({ adapter: new Adapter() });
chai.use(chaiEnzyme());
import 'bootstrap/dist/css/bootstrap.min.css';

function importAll (r) {
	r.keys().forEach(r);
}

export const spies = [];
afterEach(function masterAfterEach() {
	while(spies.length > 0){
		const spy = spies.pop();
		if(spy && spy.restore)
			spy.restore();
	}
});

// require all test files using special Webpack feature
// https://webpack.js.org/guides/dependency-management/#require-context
const componentTestsContext = require.context('../src/components', true, /\.spec.js(x)?$/);
const helperTestsContext = require.context('../src/helpers', true, /\.spec.js(x)?$/);
const storeTestsContext = require.context('../src/store', true, /\.spec.js(x)?$/);
const e2eTestsContext = require.context('.', true, /\.spec.js(x)?$/);

importAll(componentTestsContext);
importAll(helperTestsContext);
importAll(storeTestsContext);
importAll(e2eTestsContext);
