Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test for StaffGradedAssignmentXBlock.save #119

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions edx_sga/static/js/spec/test_studio.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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 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 runtime = {
handlerUrl: function() {
return fakeUrl;
},
notify: function(type, state) {
notifyStates[type] = state;
}
};

var XBlock = StaffGradedAssignmentXBlock(runtime, element, server);
// Function expects this.runtime to exist
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');
});

});
});