Commit 7f5b3634 by Will Daly Committed by Stephen Sanchez

Fixup student training JS tests

parent 48545d08
...@@ -15,8 +15,16 @@ describe("OpenAssessment.StudentTrainingView", function() { ...@@ -15,8 +15,16 @@ describe("OpenAssessment.StudentTrainingView", function() {
}; };
this.trainingAssess = function() { this.trainingAssess = function() {
return successPromise; var server = this;
return $.Deferred(function(defer) {
defer.resolveWith(server, [server.corrections]);
}).promise();
}; };
// The corrections returned by the stub server.
// Tests can update this property to control
// the behavior of the stub.
this.corrections = {};
}; };
// Stub base view // Stub base view
...@@ -53,15 +61,12 @@ describe("OpenAssessment.StudentTrainingView", function() { ...@@ -53,15 +61,12 @@ describe("OpenAssessment.StudentTrainingView", function() {
}); });
it("submits an assessment for a training example", function() { it("submits an assessment for a training example", function() {
spyOn(server, 'trainingAssess').andCallFake(function() { server.corrections = {
return $.Deferred(function(defer) { "Criterion 1": "Good",
return { "Criterion 2": "Poor",
"Criterion 1": "Good", "Criterion 3": "Fair"
"Criterion 2": "Poor", };
"Criterion 3": "Fair" spyOn(server, 'trainingAssess').andCallThrough();
};
}).promise();
});
// Select rubric options // Select rubric options
var optionsSelected = {}; var optionsSelected = {};
...@@ -78,15 +83,11 @@ describe("OpenAssessment.StudentTrainingView", function() { ...@@ -78,15 +83,11 @@ describe("OpenAssessment.StudentTrainingView", function() {
}); });
it("disable the assess button when the user submits", function() { it("disable the assess button when the user submits", function() {
spyOn(server, 'trainingAssess').andCallFake(function() { server.corrections = {
return $.Deferred(function(defer) { "Criterion 1": "Good",
return { "Criterion 2": "Poor",
"Criterion 1": "Good", "Criterion 3": "Fair"
"Criterion 2": "Poor", };
"Criterion 3": "Fair"
};
}).promise();
});
// Initially, the button should be disabled // Initially, the button should be disabled
expect(view.assessButtonEnabled()).toBe(false); expect(view.assessButtonEnabled()).toBe(false);
...@@ -109,10 +110,10 @@ describe("OpenAssessment.StudentTrainingView", function() { ...@@ -109,10 +110,10 @@ describe("OpenAssessment.StudentTrainingView", function() {
}); });
it("reloads the assessment steps when the user submits an assessment", function() { it("reloads the assessment steps when the user submits an assessment", function() {
// Simulate that the user answered the problem correctly, so there are no corrections
server.corrections = {};
spyOn(server, 'trainingAssess').andCallThrough();
spyOn(baseView, 'loadAssessmentModules').andCallThrough(); spyOn(baseView, 'loadAssessmentModules').andCallThrough();
spyOn(server, 'trainingAssess').andCallFake(function() {
return $.Deferred(function(defer){return {};}).promise();
});
// Select rubric options // Select rubric options
var optionsSelected = {}; var optionsSelected = {};
......
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