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
6322263c
Commit
6322263c
authored
Jan 30, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New Jasmine tests
parent
e873da76
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
7 deletions
+37
-7
common/lib/xmodule/xmodule/js/fixtures/combined-open-ended.html
+1
-1
common/lib/xmodule/xmodule/js/spec/combinedopenended/display_spec.coffee
+36
-6
No files found.
common/lib/xmodule/xmodule/js/fixtures/combined-open-ended.html
View file @
6322263c
<section
class=
"course-content"
>
<section
class=
"xmodule_display xmodule_CombinedOpenEndedModule"
data-type=
"CombinedOpenEnded"
>
<section
id=
"combined-open-ended"
class=
"combined-open-ended"
data-ajax-url=
"/courses/MITx/6.002x/2012_Fall/modx/i4x://MITx/6.002x/combinedopenended/CombinedOE"
data-allow_reset=
"False"
data-state=
"assessing"
data-task-count=
"2"
data-task-number=
"
2
"
>
<section
id=
"combined-open-ended"
class=
"combined-open-ended"
data-ajax-url=
"/courses/MITx/6.002x/2012_Fall/modx/i4x://MITx/6.002x/combinedopenended/CombinedOE"
data-allow_reset=
"False"
data-state=
"assessing"
data-task-count=
"2"
data-task-number=
"
1
"
>
<h2>
Problem 1
</h2>
<div
class=
"status-container"
>
...
...
common/lib/xmodule/xmodule/js/spec/combinedopenended/display_spec.coffee
View file @
6322263c
...
...
@@ -19,14 +19,11 @@ describe 'CombinedOpenEnded', ->
expect
(
@
combined
.
ajax_url
).
toEqual
'/courses/MITx/6.002x/2012_Fall/modx/i4x://MITx/6.002x/combinedopenended/CombinedOE'
expect
(
@
combined
.
state
).
toEqual
'assessing'
expect
(
@
combined
.
task_count
).
toEqual
2
expect
(
@
combined
.
task_number
).
toEqual
2
expect
(
@
combined
.
task_number
).
toEqual
1
it
'subelements are made collapsible'
,
->
expect
(
Collapsible
.
setCollapsibles
).
toHaveBeenCalled
()
it
'elements are rebound for assessing state'
,
->
expect
(
@
combined
.
answer_area
.
attr
(
"disabled"
)).
toBe
(
"disabled"
)
expect
(
@
combined
.
submit_button
.
val
()).
toBe
(
"Submit assessment"
)
describe
'poll'
,
->
beforeEach
=>
...
...
@@ -35,14 +32,14 @@ describe 'CombinedOpenEnded', ->
spyOn
(
@
combined
,
'reload'
).
andCallFake
->
return
0
window
.
setTimeout
=
jasmine
.
createSpy
().
andCallFake
(
callback
,
timeout
)
->
return
5
it
'
we are setting the timeout
'
,
=>
it
'
polls at the correct intervals
'
,
=>
fakeResponseContinue
=
state
:
'not done'
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
callback
)
->
callback
(
fakeResponseContinue
)
@
combined
.
poll
()
expect
(
window
.
setTimeout
).
toHaveBeenCalledWith
(
@
combined
.
poll
,
10000
)
expect
(
window
.
queuePollerID
).
toBe
(
5
)
it
'
we are stopping polling
properly'
,
=>
it
'
polling stops
properly'
,
=>
$
.
postWithPrefix
=
jasmine
.
createSpy
(
"$.postWithPrefix"
)
fakeResponseDone
=
state
:
"done"
$
.
postWithPrefix
.
andCallFake
(
url
,
callback
)
->
callback
(
fakeResponseDone
)
...
...
@@ -50,3 +47,36 @@ describe 'CombinedOpenEnded', ->
expect
(
window
.
queuePollerID
).
toBeUndefined
()
expect
(
window
.
setTimeout
).
not
.
toHaveBeenCalled
()
expect
(
@
combined
.
reload
).
toHaveBeenCalled
()
describe
'rebind'
,
->
beforeEach
->
@
combined
=
new
CombinedOpenEnded
@
element
spyOn
(
@
combined
,
'queueing'
).
andCallFake
->
return
0
spyOn
(
@
combined
,
'skip_post_assessment'
).
andCallFake
->
return
0
window
.
setTimeout
=
jasmine
.
createSpy
().
andCallFake
(
callback
,
timeout
)
->
return
5
it
'when our child is in an assessing state'
,
->
@
combined
.
child_state
=
'assessing'
@
combined
.
rebind
()
expect
(
@
combined
.
answer_area
.
attr
(
"disabled"
)).
toBe
(
"disabled"
)
expect
(
@
combined
.
submit_button
.
val
()).
toBe
(
"Submit assessment"
)
expect
(
@
combined
.
queueing
).
toHaveBeenCalled
()
it
'when our child state is initial'
,
->
@
combined
.
child_state
=
'initial'
@
combined
.
rebind
()
expect
(
@
combined
.
answer_area
.
attr
(
"disabled"
)).
toBeUndefined
()
expect
(
@
combined
.
submit_button
.
val
()).
toBe
(
"Submit"
)
it
'when our child state is post_assessment'
,
->
@
combined
.
child_state
=
'post_assessment'
@
combined
.
rebind
()
expect
(
@
combined
.
answer_area
.
attr
(
"disabled"
)).
toBe
(
"disabled"
)
expect
(
@
combined
.
submit_button
.
val
()).
toBe
(
"Submit post-assessment"
)
it
'when our child state is done'
,
->
spyOn
(
@
combined
,
'next_problem'
).
andCallFake
->
@
combined
.
child_state
=
'done'
@
combined
.
rebind
()
expect
(
@
combined
.
answer_area
.
attr
(
"disabled"
)).
toBe
(
"disabled"
)
expect
(
@
combined
.
next_problem
).
toHaveBeenCalled
()
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