More refactoring

This commit is contained in:
Berkeley Martinez
2015-11-17 21:25:16 -08:00
parent 748f7ab93f
commit 29f90505b7
30 changed files with 1043 additions and 1569 deletions

View File

@@ -0,0 +1,35 @@
window.common = (function(global) {
const {
Rx: { Observable },
chai,
common = { init: [] }
} = global;
common.runTests$ = function runTests$({ code, userTests, ...rest }) {
return Observable.from(userTests)
.map(function(test) {
/* eslint-disable no-unused-vars */
const assert = chai.assert;
const editor = { getValue() { return code; }};
/* eslint-enable no-unused-vars */
try {
if (test) {
/* eslint-disable no-eval */
eval(common.reassembleTest(test, code));
/* eslint-enable no-eval */
}
} catch (e) {
test.err = e.message;
}
return test;
})
.toArray()
.map(tests => ({ ...rest, tests }));
};
return common;
}(window));