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
718ce4db
Commit
718ce4db
authored
Nov 16, 2012
by
Jay Zoldak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get Problem constructor working again, and copy the helper file from lms.
parent
bf6a147c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
12 deletions
+90
-12
common/lib/xmodule/xmodule/js/spec/capa/display_spec.coffee
+14
-4
common/lib/xmodule/xmodule/js/spec/helper.coffee
+76
-0
rakefile
+0
-8
No files found.
common/lib/xmodule/xmodule/js/spec/capa/display_spec.coffee
View file @
718ce4db
...
...
@@ -8,20 +8,30 @@ describe 'Problem', ->
MathJax
.
Hub
.
getAllJax
.
andReturn
[
@
stubbedJax
]
window
.
update_schematics
=
->
jasmine
.
getFixtures
().
fixturesPath
=
'xmodule/js/fixtures'
# load this function from spec/helper.coffee
jasmine
.
stubRequests
()
# note that the fixturesPath is set in spec/helper.coffee
loadFixtures
'problem.html'
spyOn
Logger
,
'log'
spyOn
(
$
.
fn
,
'load'
).
andCallFake
(
url
,
callback
)
->
$
(
@
).
html
readFixtures
(
'problem_content.html'
)
callback
()
jasmine
.
stubRequests
()
describe
'constructor'
,
->
beforeEach
->
@
problem
=
new
Problem
1
,
"problem_1"
,
"/problem/url/"
@
problem
=
new
Problem
(
"
<section class='xmodule_display xmodule_CapaModule' data-type='Problem'>
<section id='problem_999'
class='problems-wrapper'
data-problem-id='i4x://edX/999/problem/Quiz'
data-url='/problem/quiz/'>
</section>
</section>
"
)
it
'set the element'
,
->
expect
(
@
problem
.
el
).
toBe
'#problem_1
'
expect
(
@
problem
.
el
ement_id
).
toBe
'problem_999
'
describe
'bind'
,
->
beforeEach
->
...
...
common/lib/xmodule/xmodule/js/spec/helper.coffee
0 → 100644
View file @
718ce4db
jasmine
.
getFixtures
().
fixturesPath
=
'xmodule/js/fixtures'
jasmine
.
stubbedMetadata
=
slowerSpeedYoutubeId
:
id
:
'slowerSpeedYoutubeId'
duration
:
300
normalSpeedYoutubeId
:
id
:
'normalSpeedYoutubeId'
duration
:
200
bogus
:
duration
:
100
jasmine
.
stubbedCaption
=
start
:
[
0
,
10000
,
20000
,
30000
]
text
:
[
'Caption at 0'
,
'Caption at 10000'
,
'Caption at 20000'
,
'Caption at 30000'
]
jasmine
.
stubRequests
=
->
spyOn
(
$
,
'ajax'
).
andCallFake
(
settings
)
->
if
match
=
settings
.
url
.
match
/youtube\.com\/.+\/videos\/(.+)\?v=2&alt=jsonc/
settings
.
success
data
:
jasmine
.
stubbedMetadata
[
match
[
1
]]
else
if
match
=
settings
.
url
.
match
/static\/subs\/(.+)\.srt\.sjson/
settings
.
success
jasmine
.
stubbedCaption
else
if
settings
.
url
.
match
/.+\/problem_get$/
settings
.
success
html
:
readFixtures
(
'problem_content.html'
)
else
if
settings
.
url
==
'/calculate'
||
settings
.
url
.
match
(
/modx\/.+\/goto_position$/
)
||
settings
.
url
.
match
(
/event$/
)
||
settings
.
url
.
match
(
/modx\/.+\/problem_(check|reset|show|save)$/
)
# do nothing
else
throw
"External request attempted for
#{
settings
.
url
}
, which is not defined."
jasmine
.
stubYoutubePlayer
=
->
YT
.
Player
=
->
jasmine
.
createSpyObj
'YT.Player'
,
[
'cueVideoById'
,
'getVideoEmbedCode'
,
'getCurrentTime'
,
'getPlayerState'
,
'getVolume'
,
'setVolume'
,
'loadVideoById'
,
'playVideo'
,
'pauseVideo'
,
'seekTo'
]
jasmine
.
stubVideoPlayer
=
(
context
,
enableParts
,
createPlayer
=
true
)
->
enableParts
=
[
enableParts
]
unless
$
.
isArray
(
enableParts
)
suite
=
context
.
suite
currentPartName
=
suite
.
description
while
suite
=
suite
.
parentSuite
enableParts
.
push
currentPartName
for
part
in
[
'VideoCaption'
,
'VideoSpeedControl'
,
'VideoVolumeControl'
,
'VideoProgressSlider'
]
unless
$
.
inArray
(
part
,
enableParts
)
>=
0
spyOn
window
,
part
loadFixtures
'video.html'
jasmine
.
stubRequests
()
YT
.
Player
=
undefined
context
.
video
=
new
Video
'example'
,
'.75:slowerSpeedYoutubeId,1.0:normalSpeedYoutubeId'
jasmine
.
stubYoutubePlayer
()
if
createPlayer
return
new
VideoPlayer
(
video
:
context
.
video
)
spyOn
(
window
,
'onunload'
)
# Stub Youtube API
window
.
YT
=
PlayerState
:
UNSTARTED
:
-
1
ENDED
:
0
PLAYING
:
1
PAUSED
:
2
BUFFERING
:
3
CUED
:
5
# Stub jQuery.cookie
$
.
cookie
=
jasmine
.
createSpy
(
'jQuery.cookie'
).
andReturn
'1.0'
# Stub jQuery.qtip
$
.
fn
.
qtip
=
jasmine
.
createSpy
'jQuery.qtip'
# Stub jQuery.scrollTo
$
.
fn
.
scrollTo
=
jasmine
.
createSpy
'jQuery.scrollTo'
rakefile
View file @
718ce4db
...
...
@@ -97,14 +97,6 @@ def template_jasmine_runner(lib)
js_specs
=
Dir
[
spec_glob
].
sort_by
{
|
p
|
[
p
.
split
(
'/'
).
length
,
p
]}
.
map
{
|
f
|
File
.
expand_path
(
f
)}
js_source
=
Dir
[
src_glob
].
sort_by
{
|
p
|
[
p
.
split
(
'/'
).
length
,
p
]}
.
map
{
|
f
|
File
.
expand_path
(
f
)}
# helper file
helper_coffee
=
"
#{
REPO_ROOT
}
/lms/static/coffee/spec/helper.coffee"
if
File
.
exists?
(
helper_coffee
)
sh
(
"coffee -c
#{
helper_coffee
}
"
)
# Add the compiled helper to the beginning of the specs array
js_specs
.
unshift
(
"
#{
REPO_ROOT
}
/lms/static/coffee/spec/helper.js"
)
end
template
=
ERB
.
new
(
File
.
read
(
"
#{
lib
}
/jasmine_test_runner.html.erb"
))
template_output
=
"
#{
lib
}
/jasmine_test_runner.html"
File
.
open
(
template_output
,
'w'
)
do
|
f
|
...
...
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