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
77175872
Commit
77175872
authored
Aug 08, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some of the CMS jasmine tests.
* still a few that I haven't tracked down...
parent
80b8529f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
15 deletions
+28
-15
cms/static/coffee/spec/main_spec.coffee
+1
-1
cms/static/coffee/spec/models/module_spec.coffee
+16
-4
cms/static/coffee/spec/views/module_edit_spec.coffee
+6
-6
cms/static/coffee/spec/views/module_spec.coffee
+2
-2
cms/static/coffee/spec/views/week_spec.coffee
+1
-1
cms/static/coffee/src/models/module.coffee
+2
-1
No files found.
cms/static/coffee/spec/main_spec.coffee
View file @
77175872
...
@@ -2,7 +2,7 @@ describe "CMS", ->
...
@@ -2,7 +2,7 @@ describe "CMS", ->
beforeEach
->
beforeEach
->
CMS
.
unbind
()
CMS
.
unbind
()
it
"should ini
it
alize Models"
,
->
it
"should ini
ti
alize Models"
,
->
expect
(
CMS
.
Models
).
toBeDefined
()
expect
(
CMS
.
Models
).
toBeDefined
()
it
"should initialize Views"
,
->
it
"should initialize Views"
,
->
...
...
cms/static/coffee/spec/models/module_spec.coffee
View file @
77175872
...
@@ -11,14 +11,25 @@ describe "CMS.Models.Module", ->
...
@@ -11,14 +11,25 @@ describe "CMS.Models.Module", ->
@
fakeModule
=
jasmine
.
createSpy
(
"fakeModuleObject"
)
@
fakeModule
=
jasmine
.
createSpy
(
"fakeModuleObject"
)
window
.
FakeModule
=
jasmine
.
createSpy
(
"FakeModule"
).
andReturn
(
@
fakeModule
)
window
.
FakeModule
=
jasmine
.
createSpy
(
"FakeModule"
).
andReturn
(
@
fakeModule
)
@
module
=
new
CMS
.
Models
.
Module
(
type
:
"FakeModule"
)
@
module
=
new
CMS
.
Models
.
Module
(
type
:
"FakeModule"
)
@
stubElement
=
$
(
"<div>"
)
@
stubDiv
=
$
(
'<div />'
)
@
module
.
loadModule
(
@
stubElement
)
@
stubElement
=
$
(
'<div class="xmodule_edit" />'
)
@
stubElement
.
data
(
'type'
,
"FakeModule"
)
@
stubDiv
.
append
(
@
stubElement
)
@
module
.
loadModule
(
@
stubDiv
)
afterEach
->
afterEach
->
window
.
FakeModule
=
undefined
window
.
FakeModule
=
undefined
it
"initialize the module"
,
->
it
"initialize the module"
,
->
expect
(
window
.
FakeModule
).
toHaveBeenCalledWith
(
@
stubElement
)
expect
(
window
.
FakeModule
).
toHaveBeenCalled
()
# Need to compare underlying nodes, because jquery selectors
# aren't equal even when they point to the same node.
# http://stackoverflow.com/questions/9505437/how-to-test-jquery-with-jasmine-for-element-id-if-used-as-this
expectedNode
=
@
stubElement
[
0
]
actualNode
=
window
.
FakeModule
.
mostRecentCall
.
args
[
0
][
0
]
expect
(
actualNode
).
toEqual
(
expectedNode
)
expect
(
@
module
.
module
).
toEqual
(
@
fakeModule
)
expect
(
@
module
.
module
).
toEqual
(
@
fakeModule
)
describe
"when the module does not exists"
,
->
describe
"when the module does not exists"
,
->
...
@@ -32,7 +43,8 @@ describe "CMS.Models.Module", ->
...
@@ -32,7 +43,8 @@ describe "CMS.Models.Module", ->
window
.
console
=
@
previousConsole
window
.
console
=
@
previousConsole
it
"print out error to log"
,
->
it
"print out error to log"
,
->
expect
(
window
.
console
.
error
).
toHaveBeenCalledWith
(
"Unable to load HTML."
)
expect
(
window
.
console
.
error
).
toHaveBeenCalled
()
expect
(
window
.
console
.
error
.
mostRecentCall
.
args
[
0
]).
toMatch
(
"^Unable to load"
)
describe
"editUrl"
,
->
describe
"editUrl"
,
->
...
...
cms/static/coffee/spec/views/module_edit_spec.coffee
View file @
77175872
...
@@ -8,11 +8,11 @@ describe "CMS.Views.ModuleEdit", ->
...
@@ -8,11 +8,11 @@ describe "CMS.Views.ModuleEdit", ->
<a href="#" class="cancel">cancel</a>
<a href="#" class="cancel">cancel</a>
<ol>
<ol>
<li>
<li>
<a href="#" class="module-edit" data-id="i4x://mitx
.edu/course
/module" data-type="html">submodule</a>
<a href="#" class="module-edit" data-id="i4x://mitx
/course/html
/module" data-type="html">submodule</a>
</li>
</li>
</ol>
</ol>
</div>
</div>
"""
"""
#"
CMS
.
unbind
()
CMS
.
unbind
()
describe
"defaults"
,
->
describe
"defaults"
,
->
...
@@ -27,7 +27,7 @@ describe "CMS.Views.ModuleEdit", ->
...
@@ -27,7 +27,7 @@ describe "CMS.Views.ModuleEdit", ->
@
stubModule
.
editUrl
.
andReturn
(
"/edit_item?id=stub_module"
)
@
stubModule
.
editUrl
.
andReturn
(
"/edit_item?id=stub_module"
)
new
CMS
.
Views
.
ModuleEdit
(
el
:
$
(
"#module-edit"
),
model
:
@
stubModule
)
new
CMS
.
Views
.
ModuleEdit
(
el
:
$
(
"#module-edit"
),
model
:
@
stubModule
)
it
"load the edit
from
via ajax and pass to the model"
,
->
it
"load the edit via ajax and pass to the model"
,
->
expect
(
$
.
fn
.
load
).
toHaveBeenCalledWith
(
"/edit_item?id=stub_module"
,
jasmine
.
any
(
Function
))
expect
(
$
.
fn
.
load
).
toHaveBeenCalledWith
(
"/edit_item?id=stub_module"
,
jasmine
.
any
(
Function
))
if
$
.
fn
.
load
.
mostRecentCall
if
$
.
fn
.
load
.
mostRecentCall
$
.
fn
.
load
.
mostRecentCall
.
args
[
1
]()
$
.
fn
.
load
.
mostRecentCall
.
args
[
1
]()
...
@@ -37,9 +37,9 @@ describe "CMS.Views.ModuleEdit", ->
...
@@ -37,9 +37,9 @@ describe "CMS.Views.ModuleEdit", ->
beforeEach
->
beforeEach
->
@
stubJqXHR
=
jasmine
.
createSpy
(
"stubJqXHR"
)
@
stubJqXHR
=
jasmine
.
createSpy
(
"stubJqXHR"
)
@
stubJqXHR
.
success
=
jasmine
.
createSpy
(
"stubJqXHR.success"
).
andReturn
(
@
stubJqXHR
)
@
stubJqXHR
.
success
=
jasmine
.
createSpy
(
"stubJqXHR.success"
).
andReturn
(
@
stubJqXHR
)
@
stubJqXHR
.
error
=
jasmine
.
createSpy
(
"stubJqXHR.success
"
).
andReturn
(
@
stubJqXHR
)
@
stubJqXHR
.
error
=
jasmine
.
createSpy
(
"stubJqXHR.error
"
).
andReturn
(
@
stubJqXHR
)
@
stubModule
.
save
=
jasmine
.
createSpy
(
"stubModule.save"
).
andReturn
(
@
stubJqXHR
)
@
stubModule
.
save
=
jasmine
.
createSpy
(
"stubModule.save"
).
andReturn
(
@
stubJqXHR
)
new
CMS
.
Views
.
ModuleEdit
(
el
:
$
(
"
#
module-edit"
),
model
:
@
stubModule
)
new
CMS
.
Views
.
ModuleEdit
(
el
:
$
(
"
.
module-edit"
),
model
:
@
stubModule
)
spyOn
(
window
,
"alert"
)
spyOn
(
window
,
"alert"
)
$
(
".save-update"
).
click
()
$
(
".save-update"
).
click
()
...
@@ -77,5 +77,5 @@ describe "CMS.Views.ModuleEdit", ->
...
@@ -77,5 +77,5 @@ describe "CMS.Views.ModuleEdit", ->
expect
(
CMS
.
pushView
).
toHaveBeenCalledWith
@
view
expect
(
CMS
.
pushView
).
toHaveBeenCalledWith
@
view
expect
(
CMS
.
Views
.
ModuleEdit
).
toHaveBeenCalledWith
model
:
@
model
expect
(
CMS
.
Views
.
ModuleEdit
).
toHaveBeenCalledWith
model
:
@
model
expect
(
CMS
.
Models
.
Module
).
toHaveBeenCalledWith
expect
(
CMS
.
Models
.
Module
).
toHaveBeenCalledWith
id
:
"i4x://mitx
.edu/course
/module"
id
:
"i4x://mitx
/course/html
/module"
type
:
"html"
type
:
"html"
cms/static/coffee/spec/views/module_spec.coffee
View file @
77175872
describe
"CMS.Views.Module"
,
->
describe
"CMS.Views.Module"
,
->
beforeEach
->
beforeEach
->
setFixtures
"""
setFixtures
"""
<div id="module" data-id="i4x://mitx
.edu/course
/module" data-type="html">
<div id="module" data-id="i4x://mitx
/course/html
/module" data-type="html">
<a href="#" class="module-edit">edit</a>
<a href="#" class="module-edit">edit</a>
</div>
</div>
"""
"""
...
@@ -20,5 +20,5 @@ describe "CMS.Views.Module", ->
...
@@ -20,5 +20,5 @@ describe "CMS.Views.Module", ->
expect
(
CMS
.
replaceView
).
toHaveBeenCalledWith
@
view
expect
(
CMS
.
replaceView
).
toHaveBeenCalledWith
@
view
expect
(
CMS
.
Views
.
ModuleEdit
).
toHaveBeenCalledWith
model
:
@
model
expect
(
CMS
.
Views
.
ModuleEdit
).
toHaveBeenCalledWith
model
:
@
model
expect
(
CMS
.
Models
.
Module
).
toHaveBeenCalledWith
expect
(
CMS
.
Models
.
Module
).
toHaveBeenCalledWith
id
:
"i4x://mitx
.edu/course
/module"
id
:
"i4x://mitx
/course/html
/module"
type
:
"html"
type
:
"html"
cms/static/coffee/spec/views/week_spec.coffee
View file @
77175872
describe
"CMS.Views.Week"
,
->
describe
"CMS.Views.Week"
,
->
beforeEach
->
beforeEach
->
setFixtures
"""
setFixtures
"""
<div id="week" data-id="i4x://mitx
.edu/course
/week">
<div id="week" data-id="i4x://mitx
/course/chapter
/week">
<div class="editable"></div>
<div class="editable"></div>
<textarea class="editable-textarea"></textarea>
<textarea class="editable-textarea"></textarea>
<a href="#" class="week-edit" >edit</a>
<a href="#" class="week-edit" >edit</a>
...
...
cms/static/coffee/src/models/module.coffee
View file @
77175872
...
@@ -4,7 +4,8 @@ class CMS.Models.Module extends Backbone.Model
...
@@ -4,7 +4,8 @@ class CMS.Models.Module extends Backbone.Model
data
:
''
data
:
''
loadModule
:
(
element
)
->
loadModule
:
(
element
)
->
@
module
=
XModule
.
loadModule
(
$
(
element
).
find
(
'.xmodule_edit'
))
elt
=
$
(
element
).
find
(
'.xmodule_edit'
).
first
()
@
module
=
XModule
.
loadModule
(
elt
)
editUrl
:
->
editUrl
:
->
"/edit_item?
#{
$
.
param
(
id
:
@
get
(
'id'
))
}
"
"/edit_item?
#{
$
.
param
(
id
:
@
get
(
'id'
))
}
"
...
...
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