forked from jazkarta/obsolete-edx-sga
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test for StaffGradedAssignmentXBlock.save
- Loading branch information
George Schneeloch
committed
Aug 26, 2015
1 parent
27f5457
commit 61268fa
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
|
||
}); | ||
}); |