start adding test output to coursewares

This commit is contained in:
Michael Q Larson
2015-02-14 14:09:26 -08:00
parent 255d2654ea
commit fb971ab080
4 changed files with 30 additions and 20 deletions

View File

@ -62,7 +62,7 @@ function updatePreview() {
var previewFrame = document.getElementById('preview'); var previewFrame = document.getElementById('preview');
var preview = previewFrame.contentDocument || previewFrame.contentWindow.document; var preview = previewFrame.contentDocument || previewFrame.contentWindow.document;
preview.open(); preview.open();
preview.write(libraryIncludes + editor.getValue() + otherTestsForNow); preview.write(libraryIncludes + editor.getValue());
preview.close(); preview.close();
} }
setTimeout(updatePreview, 300); setTimeout(updatePreview, 300);
@ -81,6 +81,13 @@ eventer(messageEvent,function(e) {
} }
},false); },false);
var postError = function(data) {
console.log(Object.keys(data));
var testDoc = document.createElement("div");
$(testDoc)
.html("<div class='row'><div class='col-xs-1 text-center'><i class='ion-close-circled big-error-icon'></i></div><div class='col-xs-11 test-output wrappable'>" + data + "</div></div><div class='ten-pixel-break'/>")
.prependTo($('#testSuite'))
};
var challengeSeed = challengeSeed || null; var challengeSeed = challengeSeed || null;
var tests = tests || []; var tests = tests || [];
var allSeeds = ''; var allSeeds = '';

View File

@ -1,14 +1,19 @@
(function() { (function() {
var allTestsGood = true; var allTestsGood = true;
var expect = chai.expect; var expect = chai.expect;
var tests = parent.tests;
try { for (var i = 0; i < tests.length; i++) {
eval(parent.allTests);
} catch (err) { try {
allTestsGood = false; eval(tests[i]);
} finally { } catch (err) {
if (allTestsGood) { parent.postError(err);
parent.postMessage('CompleteAwesomeSauce', parent.nodeEnv); allTestsGood = false;
} finally {
if (allTestsGood) {
parent.postMessage('CompleteAwesomeSauce', parent.nodeEnv);
}
} }
} }
})(); })();

View File

@ -256,7 +256,7 @@
" color: blue;", " color: blue;",
" }", " }",
"</style>", "</style>",
"<h1 class=\"red-text\">hello world</h1>", "<h1 class=\"blue-text\">hello world</h1>",
"<h2>cat photo app</h2>", "<h2>cat photo app</h2>",
"<p>lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>" "<p>lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>"
], ],
@ -534,7 +534,7 @@
{ {
"_id" : "bad87fee1348bd9acdf08812", "_id" : "bad87fee1348bd9acdf08812",
"name": "Specify an Image Size TEST", "name": "Specify an Image Size",
"difficulty" : "0.19", "difficulty" : "0.19",
"description": [ "description": [
"Create a class called <code>narrow-image</code> and use it to resize the image so that it's only 200 pixels wide", "Create a class called <code>narrow-image</code> and use it to resize the image so that it's only 200 pixels wide",
@ -544,7 +544,7 @@
], ],
"tests": [ "tests": [
"expect($('img')).to.have.class('narrow-image');", "expect($('img')).to.have.class('narrow-image');",
"expect($('img')).to.have.css('width', 200px)" "expect($('img')).to.have.css('width', '200px')"
], ],
"challengeSeed": [ "challengeSeed": [
"<style>", "<style>",
@ -575,13 +575,13 @@
], ],
"tests": [ "tests": [
"expect($('img')).to.have.class('thick-green-border');", "expect($('img')).to.have.class('thick-green-border');",
"expect($('img')).to.have.css('border-color', 'rgb(0,255,0)'));", "expect($('img')).to.have.css('border-color', 'rgb(0,255,0)');",
"expect($('img')).to.have.css('border-width', '10px');" "expect($('img')).to.have.css('border-width', '10px');"
], ],
"challengeSeed": [ "challengeSeed": [
"<style>", "<style>",
" .narrow-image {", " .narrow-image {",
" width: 400px;", " width: 200px;",
" }", " }",
"", "",
" .thin-red-border {", " .thin-red-border {",

View File

@ -39,6 +39,10 @@ block content
button#less-info.btn.btn-info button#less-info.btn.btn-info
span.ion-help-circled span.ion-help-circled
| Less information | Less information
br
ul#testSuite.list-group
br
script(src='/js/lib/coursewares/coursewaresHCJQFramework_v0.1.1.js')
- if (cc) - if (cc)
a.btn.btn-primary.btn-lg.btn-block#next-courseware-button a.btn.btn-primary.btn-lg.btn-block#next-courseware-button
| Go to my next challenge | Go to my next challenge
@ -52,13 +56,7 @@ block content
script. script.
var userLoggedIn = false; var userLoggedIn = false;
div.hidden div.hidden
#submitButton.btn.btn-primary.btn-big.btn-block Run code (ctrl + enter)
br
form.code
.form-group.codeMirrorView
textarea#codeOutput
br
#testSuite
br br
script(type="text/javascript"). script(type="text/javascript").
$('#next-courseware-button').attr('disabled', 'disabled'); $('#next-courseware-button').attr('disabled', 'disabled');