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
b11b9169
Commit
b11b9169
authored
Jul 05, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CMS.Views.Course fixed and tested
parent
a77e7fe5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
3 deletions
+88
-3
cms/static/coffee/spec/views/course_spec.coffee
+85
-0
cms/static/coffee/src/views/course.coffee
+3
-3
No files found.
cms/static/coffee/spec/views/course_spec.coffee
0 → 100644
View file @
b11b9169
describe
"CMS.Views.Course"
,
->
beforeEach
->
setFixtures
"""
<section id="main-section">
<section class="main-content"></section>
<ol id="weeks">
<li class="cal week-one" style="height: 50px"></li>
<li class="cal week-two" style="height: 100px"></li>
</ol>
</section>
"""
CMS
.
unbind
()
describe
"render"
,
->
beforeEach
->
spyOn
(
CMS
.
Views
,
"Week"
).
andReturn
(
jasmine
.
createSpyObj
(
"Week"
,
[
"render"
]))
new
CMS
.
Views
.
Course
(
el
:
$
(
"#main-section"
)).
render
()
it
"create week view for each week"
,
->
expect
(
CMS
.
Views
.
Week
.
calls
[
0
].
args
[
0
])
.
toEqual
({
el
:
$
(
".week-one"
).
get
(
0
),
height
:
101
})
expect
(
CMS
.
Views
.
Week
.
calls
[
1
].
args
[
0
])
.
toEqual
({
el
:
$
(
".week-two"
).
get
(
0
),
height
:
101
})
describe
"on content.show"
,
->
beforeEach
->
@
view
=
new
CMS
.
Views
.
Course
(
el
:
$
(
"#main-section"
))
@
subView
=
jasmine
.
createSpyObj
(
"subView"
,
[
"render"
])
@
subView
.
render
.
andReturn
(
el
:
"Subview Content"
)
spyOn
(
@
view
,
"contentHeight"
).
andReturn
(
100
)
CMS
.
trigger
(
"content.show"
,
@
subView
)
afterEach
->
$
(
"body"
).
removeClass
(
"content"
)
it
"add content class to body"
,
->
expect
(
$
(
"body"
).
attr
(
"class"
)).
toEqual
(
"content"
)
it
"replace content in .main-content"
,
->
expect
(
$
(
".main-content"
)).
toHaveHtml
(
"Subview Content"
)
it
"set height on calendar"
,
->
expect
(
$
(
".cal"
)).
toHaveCss
(
height
:
"100px"
)
it
"set minimum height on all sections"
,
->
expect
(
$
(
"#main-section>section"
)).
toHaveCss
(
minHeight
:
"100px"
)
describe
"on content.hide"
,
->
beforeEach
->
$
(
"body"
).
addClass
(
"content"
)
@
view
=
new
CMS
.
Views
.
Course
(
el
:
$
(
"#main-section"
))
$
(
".cal"
).
css
(
height
:
100
)
$
(
"#main-section>section"
).
css
(
minHeight
:
100
)
CMS
.
trigger
(
"content.hide"
)
afterEach
->
$
(
"body"
).
removeClass
(
"content"
)
it
"remove content class from body"
,
->
expect
(
$
(
"body"
).
attr
(
"class"
)).
toEqual
(
""
)
it
"remove content from .main-content"
,
->
expect
(
$
(
".main-content"
)).
toHaveHtml
(
""
)
it
"reset height on calendar"
,
->
expect
(
$
(
".cal"
)).
not
.
toHaveCss
(
height
:
"100px"
)
it
"reset minimum height on all sections"
,
->
expect
(
$
(
"#main-section>section"
)).
not
.
toHaveCss
(
minHeight
:
"100px"
)
describe
"maxWeekHeight"
,
->
it
"return maximum height of the week element"
,
->
@
view
=
new
CMS
.
Views
.
Course
(
el
:
$
(
"#main-section"
))
expect
(
@
view
.
maxWeekHeight
()).
toEqual
(
101
)
describe
"contentHeight"
,
->
beforeEach
->
$
(
"body"
).
append
(
$
(
'<header id="test">'
).
height
(
100
).
hide
())
afterEach
->
$
(
"body>header#test"
).
remove
()
it
"return the window height minus the header bar"
,
->
@
view
=
new
CMS
.
Views
.
Course
(
el
:
$
(
"#main-section"
))
expect
(
@
view
.
contentHeight
()).
toEqual
(
$
(
window
).
height
()
-
100
)
cms/static/coffee/src/views/course.coffee
View file @
b11b9169
...
...
@@ -21,8 +21,8 @@ class CMS.Views.Course extends Backbone.View
@
$
(
'>section'
).
css
minHeight
:
''
maxWeekHeight
:
->
_
.
max
(
$
(
'#weeks > li'
).
map
->
$
(
this
).
height
())
+
1
weekElementBorderSize
=
1
_
.
max
(
$
(
'#weeks > li'
).
map
->
$
(
this
).
height
())
+
weekElementBorderSize
contentHeight
:
->
padding
=
29
$
(
window
).
height
()
-
padding
$
(
window
).
height
()
-
$
(
'body>header'
).
outerHeight
()
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