Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
0ef923e0
Commit
0ef923e0
authored
Dec 17, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add documentation.
parent
9f91935f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
cms/static/js/spec/create_sinon.js
+21
-0
No files found.
cms/static/js/spec/create_sinon.js
View file @
0ef923e0
define
([
"sinon"
],
function
(
sinon
)
{
define
([
"sinon"
],
function
(
sinon
)
{
/* These utility methods are used by Jasmine tests to create a mock server or
* get reference to mock requests. In either case, the cleanup (restore) is done with
* an after function.
*
* This pattern is being used instead of the more common beforeEach/afterEach pattern
* because we were seeing sporadic failures in the afterEach restore call. The cause of the
* errors were that one test suite was incorrectly being linked as the parent of an unrelated
* test suite (causing both suites' afterEach methods to be called). No solution for the root
* cause has been found, but initializing sinon and cleaning it up on a method-by-method
* basis seems to work. For more details, see STUD-1040.
*/
/**
* Get a reference to the mocked server, and respond
* to all requests with the specified statusCode.
*/
var
fakeServer
=
function
(
statusCode
,
that
)
{
var
fakeServer
=
function
(
statusCode
,
that
)
{
var
server
=
sinon
.
fakeServer
.
create
();
var
server
=
sinon
.
fakeServer
.
create
();
that
.
after
(
function
()
{
that
.
after
(
function
()
{
...
@@ -8,6 +24,11 @@ define(["sinon"], function(sinon) {
...
@@ -8,6 +24,11 @@ define(["sinon"], function(sinon) {
return
server
;
return
server
;
};
};
/**
* Keep track of all requests to a fake server, and
* return a reference to the Array. This allows tests
* to respond for individual requests.
*/
var
fakeRequests
=
function
(
that
)
{
var
fakeRequests
=
function
(
that
)
{
var
requests
=
[];
var
requests
=
[];
var
xhr
=
sinon
.
useFakeXMLHttpRequest
();
var
xhr
=
sinon
.
useFakeXMLHttpRequest
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment