Commit 6ae0add9 by Jay Zoldak

Fix the new problem create statements in the describe blocks for the capa display spec.

parent 718ce4db
<section id="problem_1" class="problems-wrapper" data-url="/problem/url/"></section> <section id="problem_1" class="problems-wrapper" data-url="/problem/url/"
data-problem-id="i4x://edX/101/problem/Quiz"></section>
\ No newline at end of file
<section class='xmodule_display xmodule_CapaModule' data-type='Problem'>
<section id='problem_101'
class='problems-wrapper'
data-problem-id='i4x://edX/101/problem/Problem101'
data-url='/problem/Problem101/'>
</section>
</section>
\ No newline at end of file
...@@ -13,14 +13,16 @@ describe 'Problem', -> ...@@ -13,14 +13,16 @@ describe 'Problem', ->
# note that the fixturesPath is set in spec/helper.coffee # note that the fixturesPath is set in spec/helper.coffee
loadFixtures 'problem.html' loadFixtures 'problem.html'
loadFixtures 'xmodule.html'
spyOn Logger, 'log' spyOn Logger, 'log'
spyOn($.fn, 'load').andCallFake (url, callback) -> spyOn($.fn, 'load').andCallFake (url, callback) ->
$(@).html readFixtures('problem_content.html') $(@).html readFixtures('problem_content.html')
callback() callback()
describe 'constructor', -> describe 'constructor', ->
beforeEach ->
@problem = new Problem (" it 'set the element from html', ->
@problem999 = new Problem ("
<section class='xmodule_display xmodule_CapaModule' data-type='Problem'> <section class='xmodule_display xmodule_CapaModule' data-type='Problem'>
<section id='problem_999' <section id='problem_999'
class='problems-wrapper' class='problems-wrapper'
...@@ -28,16 +30,18 @@ describe 'Problem', -> ...@@ -28,16 +30,18 @@ describe 'Problem', ->
data-url='/problem/quiz/'> data-url='/problem/quiz/'>
</section> </section>
</section> </section>
") ")
expect(@problem999.element_id).toBe 'problem_999'
it 'set the element', -> it 'set the element from loadFixtures', ->
expect(@problem.element_id).toBe 'problem_999' @problem101 = new Problem($('.xmodule_display'))
expect(@problem101.element_id).toBe 'problem_101'
describe 'bind', -> describe 'bind', ->
beforeEach -> beforeEach ->
spyOn window, 'update_schematics' spyOn window, 'update_schematics'
MathJax.Hub.getAllJax.andReturn [@stubbedJax] MathJax.Hub.getAllJax.andReturn [@stubbedJax]
@problem = new Problem 1, "problem_1", "/problem/url/" @problem = new Problem($('.xmodule_display'))
it 'set mathjax typeset', -> it 'set mathjax typeset', ->
expect(MathJax.Hub.Queue).toHaveBeenCalled() expect(MathJax.Hub.Queue).toHaveBeenCalled()
...@@ -71,7 +75,7 @@ describe 'Problem', -> ...@@ -71,7 +75,7 @@ describe 'Problem', ->
describe 'render', -> describe 'render', ->
beforeEach -> beforeEach ->
@problem = new Problem 1, "problem_1", "/problem/url/" @problem = new Problem($('.xmodule_display'))
@bind = @problem.bind @bind = @problem.bind
spyOn @problem, 'bind' spyOn @problem, 'bind'
...@@ -99,7 +103,7 @@ describe 'Problem', -> ...@@ -99,7 +103,7 @@ describe 'Problem', ->
describe 'check', -> describe 'check', ->
beforeEach -> beforeEach ->
@problem = new Problem 1, "problem_1", "/problem/url/" @problem = new Problem($('.xmodule_display'))
@problem.answers = 'foo=1&bar=2' @problem.answers = 'foo=1&bar=2'
it 'log the problem_check event', -> it 'log the problem_check event', ->
...@@ -132,7 +136,7 @@ describe 'Problem', -> ...@@ -132,7 +136,7 @@ describe 'Problem', ->
describe 'reset', -> describe 'reset', ->
beforeEach -> beforeEach ->
@problem = new Problem 1, "problem_1", "/problem/url/" @problem = new Problem($('.xmodule_display'))
it 'log the problem_reset event', -> it 'log the problem_reset event', ->
@problem.answers = 'foo=1&bar=2' @problem.answers = 'foo=1&bar=2'
...@@ -152,7 +156,7 @@ describe 'Problem', -> ...@@ -152,7 +156,7 @@ describe 'Problem', ->
describe 'show', -> describe 'show', ->
beforeEach -> beforeEach ->
@problem = new Problem 1, "problem_1", "/problem/url/" @problem = new Problem($('.xmodule_display'))
@problem.el.prepend '<div id="answer_1_1" /><div id="answer_1_2" />' @problem.el.prepend '<div id="answer_1_1" /><div id="answer_1_2" />'
describe 'when the answer has not yet shown', -> describe 'when the answer has not yet shown', ->
...@@ -231,7 +235,7 @@ describe 'Problem', -> ...@@ -231,7 +235,7 @@ describe 'Problem', ->
describe 'save', -> describe 'save', ->
beforeEach -> beforeEach ->
@problem = new Problem 1, "problem_1", "/problem/url/" @problem = new Problem($('.xmodule_display'))
@problem.answers = 'foo=1&bar=2' @problem.answers = 'foo=1&bar=2'
it 'log the problem_save event', -> it 'log the problem_save event', ->
...@@ -251,7 +255,7 @@ describe 'Problem', -> ...@@ -251,7 +255,7 @@ describe 'Problem', ->
describe 'refreshMath', -> describe 'refreshMath', ->
beforeEach -> beforeEach ->
@problem = new Problem 1, "problem_1", "/problem/url/" @problem = new Problem($('.xmodule_display'))
$('#input_example_1').val 'E=mc^2' $('#input_example_1').val 'E=mc^2'
@problem.refreshMath target: $('#input_example_1').get(0) @problem.refreshMath target: $('#input_example_1').get(0)
...@@ -261,7 +265,7 @@ describe 'Problem', -> ...@@ -261,7 +265,7 @@ describe 'Problem', ->
describe 'updateMathML', -> describe 'updateMathML', ->
beforeEach -> beforeEach ->
@problem = new Problem 1, "problem_1", "/problem/url/" @problem = new Problem($('.xmodule_display'))
@stubbedJax.root.toMathML.andReturn '<MathML>' @stubbedJax.root.toMathML.andReturn '<MathML>'
describe 'when there is no exception', -> describe 'when there is no exception', ->
...@@ -281,7 +285,7 @@ describe 'Problem', -> ...@@ -281,7 +285,7 @@ describe 'Problem', ->
describe 'refreshAnswers', -> describe 'refreshAnswers', ->
beforeEach -> beforeEach ->
@problem = new Problem 1, "problem_1", "/problem/url/" @problem = new Problem($('.xmodule_display'))
@problem.el.html ''' @problem.el.html '''
<textarea class="CodeMirror" /> <textarea class="CodeMirror" />
<input id="input_1_1" name="input_1_1" class="schematic" value="one" /> <input id="input_1_1" name="input_1_1" class="schematic" value="one" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment