2015-11-04 20:37:25 +00:00
|
|
|
/* eslint-disable no-undef, no-unused-vars, no-native-reassign */
|
2015-11-23 21:58:51 +00:00
|
|
|
window.__$ = parent.$;
|
|
|
|
window.__$(function() {
|
2015-11-13 19:10:23 +00:00
|
|
|
var _ = parent._;
|
2015-11-23 03:42:53 +00:00
|
|
|
var Rx = parent.Rx;
|
2015-11-13 19:10:23 +00:00
|
|
|
var chai = parent.chai;
|
2015-11-23 03:42:53 +00:00
|
|
|
var assert = chai.assert;
|
2015-05-28 12:26:25 +00:00
|
|
|
var tests = parent.tests;
|
2015-11-13 19:10:23 +00:00
|
|
|
var common = parent.common;
|
2015-11-24 01:29:05 +00:00
|
|
|
var editor = common.editor.getValue();
|
2015-11-23 21:58:51 +00:00
|
|
|
// grab the iframe body element
|
|
|
|
var body = document.getElementsByTagName('body');
|
|
|
|
// change the context of $ so it uses the iFrame for testing
|
|
|
|
var $ = __$.proxy(__$.fn.find, __$(body));
|
2015-05-28 12:26:25 +00:00
|
|
|
|
2015-11-23 03:42:53 +00:00
|
|
|
common.runPreviewTests$ =
|
|
|
|
function runPreviewTests$({ tests = [], ...rest }) {
|
|
|
|
return Rx.Observable.from(tests)
|
|
|
|
.map(test => {
|
|
|
|
const userTest = {};
|
|
|
|
try {
|
|
|
|
/* eslint-disable no-eval */
|
|
|
|
eval(test);
|
|
|
|
/* eslint-enable no-eval */
|
|
|
|
} catch (e) {
|
|
|
|
userTest.err = e.message.split(':').shift();
|
|
|
|
} finally {
|
|
|
|
userTest.text = test
|
|
|
|
.split(',')
|
|
|
|
.pop()
|
|
|
|
.replace(/\'/g, '')
|
|
|
|
.replace(/\)/, '');
|
|
|
|
}
|
|
|
|
return userTest;
|
|
|
|
})
|
|
|
|
.toArray()
|
|
|
|
.map(tests => ({ ...rest, tests }));
|
|
|
|
};
|
|
|
|
|
2015-11-13 19:10:23 +00:00
|
|
|
});
|