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
3f0efe70
Commit
3f0efe70
authored
Jun 14, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added jasmine-stealth library, v0.0.12
parent
8227a8c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
245 additions
and
0 deletions
+245
-0
cms/static/coffee/files.json
+1
-0
common/static/js/vendor/jasmine-stealth.js
+244
-0
No files found.
cms/static/coffee/files.json
View file @
3f0efe70
...
...
@@ -12,6 +12,7 @@
"js/vendor/backbone-associations-min.js"
,
"js/vendor/jquery.leanModal.min.js"
,
"js/vendor/sinon-1.7.1.js"
,
"js/vendor/jasmine-stealth.js"
,
"js/test/i18n.js"
]
}
common/static/js/vendor/jasmine-stealth.js
0 → 100644
View file @
3f0efe70
// Generated by CoffeeScript 1.3.3
/*
jasmine-stealth 0.0.12
Makes Jasmine spies a bit more robust
site: https://github.com/searls/jasmine-stealth
*/
(
function
()
{
var
Captor
,
fake
,
root
,
unfakes
,
whatToDoWhenTheSpyGetsCalled
,
_
,
__hasProp
=
{}.
hasOwnProperty
,
__extends
=
function
(
child
,
parent
)
{
for
(
var
key
in
parent
)
{
if
(
__hasProp
.
call
(
parent
,
key
))
child
[
key
]
=
parent
[
key
];
}
function
ctor
()
{
this
.
constructor
=
child
;
}
ctor
.
prototype
=
parent
.
prototype
;
child
.
prototype
=
new
ctor
();
child
.
__super__
=
parent
.
prototype
;
return
child
;
};
root
=
this
;
_
=
function
(
obj
)
{
return
{
each
:
function
(
iterator
)
{
var
item
,
_i
,
_len
,
_results
;
_results
=
[];
for
(
_i
=
0
,
_len
=
obj
.
length
;
_i
<
_len
;
_i
++
)
{
item
=
obj
[
_i
];
_results
.
push
(
iterator
(
item
));
}
return
_results
;
},
isFunction
:
function
()
{
return
Object
.
prototype
.
toString
.
call
(
obj
)
===
"[object Function]"
;
},
isString
:
function
()
{
return
Object
.
prototype
.
toString
.
call
(
obj
)
===
"[object String]"
;
}
};
};
root
.
spyOnConstructor
=
function
(
owner
,
classToFake
,
methodsToSpy
)
{
var
fakeClass
,
spies
;
if
(
methodsToSpy
==
null
)
{
methodsToSpy
=
[];
}
if
(
_
(
methodsToSpy
).
isString
())
{
methodsToSpy
=
[
methodsToSpy
];
}
spies
=
{
constructor
:
jasmine
.
createSpy
(
""
+
classToFake
+
"'s constructor"
)
};
fakeClass
=
(
function
()
{
function
_Class
()
{
spies
.
constructor
.
apply
(
this
,
arguments
);
}
return
_Class
;
})();
_
(
methodsToSpy
).
each
(
function
(
methodName
)
{
spies
[
methodName
]
=
jasmine
.
createSpy
(
""
+
classToFake
+
"#"
+
methodName
);
return
fakeClass
.
prototype
[
methodName
]
=
function
()
{
return
spies
[
methodName
].
apply
(
this
,
arguments
);
};
});
fake
(
owner
,
classToFake
,
fakeClass
);
return
spies
;
};
unfakes
=
[];
afterEach
(
function
()
{
_
(
unfakes
).
each
(
function
(
u
)
{
return
u
();
});
return
unfakes
=
[];
});
fake
=
function
(
owner
,
thingToFake
,
newThing
)
{
var
originalThing
;
originalThing
=
owner
[
thingToFake
];
owner
[
thingToFake
]
=
newThing
;
return
unfakes
.
push
(
function
()
{
return
owner
[
thingToFake
]
=
originalThing
;
});
};
root
.
stubFor
=
root
.
spyOn
;
jasmine
.
createStub
=
jasmine
.
createSpy
;
jasmine
.
createStubObj
=
function
(
baseName
,
stubbings
)
{
var
name
,
obj
,
stubbing
;
if
(
stubbings
.
constructor
===
Array
)
{
return
jasmine
.
createSpyObj
(
baseName
,
stubbings
);
}
else
{
obj
=
{};
for
(
name
in
stubbings
)
{
stubbing
=
stubbings
[
name
];
obj
[
name
]
=
jasmine
.
createSpy
(
baseName
+
"."
+
name
);
if
(
_
(
stubbing
).
isFunction
())
{
obj
[
name
].
andCallFake
(
stubbing
);
}
else
{
obj
[
name
].
andReturn
(
stubbing
);
}
}
return
obj
;
}
};
whatToDoWhenTheSpyGetsCalled
=
function
(
spy
)
{
var
matchesStub
,
priorStubbing
;
matchesStub
=
function
(
stubbing
,
args
,
context
)
{
switch
(
stubbing
.
type
)
{
case
"args"
:
return
jasmine
.
getEnv
().
equals_
(
stubbing
.
ifThis
,
jasmine
.
util
.
argsToArray
(
args
));
case
"context"
:
return
jasmine
.
getEnv
().
equals_
(
stubbing
.
ifThis
,
context
);
}
};
priorStubbing
=
spy
.
plan
();
return
spy
.
andCallFake
(
function
()
{
var
i
,
stubbing
;
i
=
0
;
while
(
i
<
spy
.
_stealth_stubbings
.
length
)
{
stubbing
=
spy
.
_stealth_stubbings
[
i
];
if
(
matchesStub
(
stubbing
,
arguments
,
this
))
{
if
(
Object
.
prototype
.
toString
.
call
(
stubbing
.
thenThat
)
===
"[object Function]"
)
{
return
stubbing
.
thenThat
();
}
else
{
return
stubbing
.
thenThat
;
}
}
i
++
;
}
return
priorStubbing
;
});
};
jasmine
.
Spy
.
prototype
.
whenContext
=
function
(
context
)
{
var
addStubbing
,
spy
;
spy
=
this
;
spy
.
_stealth_stubbings
||
(
spy
.
_stealth_stubbings
=
[]);
whatToDoWhenTheSpyGetsCalled
(
spy
);
addStubbing
=
function
(
thenThat
)
{
spy
.
_stealth_stubbings
.
push
({
type
:
'context'
,
ifThis
:
context
,
thenThat
:
thenThat
});
return
spy
;
};
return
{
thenReturn
:
addStubbing
,
thenCallFake
:
addStubbing
};
};
jasmine
.
Spy
.
prototype
.
when
=
function
()
{
var
addStubbing
,
ifThis
,
spy
;
spy
=
this
;
ifThis
=
jasmine
.
util
.
argsToArray
(
arguments
);
spy
.
_stealth_stubbings
||
(
spy
.
_stealth_stubbings
=
[]);
whatToDoWhenTheSpyGetsCalled
(
spy
);
addStubbing
=
function
(
thenThat
)
{
spy
.
_stealth_stubbings
.
push
({
type
:
'args'
,
ifThis
:
ifThis
,
thenThat
:
thenThat
});
return
spy
;
};
return
{
thenReturn
:
addStubbing
,
thenCallFake
:
addStubbing
};
};
jasmine
.
Spy
.
prototype
.
mostRecentCallThat
=
function
(
callThat
,
context
)
{
var
i
;
i
=
this
.
calls
.
length
-
1
;
while
(
i
>=
0
)
{
if
(
callThat
.
call
(
context
||
this
,
this
.
calls
[
i
])
===
true
)
{
return
this
.
calls
[
i
];
}
i
--
;
}
};
jasmine
.
Matchers
.
ArgThat
=
(
function
(
_super
)
{
__extends
(
ArgThat
,
_super
);
function
ArgThat
(
matcher
)
{
this
.
matcher
=
matcher
;
}
ArgThat
.
prototype
.
jasmineMatches
=
function
(
actual
)
{
return
this
.
matcher
(
actual
);
};
return
ArgThat
;
})(
jasmine
.
Matchers
.
Any
);
jasmine
.
Matchers
.
ArgThat
.
prototype
.
matches
=
jasmine
.
Matchers
.
ArgThat
.
prototype
.
jasmineMatches
;
jasmine
.
argThat
=
function
(
expected
)
{
return
new
jasmine
.
Matchers
.
ArgThat
(
expected
);
};
jasmine
.
Matchers
.
Capture
=
(
function
(
_super
)
{
__extends
(
Capture
,
_super
);
function
Capture
(
captor
)
{
this
.
captor
=
captor
;
}
Capture
.
prototype
.
jasmineMatches
=
function
(
actual
)
{
this
.
captor
.
value
=
actual
;
return
true
;
};
return
Capture
;
})(
jasmine
.
Matchers
.
Any
);
jasmine
.
Matchers
.
Capture
.
prototype
.
matches
=
jasmine
.
Matchers
.
Capture
.
prototype
.
jasmineMatches
;
Captor
=
(
function
()
{
function
Captor
()
{}
Captor
.
prototype
.
capture
=
function
()
{
return
new
jasmine
.
Matchers
.
Capture
(
this
);
};
return
Captor
;
})();
jasmine
.
captor
=
function
()
{
return
new
Captor
();
};
}).
call
(
this
);
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