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
6aa1a849
Commit
6aa1a849
authored
May 21, 2015
by
Thomas Young
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added jasmine tests for focusing on and scrolling to newly added textbook
parent
e294e01d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
2 deletions
+34
-2
cms/static/coffee/spec/views/textbook_spec.coffee
+34
-2
No files found.
cms/static/coffee/spec/views/textbook_spec.coffee
View file @
6aa1a849
define
[
"js/models/textbook"
,
"js/models/chapter"
,
"js/collections/chapter"
,
"js/models/course"
,
"js/collections/textbook"
,
"js/views/show_textbook"
,
"js/views/edit_textbook"
,
"js/views/list_textbooks"
,
"js/views/edit_chapter"
,
"js/views/feedback_prompt"
,
"js/views/feedback_notification"
,
"js/views/edit_chapter"
,
"js/views/feedback_prompt"
,
"js/views/feedback_notification"
,
"js/views/utils/view_utils"
,
"js/common_helpers/ajax_helpers"
,
"js/spec_helpers/modal_helpers"
,
"jasmine-stealth"
],
(
Textbook
,
Chapter
,
ChapterSet
,
Course
,
TextbookSet
,
ShowTextbook
,
EditTextbook
,
ListTex
book
,
EditChapter
,
Prompt
,
Notification
,
AjaxHelpers
,
modal_helpers
)
->
(
Textbook
,
Chapter
,
ChapterSet
,
Course
,
TextbookSet
,
ShowTextbook
,
EditTextbook
,
ListTex
tbooks
,
EditChapter
,
Prompt
,
Notification
,
ViewUtils
,
AjaxHelpers
,
modal_helpers
)
->
feedbackTpl
=
readFixtures
(
'system-feedback.underscore'
)
beforeEach
->
...
...
@@ -194,6 +194,38 @@ define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js
@
view
.
$
(
".action-cancel"
).
click
()
expect
(
chapters
.
length
).
toEqual
(
1
)
describe
"ListTextbooks"
,
->
noTextbooksTpl
=
readFixtures
(
"no-textbooks.underscore"
)
editTextbooktpl
=
readFixtures
(
'edit-textbook.underscore'
)
beforeEach
->
appendSetFixtures
(
$
(
"<script>"
,
{
id
:
"no-textbooks-tpl"
,
type
:
"text/template"
}).
text
(
noTextbooksTpl
))
appendSetFixtures
(
$
(
"<script>"
,
{
id
:
"edit-textbook-tpl"
,
type
:
"text/template"
}).
text
(
editTextbooktpl
))
@
collection
=
new
TextbookSet
@
view
=
new
ListTextbooks
({
collection
:
@
collection
})
@
view
.
render
()
it
"should scroll to newly added textbook"
,
->
spyOn
(
ViewUtils
,
'setScrollOffset'
)
@
view
.
$
(
".new-button"
).
click
()
$sectionEl
=
@
view
.
$el
.
find
(
'section:last'
)
expect
(
$sectionEl
.
length
).
toEqual
(
1
)
expect
(
ViewUtils
.
setScrollOffset
).
toHaveBeenCalledWith
(
$sectionEl
,
0
)
it
"should focus first input element of newly added textbook"
,
->
spyOn
(
jQuery
.
fn
,
'focus'
).
andCallThrough
()
@
addMatchers
toHaveBeenCalledOnJQueryObject
:
(
actual
,
expected
)
->
pass
:
actual
.
calls
&&
actual
.
calls
.
mostRecent
()
&&
actual
.
calls
.
mostRecent
().
object
[
0
]
==
expected
[
0
]
@
view
.
$
(
".new-button"
).
click
()
$inputEl
=
@
view
.
$el
.
find
(
'section:last input:first'
)
expect
(
$inputEl
.
length
).
toEqual
(
1
)
# testing for element focused seems to be tricky
# (see http://stackoverflow.com/questions/967096)
# and the following doesn't seem to work
# expect($inputEl).toBeFocused()
# expect($inputEl.find(':focus').length).toEqual(1)
expect
(
jQuery
.
fn
.
focus
).
toHaveBeenCalledOnJQueryObject
(
$inputEl
)
# describe "ListTextbooks", ->
# noTextbooksTpl = readFixtures("no-textbooks.underscore")
...
...
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