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
fedfe862
Commit
fedfe862
authored
May 14, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for click events on views
parent
070d24cf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
2 deletions
+32
-2
cms/static/coffee/spec/models/feedback_spec.coffee
+1
-1
cms/static/coffee/spec/views/feedback_spec.coffee
+25
-0
cms/static/js/views/feedback.js
+6
-1
No files found.
cms/static/coffee/spec/models/feedback_spec.coffee
View file @
fedfe862
...
...
@@ -23,6 +23,7 @@ describe "CMS.Models.SystemFeedback", ->
expect
(
@
model
.
get
(
"shown"
)).
toEqual
(
false
)
expect
(
spy
).
toHaveBeenCalled
()
describe
"CMS.Models.WarningMessage"
,
->
beforeEach
->
@
model
=
new
CMS
.
Models
.
WarningMessage
()
...
...
@@ -43,4 +44,3 @@ describe "CMS.Models.ConfirmationMessage", ->
it
"should have the correct type"
,
->
expect
(
@
model
.
get
(
"type"
)).
toEqual
(
"confirmation"
)
cms/static/coffee/spec/views/feedback_spec.coffee
View file @
fedfe862
...
...
@@ -50,3 +50,28 @@ describe "CMS.Views.SystemFeedback", ->
@
model
.
hide
()
# expect($("body")).not.toHaveClass("prompt-is-shown")
describe
"SystemFeedback click events"
,
->
beforeEach
->
@
model
=
new
CMS
.
Models
.
WarningMessage
(
title
:
"Unsaved"
,
message
:
"Your content is currently unsaved."
,
actions
:
primary
:
text
:
"Save"
,
click
:
jasmine
.
createSpy
(
'primaryClick'
)
secondary
:
[{
text
:
"Revert"
,
click
:
jasmine
.
createSpy
(
'secondaryClick'
)
}]
)
@
view
=
new
CMS
.
Views
.
Alert
({
model
:
@
model
})
it
"should trigger the primary event on a primary click"
,
->
@
view
.
primaryClick
()
expect
(
@
model
.
get
(
'actions'
).
primary
.
click
).
toHaveBeenCalled
()
it
"should trigger the secondary event on a secondary click"
,
->
@
view
.
secondaryClick
()
expect
(
@
model
.
get
(
'actions'
).
secondary
[
0
].
click
).
toHaveBeenCalled
()
cms/static/js/views/feedback.js
View file @
fedfe862
...
...
@@ -38,7 +38,12 @@ CMS.Views.SystemFeedback = Backbone.View.extend({
var
secondaryList
=
actions
.
secondary
;
if
(
!
secondaryList
)
{
return
;
}
// which secondary action was clicked?
var
i
=
_
.
indexOf
(
this
.
$
(
".action-secondary"
),
e
.
target
);
var
i
;
if
(
e
&&
e
.
target
)
{
i
=
_
.
indexOf
(
this
.
$
(
".action-secondary"
),
e
.
target
);
}
else
{
i
=
0
;
}
var
secondary
=
this
.
model
.
get
(
"actions"
).
secondary
[
i
];
if
(
secondary
.
click
)
{
secondary
.
click
.
call
(
this
.
model
);
...
...
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