Skip to content

Commit

Permalink
Added test for StaffGradedAssignmentXBlock.save
Browse files Browse the repository at this point in the history
  • Loading branch information
George Schneeloch committed Aug 26, 2015
1 parent 27f5457 commit 61268fa
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions edx_sga/static/js/spec/test_studio.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
describe("studio.js", function() {
'use strict';
describe("StaffGradedAssignmentXBlock", function() {
beforeEach(function() {
jasmine.Ajax.install();
});

afterEach(function() {
jasmine.Ajax.uninstall();
});

it("saves the view", function() {
// Mock some arguments
var fakeUrl = "/test_url/";
var runtime = {
handlerUrl: function() {
return fakeUrl;
}
};

var element = $("<div>" +
"<input type='hidden' name='one' value='1' />" +
"<input type='hidden' name='two' value='2' />" +
"<input type='hidden' name='three' value='3' /></div>");
var server = null;

var XBlock = StaffGradedAssignmentXBlock(runtime, element, server);

// Function expects this.runtime to exist
var runtime = {
notify: function(type, state) {
notifyStates[type] = state;
}
};
XBlock.save = XBlock.save.bind({runtime: runtime});

var notifyStates = {};

// Mock a response to the POST
jasmine.Ajax.stubRequest(
fakeUrl, JSON.stringify({
one: "1",
two: "2",
three: "3"
}), "POST"
).andReturn({responseText: "{}"});

// Execute the save
XBlock.save();

var request = jasmine.Ajax.requests.mostRecent();
expect(request.status).toBe(200);
expect(request.url).toBe(fakeUrl);
expect(notifyStates.save.state).toBe('end');
});

});
});

0 comments on commit 61268fa

Please sign in to comment.