Commit 386029be by Julian Arni

Adding jasmine tests; code cleanup.

parent b03d9390
<section id="inputtype_${id}" class="jsinput"
data="${gradefn}"
<section id="inputtype_${id}" class="jsinput"
data="${gradefn}"
% if saved_state:
data-stored="${saved_state|x}"
% endif
......@@ -11,7 +11,7 @@
% endif
>
<div class="script_placeholder" data-src="${applet_loader}"/>
% if status == 'unsubmitted':
<div class="unanswered" id="status_${id}">
......@@ -23,8 +23,8 @@
<div class="incorrect" id="status_${id}">
% endif
<iframe name="iframe_${id}"
id="iframe_${id}"
<iframe name="iframe_${id}"
id="iframe_${id}"
sandbox="allow-scripts allow-popups allow-same-origin allow-forms allow-pointer-lock"
seamless="seamless"
frameborder="0"
......@@ -32,7 +32,7 @@
height="${height}"
width="${width}"
/>
<input type="hidden" name="input_${id}" id="input_${id}"
<input type="hidden" name="input_${id}" id="input_${id}"
waitfor=""
value="${value|h}"/>
......@@ -57,7 +57,7 @@
% if status in ['unsubmitted', 'correct', 'incorrect', 'incomplete']:
</div>
% endif
% if msg:
<span class="message">${msg|n}</span>
% endif
......
......@@ -16,8 +16,16 @@ h2 {
}
}
iframe[seamless]{
background-color: transparent;
border: 0px none transparent;
padding: 0px;
overflow: hidden;
}
.inline-error {
color: darken($error-red, 10%);
color: darken($error-red, 11%);
}
......
......@@ -142,7 +142,7 @@ class @Problem
# off @answers
check_waitfor: =>
for inp in @inputs
if ($(inp).attr("waitfor")?)
if ($(inp).is("input[waitfor]"))
try
$(inp).data("waitfor")()
catch e
......
describe("A jsinput has:", function () {
beforeEach(function () {
$('#fixture').remove();
$.ajax({
async: false,
url: 'mainfixture.html',
success: function(data) {
$('body').append($(data));
}
});
});
describe("The ctxCall function", function() {
it("Evaluatates nested-object functions", function() {
var ctxTest = {
ctxFn : function () {
return this.name ;
}
};
var fnString = "nest.ctxFn";
var holder = {};
holder.nest = ctxTest;
var fn = _ctxCall(holder, fnString);
expect(fnString).toBe(holder.nest.ctxFn());
});
it("Throws an exception when the object does not exits", function () {
var notObj = _ctxCall("twas", "brilling");
expect(notObj).toThrow();
});
it("Throws an exception when the function does not exist", function () {
var anobj = {};
var notFn = _ctxCall("anobj", "brillig");
expect(notFn).toThrow();
});
});
describe("The jsinput constructor", function(){
var testJsElem = jsinputConstructor({
id: 3781,
elem: "<div id='abc'> a div </div>",
passive: false
});
it("Returns an object", function(){
expect(typeof(testJsElem)).toEqual('object');
});
it("Adds the object to the jsinput array", function() {
expect(jsinput.jsinputarr.exists(3781)).toBe(true);
});
describe("The returned object", function() {
it("Has a public 'update' method", function(){
expect(testJsElem.update).toBeDefined();
});
it("Changes the parent's inputfield", function() {
})
});
});
}
)
describe("jsinput test", function () {
beforeEach(function () {
$('#fixture').remove();
$.ajax({
async: false,
url: 'mainfixture.html',
success: function(data) {
$('body').append($(data));
}
});
});
it("")
}
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment