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
a10a3209
Commit
a10a3209
authored
Nov 16, 2012
by
Jay Zoldak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix all but 4 broken tests.
parent
6ae0add9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
18 deletions
+37
-18
common/lib/xmodule/xmodule/js/fixtures/xmodule.html
+4
-3
common/lib/xmodule/xmodule/js/spec/capa/display_spec.coffee
+31
-13
common/lib/xmodule/xmodule/js/spec/helper.coffee
+2
-2
No files found.
common/lib/xmodule/xmodule/js/fixtures/xmodule.html
View file @
a10a3209
<section
class=
'xmodule_display xmodule_CapaModule'
data-type=
'Problem'
>
<section
class=
'xmodule_display xmodule_CapaModule'
data-type=
'Problem'
>
<section
id=
'problem_1
01
'
<section
id=
'problem_1'
class=
'problems-wrapper'
class=
'problems-wrapper'
data-problem-id=
'i4x://edX/101/problem/Problem1
01
'
data-problem-id=
'i4x://edX/101/problem/Problem1'
data-url=
'/problem/Problem1
01/
'
>
data-url=
'/problem/Problem1'
>
</section>
</section>
</section>
</section>
\ No newline at end of file
common/lib/xmodule/xmodule/js/spec/capa/display_spec.coffee
View file @
a10a3209
...
@@ -8,7 +8,10 @@ describe 'Problem', ->
...
@@ -8,7 +8,10 @@ describe 'Problem', ->
MathJax
.
Hub
.
getAllJax
.
andReturn
[
@
stubbedJax
]
MathJax
.
Hub
.
getAllJax
.
andReturn
[
@
stubbedJax
]
window
.
update_schematics
=
->
window
.
update_schematics
=
->
# load this function from spec/helper.coffee
# Load this function from spec/helper.coffee
# Note that if your test fails with a message like:
# 'External request attempted for blah, which is not defined.'
# this msg is coming from the stubRequests function else clause.
jasmine
.
stubRequests
()
jasmine
.
stubRequests
()
# note that the fixturesPath is set in spec/helper.coffee
# note that the fixturesPath is set in spec/helper.coffee
...
@@ -34,8 +37,8 @@ describe 'Problem', ->
...
@@ -34,8 +37,8 @@ describe 'Problem', ->
expect
(
@
problem999
.
element_id
).
toBe
'problem_999'
expect
(
@
problem999
.
element_id
).
toBe
'problem_999'
it
'set the element from loadFixtures'
,
->
it
'set the element from loadFixtures'
,
->
@
problem1
01
=
new
Problem
(
$
(
'.xmodule_display'
))
@
problem1
=
new
Problem
(
$
(
'.xmodule_display'
))
expect
(
@
problem1
01
.
element_id
).
toBe
'problem_10
1'
expect
(
@
problem1
.
element_id
).
toBe
'problem_
1'
describe
'bind'
,
->
describe
'bind'
,
->
beforeEach
->
beforeEach
->
...
@@ -53,7 +56,7 @@ describe 'Problem', ->
...
@@ -53,7 +56,7 @@ describe 'Problem', ->
expect
(
$
(
'section.action input:button'
)).
toHandleWith
'click'
,
@
problem
.
refreshAnswers
expect
(
$
(
'section.action input:button'
)).
toHandleWith
'click'
,
@
problem
.
refreshAnswers
it
'bind the check button'
,
->
it
'bind the check button'
,
->
expect
(
$
(
'section.action input.check'
)).
toHandleWith
'click'
,
@
problem
.
check
expect
(
$
(
'section.action input.check'
)).
toHandleWith
'click'
,
@
problem
.
check
_fd
it
'bind the reset button'
,
->
it
'bind the reset button'
,
->
expect
(
$
(
'section.action input.reset'
)).
toHandleWith
'click'
,
@
problem
.
reset
expect
(
$
(
'section.action input.reset'
)).
toHandleWith
'click'
,
@
problem
.
reset
...
@@ -101,6 +104,10 @@ describe 'Problem', ->
...
@@ -101,6 +104,10 @@ describe 'Problem', ->
it
're-bind the content'
,
->
it
're-bind the content'
,
->
expect
(
@
problem
.
bind
).
toHaveBeenCalled
()
expect
(
@
problem
.
bind
).
toHaveBeenCalled
()
describe
'check_fd'
,
->
xit
'should have specs written for this functionality'
,
->
expect
(
false
)
describe
'check'
,
->
describe
'check'
,
->
beforeEach
->
beforeEach
->
@
problem
=
new
Problem
(
$
(
'.xmodule_display'
))
@
problem
=
new
Problem
(
$
(
'.xmodule_display'
))
...
@@ -113,24 +120,28 @@ describe 'Problem', ->
...
@@ -113,24 +120,28 @@ describe 'Problem', ->
it
'submit the answer for check'
,
->
it
'submit the answer for check'
,
->
spyOn
$
,
'postWithPrefix'
spyOn
$
,
'postWithPrefix'
@
problem
.
check
()
@
problem
.
check
()
expect
(
$
.
postWithPrefix
).
toHaveBeenCalledWith
'/modx/1/problem_check'
,
'foo=1&bar=2'
,
jasmine
.
any
(
Function
)
expect
(
$
.
postWithPrefix
).
toHaveBeenCalledWith
'/problem/Problem1/problem_check'
,
'foo=1&bar=2'
,
jasmine
.
any
(
Function
)
describe
'when the response is correct'
,
->
describe
'when the response is correct'
,
->
it
'call render with returned content'
,
->
it
'call render with returned content'
,
->
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
answers
,
callback
)
->
callback
(
success
:
'correct'
,
contents
:
'Correct!'
)
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
answers
,
callback
)
->
callback
(
success
:
'correct'
,
contents
:
'Correct!'
)
@
problem
.
check
()
@
problem
.
check
()
expect
(
@
problem
.
el
.
html
()).
toEqual
'Correct!'
expect
(
@
problem
.
el
.
html
()).
toEqual
'Correct!'
describe
'when the response is incorrect'
,
->
describe
'when the response is incorrect'
,
->
it
'call render with returned content'
,
->
it
'call render with returned content'
,
->
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
answers
,
callback
)
->
callback
(
success
:
'incorrect'
,
contents
:
'Correct!'
)
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
answers
,
callback
)
->
callback
(
success
:
'incorrect'
,
contents
:
'Incorrect!'
)
@
problem
.
check
()
@
problem
.
check
()
expect
(
@
problem
.
el
.
html
()).
toEqual
'
C
orrect!'
expect
(
@
problem
.
el
.
html
()).
toEqual
'
Inc
orrect!'
describe
'when the response is undetermined'
,
->
describe
'when the response is undetermined'
,
->
it
'alert the response'
,
->
it
'alert the response'
,
->
spyOn
window
,
'alert'
spyOn
window
,
'alert'
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
answers
,
callback
)
->
callback
(
success
:
'Number Only!'
)
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
answers
,
callback
)
->
callback
(
success
:
'Number Only!'
)
@
problem
.
check
()
@
problem
.
check
()
expect
(
window
.
alert
).
toHaveBeenCalledWith
'Number Only!'
expect
(
window
.
alert
).
toHaveBeenCalledWith
'Number Only!'
...
@@ -146,7 +157,8 @@ describe 'Problem', ->
...
@@ -146,7 +157,8 @@ describe 'Problem', ->
it
'POST to the problem reset page'
,
->
it
'POST to the problem reset page'
,
->
spyOn
$
,
'postWithPrefix'
spyOn
$
,
'postWithPrefix'
@
problem
.
reset
()
@
problem
.
reset
()
expect
(
$
.
postWithPrefix
).
toHaveBeenCalledWith
'/modx/1/problem_reset'
,
{
id
:
1
},
jasmine
.
any
(
Function
)
expect
(
$
.
postWithPrefix
).
toHaveBeenCalledWith
'/problem/Problem1/problem_reset'
,
{
id
:
'i4x://edX/101/problem/Problem1'
},
jasmine
.
any
(
Function
)
it
'render the returned content'
,
->
it
'render the returned content'
,
->
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
answers
,
callback
)
->
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
answers
,
callback
)
->
...
@@ -165,12 +177,14 @@ describe 'Problem', ->
...
@@ -165,12 +177,14 @@ describe 'Problem', ->
it
'log the problem_show event'
,
->
it
'log the problem_show event'
,
->
@
problem
.
show
()
@
problem
.
show
()
expect
(
Logger
.
log
).
toHaveBeenCalledWith
'problem_show'
,
problem
:
1
expect
(
Logger
.
log
).
toHaveBeenCalledWith
'problem_show'
,
problem
:
'i4x://edX/101/problem/Problem1'
it
'fetch the answers'
,
->
it
'fetch the answers'
,
->
spyOn
$
,
'postWithPrefix'
spyOn
$
,
'postWithPrefix'
@
problem
.
show
()
@
problem
.
show
()
expect
(
$
.
postWithPrefix
).
toHaveBeenCalledWith
'/modx/1/problem_show'
,
jasmine
.
any
(
Function
)
expect
(
$
.
postWithPrefix
).
toHaveBeenCalledWith
'/problem/Problem1/problem_show'
,
jasmine
.
any
(
Function
)
it
'show the answers'
,
->
it
'show the answers'
,
->
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
callback
)
->
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
callback
)
->
...
@@ -245,7 +259,8 @@ describe 'Problem', ->
...
@@ -245,7 +259,8 @@ describe 'Problem', ->
it
'POST to save problem'
,
->
it
'POST to save problem'
,
->
spyOn
$
,
'postWithPrefix'
spyOn
$
,
'postWithPrefix'
@
problem
.
save
()
@
problem
.
save
()
expect
(
$
.
postWithPrefix
).
toHaveBeenCalledWith
'/modx/1/problem_save'
,
'foo=1&bar=2'
,
jasmine
.
any
(
Function
)
expect
(
$
.
postWithPrefix
).
toHaveBeenCalledWith
'/problem/Problem1/problem_save'
,
'foo=1&bar=2'
,
jasmine
.
any
(
Function
)
it
'alert to the user'
,
->
it
'alert to the user'
,
->
spyOn
window
,
'alert'
spyOn
window
,
'alert'
...
@@ -308,3 +323,6 @@ describe 'Problem', ->
...
@@ -308,3 +323,6 @@ describe 'Problem', ->
it
'serialize all answers'
,
->
it
'serialize all answers'
,
->
@
problem
.
refreshAnswers
()
@
problem
.
refreshAnswers
()
expect
(
@
problem
.
answers
).
toEqual
"input_1_1=one&input_1_2=two"
expect
(
@
problem
.
answers
).
toEqual
"input_1_1=one&input_1_2=two"
common/lib/xmodule/xmodule/js/spec/helper.coffee
View file @
a10a3209
...
@@ -23,9 +23,9 @@ jasmine.stubRequests = ->
...
@@ -23,9 +23,9 @@ jasmine.stubRequests = ->
else
if
settings
.
url
.
match
/.+\/problem_get$/
else
if
settings
.
url
.
match
/.+\/problem_get$/
settings
.
success
html
:
readFixtures
(
'problem_content.html'
)
settings
.
success
html
:
readFixtures
(
'problem_content.html'
)
else
if
settings
.
url
==
'/calculate'
||
else
if
settings
.
url
==
'/calculate'
||
settings
.
url
.
match
(
/
modx\/
.+\/goto_position$/
)
||
settings
.
url
.
match
(
/.+\/goto_position$/
)
||
settings
.
url
.
match
(
/event$/
)
||
settings
.
url
.
match
(
/event$/
)
||
settings
.
url
.
match
(
/
modx\/
.+\/problem_(check|reset|show|save)$/
)
settings
.
url
.
match
(
/.+\/problem_(check|reset|show|save)$/
)
# do nothing
# do nothing
else
else
throw
"External request attempted for
#{
settings
.
url
}
, which is not defined."
throw
"External request attempted for
#{
settings
.
url
}
, which is not defined."
...
...
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