Preview tests now run correctly
Pulling jQuery from the parent frame
This commit is contained in:
@ -77,7 +77,7 @@ $(document).ready(function() {
|
|||||||
.delay(500)
|
.delay(500)
|
||||||
.flatMap(() => common.executeChallenge$())
|
.flatMap(() => common.executeChallenge$())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
({ code, tests }) => {
|
({ tests }) => {
|
||||||
common.displayTestResults(tests);
|
common.displayTestResults(tests);
|
||||||
},
|
},
|
||||||
({ err }) => {
|
({ err }) => {
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
window.common = (function({ Rx: { Observable }, common = { init: [] } }) {
|
window.common = (function(global) {
|
||||||
|
const {
|
||||||
|
Rx: { Observable },
|
||||||
|
common = { init: [] }
|
||||||
|
} = global;
|
||||||
|
|
||||||
var libraryIncludes = `
|
var libraryIncludes = `
|
||||||
<link
|
<link
|
||||||
rel='stylesheet'
|
rel='stylesheet'
|
||||||
@ -13,7 +18,7 @@ window.common = (function({ Rx: { Observable }, common = { init: [] } }) {
|
|||||||
rel='stylesheet'
|
rel='stylesheet'
|
||||||
href='//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css'
|
href='//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css'
|
||||||
/>
|
/>
|
||||||
|
<script src='https://cdn.jsdelivr.net/jquery/1.9.0/jquery.js'></script>
|
||||||
<style>
|
<style>
|
||||||
body { padding: 0px 3px 0px 3px; }
|
body { padding: 0px 3px 0px 3px; }
|
||||||
</style>
|
</style>
|
||||||
@ -36,10 +41,14 @@ window.common = (function({ Rx: { Observable }, common = { init: [] } }) {
|
|||||||
|
|
||||||
return iFrameScript$
|
return iFrameScript$
|
||||||
.map(script => `<script>${script}</script>`)
|
.map(script => `<script>${script}</script>`)
|
||||||
.doOnNext(script => {
|
.flatMap(script => {
|
||||||
preview.open();
|
preview.open();
|
||||||
preview.write(libraryIncludes + code + script);
|
preview.write(libraryIncludes + code + script);
|
||||||
preview.close();
|
preview.close();
|
||||||
|
return Observable.fromCallback($(preview).ready, $(preview))()
|
||||||
|
.first()
|
||||||
|
// delay is need here for first initial run
|
||||||
|
.delay(50);
|
||||||
})
|
})
|
||||||
.map(() => code);
|
.map(() => code);
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable no-undef, no-unused-vars, no-native-reassign */
|
/* eslint-disable no-undef, no-unused-vars, no-native-reassign */
|
||||||
window.$ = parent.$;
|
window.__$ = parent.$;
|
||||||
window.$(function() {
|
window.__$(function() {
|
||||||
var _ = parent._;
|
var _ = parent._;
|
||||||
var Rx = parent.Rx;
|
var Rx = parent.Rx;
|
||||||
var chai = parent.chai;
|
var chai = parent.chai;
|
||||||
@ -9,6 +9,10 @@ window.$(function() {
|
|||||||
var common = parent.common;
|
var common = parent.common;
|
||||||
var code = common.editor.getValue();
|
var code = common.editor.getValue();
|
||||||
var editor = common.editor;
|
var editor = common.editor;
|
||||||
|
// 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));
|
||||||
|
|
||||||
common.runPreviewTests$ =
|
common.runPreviewTests$ =
|
||||||
function runPreviewTests$({ tests = [], ...rest }) {
|
function runPreviewTests$({ tests = [], ...rest }) {
|
||||||
|
Reference in New Issue
Block a user