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
8e7bf4c1
Commit
8e7bf4c1
authored
May 10, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broken test case
parent
afde79da
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
257 additions
and
186 deletions
+257
-186
static/coffee/files.json
+2
-1
static/coffee/spec/courseware_spec.coffee
+41
-72
static/coffee/spec/courseware_spec.js
+36
-84
static/coffee/spec/feedback_form_spec.coffee
+2
-2
static/coffee/spec/feedback_form_spec.js
+2
-2
static/coffee/src/calculator.coffee
+1
-1
static/coffee/src/courseware.coffee
+2
-2
static/coffee/src/feedback_form.coffee
+1
-1
templates/coffee/spec/navigation_spec.coffee
+74
-0
templates/coffee/spec/navigation_spec.js
+94
-0
templates/coffee/src/courseware_navigation.coffee
+0
-19
templates/coffee/src/modules/video.coffee
+1
-1
templates/coffee/src/navigation.coffee
+1
-1
No files found.
static/coffee/files.json
View file @
8e7bf4c1
...
...
@@ -2,7 +2,8 @@
"js_files"
:
[
"/static/js/jquery-1.6.2.min.js"
,
"/static/js/jquery-ui-1.8.16.custom.min.js"
,
"/static/js/jquery.leanModal.js"
"/static/js/jquery.leanModal.js"
,
"/static/js/jquery.cookie.js"
],
"static_files"
:
[
"js/application.js"
...
...
static/coffee/spec/courseware_spec.coffee
View file @
8e7bf4c1
describe
'Courseware'
,
->
describe
'bind'
,
->
it
'bind the navigation'
,
->
spyOn
Courseware
.
Navigation
,
'bind'
Courseware
.
bind
()
expect
(
Courseware
.
Navigation
.
bind
).
toHaveBeenCalled
()
describe
'start'
,
->
it
'create the navigation'
,
->
spyOn
(
window
,
'Navigation'
)
Courseware
.
start
()
expect
(
window
.
Navigation
).
toHaveBeenCalled
()
it
'create the calculator'
,
->
spyOn
(
window
,
'Calculator'
)
Courseware
.
start
()
expect
(
window
.
Calculator
).
toHaveBeenCalled
()
it
'creates the FeedbackForm'
,
->
spyOn
(
window
,
'FeedbackForm'
)
Courseware
.
start
()
expect
(
window
.
FeedbackForm
).
toHaveBeenCalled
()
it
'binds the Logger'
,
->
spyOn
(
Logger
,
'bind'
)
Courseware
.
start
()
expect
(
Logger
.
bind
).
toHaveBeenCalled
()
describe
'
Navigation
'
,
->
describe
'
bind
'
,
->
beforeEach
->
loadFixtures
'accordion.html'
@
navigation
=
new
Courseware
.
Navigation
describe
'bind'
,
->
describe
'when the #accordion exists'
,
->
describe
'when there is an active section'
,
->
it
'activate the accordion with correct active section'
,
->
spyOn
$
.
fn
,
'accordion'
$
(
'#accordion'
).
append
(
'<ul><li></li></ul><ul><li class="active"></li></ul>'
)
Courseware
.
Navigation
.
bind
()
expect
(
$
(
'#accordion'
).
accordion
).
toHaveBeenCalledWith
active
:
1
header
:
'h3'
autoHeight
:
false
describe
'when there is no active section'
,
->
it
'activate the accordian with section 1 as active'
,
->
spyOn
$
.
fn
,
'accordion'
$
(
'#accordion'
).
append
(
'<ul><li></li></ul><ul><li></li></ul>'
)
Courseware
.
Navigation
.
bind
()
expect
(
$
(
'#accordion'
).
accordion
).
toHaveBeenCalledWith
active
:
1
header
:
'h3'
autoHeight
:
false
it
'binds the accordionchange event'
,
->
Courseware
.
Navigation
.
bind
()
expect
(
$
(
'#accordion'
)).
toHandleWith
'accordionchange'
,
@
navigation
.
log
it
'bind the navigation toggle'
,
->
Courseware
.
Navigation
.
bind
()
expect
(
$
(
'#open_close_accordion a'
)).
toHandleWith
'click'
,
@
navigation
.
toggle
describe
'when the #accordion does not exists'
,
->
beforeEach
->
$
(
'#accordion'
).
remove
()
@
courseware
=
new
Courseware
setFixtures
"""<div id="seq_content"></div>"""
it
'does not activate the accordion'
,
->
spyOn
$
.
fn
,
'accordion'
Courseware
.
Navigation
.
bind
()
expect
(
$
(
'#accordion'
).
accordion
).
wasNotCalled
()
it
'binds the sequential content change event'
,
->
@
courseware
.
bind
()
expect
(
$
(
'#seq_content'
)).
toHandleWith
'change'
,
@
courseware
.
render
describe
'toggle'
,
->
it
'toggle closed class on the wrapper'
,
->
$
(
'.course-wrapper'
).
removeClass
(
'closed'
)
@
navigation
.
toggle
()
expect
(
$
(
'.course-wrapper'
)).
toHaveClass
(
'closed'
)
@
navigation
.
toggle
()
expect
(
$
(
'.course-wrapper'
)).
not
.
toHaveClass
(
'closed'
)
describe
'log'
,
->
beforeEach
->
window
.
log_event
=
->
spyOn
window
,
'log_event'
it
'submit event log'
,
->
@
navigation
.
log
{},
{
newHeader
:
text
:
->
"new"
oldHeader
:
text
:
->
"old"
}
expect
(
window
.
log_event
).
toHaveBeenCalledWith
'accordion'
,
newheader
:
'new'
oldheader
:
'old'
describe
'render'
,
->
beforeEach
->
@
courseware
=
new
Courseware
setFixtures
"""
<div class="course-content">
<div id="video_1" class="video" data-streams="1.0:abc1234"></div>
<div id="video_2" class="video" data-streams="1.0:def5678"></div>
</div>
"""
it
'detect the video element and convert them'
,
->
spyOn
(
window
,
'Video'
)
@
courseware
.
render
()
expect
(
window
.
Video
).
toHaveBeenCalledWith
(
'1'
,
'1.0:abc1234'
)
expect
(
window
.
Video
).
toHaveBeenCalledWith
(
'2'
,
'1.0:def5678'
)
static/coffee/spec/courseware_spec.js
View file @
8e7bf4c1
(
function
()
{
describe
(
'Courseware'
,
function
()
{
describe
(
'bind'
,
function
()
{
return
it
(
'bind the navigation'
,
function
()
{
spyOn
(
Courseware
.
Navigation
,
'bind'
);
Courseware
.
bind
();
return
expect
(
Courseware
.
Navigation
.
bind
).
toHaveBeenCalled
();
describe
(
'start'
,
function
()
{
it
(
'create the navigation'
,
function
()
{
spyOn
(
window
,
'Navigation'
);
Courseware
.
start
();
return
expect
(
window
.
Navigation
).
toHaveBeenCalled
();
});
it
(
'create the calculator'
,
function
()
{
spyOn
(
window
,
'Calculator'
);
Courseware
.
start
();
return
expect
(
window
.
Calculator
).
toHaveBeenCalled
();
});
it
(
'creates the FeedbackForm'
,
function
()
{
spyOn
(
window
,
'FeedbackForm'
);
Courseware
.
start
();
return
expect
(
window
.
FeedbackForm
).
toHaveBeenCalled
();
});
return
it
(
'binds the Logger'
,
function
()
{
spyOn
(
Logger
,
'bind'
);
Courseware
.
start
();
return
expect
(
Logger
.
bind
).
toHaveBeenCalled
();
});
});
return
describe
(
'Navigation
'
,
function
()
{
describe
(
'bind
'
,
function
()
{
beforeEach
(
function
()
{
loadFixtures
(
'accordion.html'
)
;
return
this
.
navigation
=
new
Courseware
.
Navigation
;
this
.
courseware
=
new
Courseware
;
return
setFixtures
(
"<div id=
\"
seq_content
\"
></div>"
)
;
});
describe
(
'bind'
,
function
()
{
describe
(
'when the #accordion exists'
,
function
()
{
describe
(
'when there is an active section'
,
function
()
{
return
it
(
'activate the accordion with correct active section'
,
function
()
{
spyOn
(
$
.
fn
,
'accordion'
);
$
(
'#accordion'
).
append
(
'<ul><li></li></ul><ul><li class="active"></li></ul>'
);
Courseware
.
Navigation
.
bind
();
return
expect
(
$
(
'#accordion'
).
accordion
).
toHaveBeenCalledWith
({
active
:
1
,
header
:
'h3'
,
autoHeight
:
false
});
});
});
describe
(
'when there is no active section'
,
function
()
{
return
it
(
'activate the accordian with section 1 as active'
,
function
()
{
spyOn
(
$
.
fn
,
'accordion'
);
$
(
'#accordion'
).
append
(
'<ul><li></li></ul><ul><li></li></ul>'
);
Courseware
.
Navigation
.
bind
();
return
expect
(
$
(
'#accordion'
).
accordion
).
toHaveBeenCalledWith
({
active
:
1
,
header
:
'h3'
,
autoHeight
:
false
});
});
});
it
(
'binds the accordionchange event'
,
function
()
{
Courseware
.
Navigation
.
bind
();
return
expect
(
$
(
'#accordion'
)).
toHandleWith
(
'accordionchange'
,
this
.
navigation
.
log
);
});
return
it
(
'bind the navigation toggle'
,
function
()
{
Courseware
.
Navigation
.
bind
();
return
expect
(
$
(
'#open_close_accordion a'
)).
toHandleWith
(
'click'
,
this
.
navigation
.
toggle
);
});
});
return
describe
(
'when the #accordion does not exists'
,
function
()
{
beforeEach
(
function
()
{
return
$
(
'#accordion'
).
remove
();
});
return
it
(
'does not activate the accordion'
,
function
()
{
spyOn
(
$
.
fn
,
'accordion'
);
Courseware
.
Navigation
.
bind
();
return
expect
(
$
(
'#accordion'
).
accordion
).
wasNotCalled
();
});
});
return
it
(
'binds the sequential content change event'
,
function
()
{
this
.
courseware
.
bind
();
return
expect
(
$
(
'#seq_content'
)).
toHandleWith
(
'change'
,
this
.
courseware
.
render
);
});
describe
(
'toggle'
,
function
()
{
return
it
(
'toggle closed class on the wrapper'
,
function
()
{
$
(
'.course-wrapper'
).
removeClass
(
'closed'
);
this
.
navigation
.
toggle
();
expect
(
$
(
'.course-wrapper'
)).
toHaveClass
(
'closed'
);
this
.
navigation
.
toggle
();
return
expect
(
$
(
'.course-wrapper'
)).
not
.
toHaveClass
(
'closed'
);
});
});
return
describe
(
'render'
,
function
()
{
beforeEach
(
function
()
{
this
.
courseware
=
new
Courseware
;
return
setFixtures
(
"<div class=
\"
course-content
\"
>
\
n <div id=
\"
video_1
\"
class=
\"
video
\"
data-streams=
\"
1.0:abc1234
\"
></div>
\
n <div id=
\"
video_2
\"
class=
\"
video
\"
data-streams=
\"
1.0:def5678
\"
></div>
\
n</div>"
);
});
return
describe
(
'log'
,
function
()
{
beforeEach
(
function
()
{
window
.
log_event
=
function
()
{};
return
spyOn
(
window
,
'log_event'
);
});
return
it
(
'submit event log'
,
function
()
{
this
.
navigation
.
log
({},
{
newHeader
:
{
text
:
function
()
{
return
"new"
;
}
},
oldHeader
:
{
text
:
function
()
{
return
"old"
;
}
}
});
return
expect
(
window
.
log_event
).
toHaveBeenCalledWith
(
'accordion'
,
{
newheader
:
'new'
,
oldheader
:
'old'
});
});
return
it
(
'detect the video element and convert them'
,
function
()
{
spyOn
(
window
,
'Video'
);
this
.
courseware
.
render
();
expect
(
window
.
Video
).
toHaveBeenCalledWith
(
'1'
,
'1.0:abc1234'
);
return
expect
(
window
.
Video
).
toHaveBeenCalledWith
(
'2'
,
'1.0:def5678'
);
});
});
});
...
...
static/coffee/spec/feedback_form_spec.coffee
View file @
8e7bf4c1
...
...
@@ -2,9 +2,9 @@ describe 'FeedbackForm', ->
beforeEach
->
loadFixtures
'feedback_form.html'
describe
'
bind
'
,
->
describe
'
constructor
'
,
->
beforeEach
->
FeedbackForm
.
bind
()
new
FeedbackForm
spyOn
(
$
,
'post'
).
andCallFake
(
url
,
data
,
callback
,
format
)
->
callback
()
...
...
static/coffee/spec/feedback_form_spec.js
View file @
8e7bf4c1
...
...
@@ -4,9 +4,9 @@
beforeEach
(
function
()
{
return
loadFixtures
(
'feedback_form.html'
);
});
return
describe
(
'
bind
'
,
function
()
{
return
describe
(
'
constructor
'
,
function
()
{
beforeEach
(
function
()
{
FeedbackForm
.
bind
()
;
new
FeedbackForm
;
return
spyOn
(
$
,
'post'
).
andCallFake
(
function
(
url
,
data
,
callback
,
format
)
{
return
callback
();
});
...
...
static/coffee/src/calculator.coffee
View file @
8e7bf4c1
class
Calculator
class
@
Calculator
constructor
:
->
$
(
'.calc'
).
click
@
toggle
$
(
'form#calculator'
).
submit
(
@
calculate
).
submit
(
e
)
->
...
...
static/coffee/src/courseware.coffee
View file @
8e7bf4c1
class
window
.
Courseware
class
@
Courseware
constructor
:
->
new
Courseware
Navigation
new
Navigation
new
Calculator
new
FeedbackForm
Logger
.
bind
()
...
...
static/coffee/src/feedback_form.coffee
View file @
8e7bf4c1
class
FeedbackForm
class
@
FeedbackForm
constructor
:
->
$
(
'#feedback_button'
).
click
->
data
=
...
...
templates/coffee/spec/navigation_spec.coffee
0 → 100644
View file @
8e7bf4c1
describe
'Navigation'
,
->
beforeEach
->
loadFixtures
'accordion.html'
@
navigation
=
new
Navigation
describe
'constructor'
,
->
describe
'when the #accordion exists'
,
->
describe
'when there is an active section'
,
->
beforeEach
->
spyOn
$
.
fn
,
'accordion'
$
(
'#accordion'
).
append
(
'<ul><li></li></ul><ul><li class="active"></li></ul>'
)
new
Navigation
it
'activate the accordion with correct active section'
,
->
expect
(
$
(
'#accordion'
).
accordion
).
toHaveBeenCalledWith
active
:
1
header
:
'h3'
autoHeight
:
false
describe
'when there is no active section'
,
->
beforeEach
->
spyOn
$
.
fn
,
'accordion'
$
(
'#accordion'
).
append
(
'<ul><li></li></ul><ul><li></li></ul>'
)
new
Navigation
it
'activate the accordian with section 1 as active'
,
->
expect
(
$
(
'#accordion'
).
accordion
).
toHaveBeenCalledWith
active
:
1
header
:
'h3'
autoHeight
:
false
it
'binds the accordionchange event'
,
->
Navigation
.
bind
()
expect
(
$
(
'#accordion'
)).
toHandleWith
'accordionchange'
,
@
navigation
.
log
it
'bind the navigation toggle'
,
->
Navigation
.
bind
()
expect
(
$
(
'#open_close_accordion a'
)).
toHandleWith
'click'
,
@
navigation
.
toggle
describe
'when the #accordion does not exists'
,
->
beforeEach
->
$
(
'#accordion'
).
remove
()
it
'does not activate the accordion'
,
->
spyOn
$
.
fn
,
'accordion'
Navigation
.
bind
()
expect
(
$
(
'#accordion'
).
accordion
).
wasNotCalled
()
describe
'toggle'
,
->
it
'toggle closed class on the wrapper'
,
->
$
(
'.course-wrapper'
).
removeClass
(
'closed'
)
@
navigation
.
toggle
()
expect
(
$
(
'.course-wrapper'
)).
toHaveClass
(
'closed'
)
@
navigation
.
toggle
()
expect
(
$
(
'.course-wrapper'
)).
not
.
toHaveClass
(
'closed'
)
describe
'log'
,
->
beforeEach
->
window
.
log_event
=
->
spyOn
window
,
'log_event'
it
'submit event log'
,
->
@
navigation
.
log
{},
{
newHeader
:
text
:
->
"new"
oldHeader
:
text
:
->
"old"
}
expect
(
window
.
log_event
).
toHaveBeenCalledWith
'accordion'
,
newheader
:
'new'
oldheader
:
'old'
templates/coffee/spec/navigation_spec.js
0 → 100644
View file @
8e7bf4c1
// Generated by CoffeeScript 1.3.2-pre
(
function
()
{
describe
(
'Navigation'
,
function
()
{
beforeEach
(
function
()
{
loadFixtures
(
'accordion.html'
);
return
this
.
navigation
=
new
Navigation
;
});
describe
(
'constructor'
,
function
()
{
describe
(
'when the #accordion exists'
,
function
()
{
describe
(
'when there is an active section'
,
function
()
{
beforeEach
(
function
()
{
spyOn
(
$
.
fn
,
'accordion'
);
$
(
'#accordion'
).
append
(
'<ul><li></li></ul><ul><li class="active"></li></ul>'
);
return
new
Navigation
;
});
return
it
(
'activate the accordion with correct active section'
,
function
()
{
return
expect
(
$
(
'#accordion'
).
accordion
).
toHaveBeenCalledWith
({
active
:
1
,
header
:
'h3'
,
autoHeight
:
false
});
});
});
describe
(
'when there is no active section'
,
function
()
{
beforeEach
(
function
()
{
spyOn
(
$
.
fn
,
'accordion'
);
$
(
'#accordion'
).
append
(
'<ul><li></li></ul><ul><li></li></ul>'
);
return
new
Navigation
;
});
return
it
(
'activate the accordian with section 1 as active'
,
function
()
{
return
expect
(
$
(
'#accordion'
).
accordion
).
toHaveBeenCalledWith
({
active
:
1
,
header
:
'h3'
,
autoHeight
:
false
});
});
});
it
(
'binds the accordionchange event'
,
function
()
{
Navigation
.
bind
();
return
expect
(
$
(
'#accordion'
)).
toHandleWith
(
'accordionchange'
,
this
.
navigation
.
log
);
});
return
it
(
'bind the navigation toggle'
,
function
()
{
Navigation
.
bind
();
return
expect
(
$
(
'#open_close_accordion a'
)).
toHandleWith
(
'click'
,
this
.
navigation
.
toggle
);
});
});
return
describe
(
'when the #accordion does not exists'
,
function
()
{
beforeEach
(
function
()
{
return
$
(
'#accordion'
).
remove
();
});
return
it
(
'does not activate the accordion'
,
function
()
{
spyOn
(
$
.
fn
,
'accordion'
);
Navigation
.
bind
();
return
expect
(
$
(
'#accordion'
).
accordion
).
wasNotCalled
();
});
});
});
describe
(
'toggle'
,
function
()
{
return
it
(
'toggle closed class on the wrapper'
,
function
()
{
$
(
'.course-wrapper'
).
removeClass
(
'closed'
);
this
.
navigation
.
toggle
();
expect
(
$
(
'.course-wrapper'
)).
toHaveClass
(
'closed'
);
this
.
navigation
.
toggle
();
return
expect
(
$
(
'.course-wrapper'
)).
not
.
toHaveClass
(
'closed'
);
});
});
return
describe
(
'log'
,
function
()
{
beforeEach
(
function
()
{
window
.
log_event
=
function
()
{};
return
spyOn
(
window
,
'log_event'
);
});
return
it
(
'submit event log'
,
function
()
{
this
.
navigation
.
log
({},
{
newHeader
:
{
text
:
function
()
{
return
"new"
;
}
},
oldHeader
:
{
text
:
function
()
{
return
"old"
;
}
}
});
return
expect
(
window
.
log_event
).
toHaveBeenCalledWith
(
'accordion'
,
{
newheader
:
'new'
,
oldheader
:
'old'
});
});
});
});
}).
call
(
this
);
templates/coffee/src/courseware_navigation.coffee
deleted
100644 → 0
View file @
afde79da
class
CoursewareNavigation
constructor
:
->
if
$
(
'#accordion'
).
length
active
=
$
(
'#accordion ul:has(li.active)'
).
index
(
'#accordion ul'
)
$
(
'#accordion'
).
bind
(
'accordionchange'
,
@
log
).
accordion
active
:
if
active
>=
0
then
active
else
1
header
:
'h3'
autoHeight
:
false
$
(
'#open_close_accordion a'
).
click
@
toggle
$
(
'#accordion'
).
show
()
log
:
(
event
,
ui
)
->
log_event
'accordion'
,
newheader
:
ui
.
newHeader
.
text
()
oldheader
:
ui
.
oldHeader
.
text
()
toggle
:
->
$
(
'.course-wrapper'
).
toggleClass
(
'closed'
)
templates/coffee/src/modules/video.coffee
View file @
8e7bf4c1
class
Video
class
@
Video
constructor
:
(
@
id
,
videos
)
->
window
.
player
=
null
@
element
=
$
(
"#video_
#{
@
id
}
"
)
...
...
templates/coffee/src/navigation.coffee
View file @
8e7bf4c1
class
Courseware
::
Navigation
class
@
Navigation
constructor
:
->
if
$
(
'#accordion'
).
length
active
=
$
(
'#accordion ul:has(li.active)'
).
index
(
'#accordion ul'
)
...
...
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