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
609c299f
Commit
609c299f
authored
Jun 14, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished backbone model tests for textbooks
parent
207453a3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
0 deletions
+66
-0
cms/static/coffee/spec/models/textbook_spec.coffee
+66
-0
No files found.
cms/static/coffee/spec/models/textbook_spec.coffee
View file @
609c299f
...
...
@@ -67,3 +67,69 @@ describe "CMS.Models.Textbook input/output", ->
model
=
new
CMS
.
Models
.
Textbook
(
serverModelSpec
,
{
parse
:
true
})
expect
(
deepAttributes
(
model
)).
toEqual
(
clientModelSpec
)
expect
(
model
.
toJSON
()).
toEqual
(
serverModelSpec
)
describe
"CMS.Collections.TextbookSet"
,
->
beforeEach
->
window
.
TEXTBOOK_URL
=
"/textbooks"
@
collection
=
new
CMS
.
Collections
.
TextbookSet
()
afterEach
->
delete
window
.
TEXTBOOK_URL
it
"should have a url set"
,
->
expect
(
_
.
result
(
@
collection
,
"url"
),
window
.
TEXTBOOK_URL
)
it
"can call save"
,
->
spyOn
(
@
collection
,
"sync"
)
@
collection
.
save
()
expect
(
@
collection
.
sync
).
toHaveBeenCalledWith
(
"update"
,
@
collection
,
undefined
)
it
"should respond to editOne events"
,
->
model
=
new
CMS
.
Models
.
Textbook
()
@
collection
.
trigger
(
'editOne'
,
model
)
expect
(
@
collection
.
editing
).
toEqual
(
model
)
describe
"CMS.Models.Chapter"
,
->
beforeEach
->
@
model
=
new
CMS
.
Models
.
Chapter
()
it
"should have a name by default"
,
->
expect
(
@
model
.
get
(
"name"
)).
toEqual
(
""
)
it
"should have an asset_path by default"
,
->
expect
(
@
model
.
get
(
"asset_path"
)).
toEqual
(
""
)
it
"should have an order by default"
,
->
expect
(
@
model
.
get
(
"order"
)).
toEqual
(
1
)
it
"should be empty by default"
,
->
expect
(
@
model
.
isEmpty
()).
toBeTruthy
()
describe
"CMS.Collections.ChapterSet"
,
->
beforeEach
->
@
collection
=
new
CMS
.
Collections
.
ChapterSet
()
it
"is empty by default"
,
->
expect
(
@
collection
.
isEmpty
()).
toBeTruthy
()
it
"is empty if all chapters are empty"
,
->
@
collection
.
add
([{},
{},
{}])
expect
(
@
collection
.
isEmpty
()).
toBeTruthy
()
it
"is not empty if a chapter is not empty"
,
->
@
collection
.
add
([{},
{
name
:
"full"
},
{}])
expect
(
@
collection
.
isEmpty
()).
toBeFalsy
()
it
"should have a nextOrder function"
,
->
expect
(
@
collection
.
nextOrder
()).
toEqual
(
1
)
@
collection
.
add
([{}])
expect
(
@
collection
.
nextOrder
()).
toEqual
(
2
)
@
collection
.
add
([{}])
expect
(
@
collection
.
nextOrder
()).
toEqual
(
3
)
# verify that it doesn't just return an incrementing value each time
expect
(
@
collection
.
nextOrder
()).
toEqual
(
3
)
# try going back one
@
collection
.
remove
(
@
collection
.
last
())
expect
(
@
collection
.
nextOrder
()).
toEqual
(
2
)
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