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
d6c033d6
Commit
d6c033d6
authored
Jul 05, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
main.coffee/CMS module tested
parent
f60af340
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
1 deletions
+99
-1
cms/static/coffee/spec/helpers.coffee
+9
-0
cms/static/coffee/spec/main_spec.coffee
+89
-0
cms/static/coffee/src/main.coffee
+1
-1
No files found.
cms/static/coffee/spec/helpers.coffee
0 → 100644
View file @
d6c033d6
# Stub jQuery.cookie
@
stubCookies
=
csrftoken
:
'stubCSRFToken'
jQuery
.
cookie
=
(
key
,
value
)
=>
if
value
?
@
stubCookies
[
key
]
=
value
else
@
stubCookies
[
key
]
cms/static/coffee/spec/main_spec.coffee
0 → 100644
View file @
d6c033d6
describe
"CMS"
,
->
beforeEach
->
CMS
.
unbind
()
it
"should iniitalize Models"
,
->
expect
(
CMS
.
Models
).
toBeDefined
()
it
"should initialize Views"
,
->
expect
(
CMS
.
Views
).
toBeDefined
()
describe
"start"
,
->
beforeEach
->
spyOn
(
CMS
.
Views
,
'Course'
).
andReturn
(
jasmine
.
createSpyObj
(
"Course"
,
[
"render"
]))
CMS
.
start
()
it
"create the Course"
,
->
expect
(
CMS
.
Views
.
Course
).
toHaveBeenCalled
()
expect
(
CMS
.
Views
.
Course
().
render
).
toHaveBeenCalled
()
describe
"view stack"
,
->
beforeEach
->
@
currentView
=
jasmine
.
createSpy
(
"currentView"
)
CMS
.
viewStack
=
[
@
currentView
]
describe
"replaceView"
,
->
beforeEach
->
@
newView
=
jasmine
.
createSpy
(
"newView"
)
CMS
.
on
"content.show"
,
(
@
expectedView
)
=>
CMS
.
replaceView
(
@
newView
)
it
"replace the views on the viewStack"
,
->
expect
(
CMS
.
viewStack
).
toEqual
([
@
newView
])
it
"trigger content.show on CMS"
,
->
expect
(
@
expectedView
).
toEqual
(
@
newView
)
describe
"pushView"
,
->
beforeEach
->
@
newView
=
jasmine
.
createSpy
(
"newView"
)
CMS
.
on
"content.show"
,
(
@
expectedView
)
=>
CMS
.
pushView
(
@
newView
)
it
"push new view onto viewStack"
,
->
expect
(
CMS
.
viewStack
).
toEqual
([
@
currentView
,
@
newView
])
it
"trigger content.show on CMS"
,
->
expect
(
@
expectedView
).
toEqual
(
@
newView
)
describe
"popView"
,
->
it
"remove the current view from the viewStack"
,
->
CMS
.
popView
()
expect
(
CMS
.
viewStack
).
toEqual
([])
describe
"when there's no view on the viewStack"
,
->
beforeEach
->
CMS
.
viewStack
=
[
@
currentView
]
CMS
.
on
"content.hide"
,
=>
@
eventTriggered
=
true
CMS
.
popView
()
it
"trigger content.hide on CMS"
,
->
expect
(
@
eventTriggered
).
toBeTruthy
describe
"when there's previous view on the viewStack"
,
->
beforeEach
->
@
parentView
=
jasmine
.
createSpyObj
(
"parentView"
,
[
"delegateEvents"
])
CMS
.
viewStack
=
[
@
parentView
,
@
currentView
]
CMS
.
on
"content.show"
,
(
@
expectedView
)
=>
CMS
.
popView
()
it
"trigger content.show with the previous view on CMS"
,
->
expect
(
@
expectedView
).
toEqual
@
parentView
it
"re-bind events on the view"
,
->
expect
(
@
parentView
.
delegateEvents
).
toHaveBeenCalled
()
describe
"main helper"
,
->
beforeEach
->
@
previousAjaxSettings
=
$
.
extend
(
true
,
{},
$
.
ajaxSettings
)
window
.
stubCookies
[
"csrftoken"
]
=
"stubCSRFToken"
$
(
document
).
ready
()
afterEach
->
$
.
ajaxSettings
=
@
previousAjaxSettings
it
"turn on Backbone emulateHTTP"
,
->
expect
(
Backbone
.
emulateHTTP
).
toBeTruthy
()
it
"setup AJAX CSRF token"
,
->
expect
(
$
.
ajaxSettings
.
headers
[
'X-CSRFToken'
]).
toEqual
(
"stubCSRFToken"
)
cms/static/coffee/src/main.coffee
View file @
d6c033d6
...
...
@@ -30,6 +30,6 @@ $ ->
Backbone
.
emulateHTTP
=
true
$
.
ajaxSetup
headers
:
{
'X-CSRFToken'
:
$
.
cookie
'csrftoken'
}
headers
:
{
'X-CSRFToken'
:
$
.
cookie
'csrftoken'
}
CMS
.
start
()
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