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
a861e015
Commit
a861e015
authored
Jun 21, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorganize Jasmine uploader tests
parent
c2ef6a53
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
40 deletions
+12
-40
cms/static/coffee/spec/views/textbook_spec.coffee
+12
-40
No files found.
cms/static/coffee/spec/views/textbook_spec.coffee
View file @
a861e015
...
...
@@ -264,9 +264,6 @@ describe "CMS.Views.UploadDialog", ->
setFixtures
(
$
(
"<script>"
,
{
id
:
"upload-dialog-tpl"
,
type
:
"text/template"
}).
text
(
tpl
))
appendSetFixtures
(
$
(
"<script>"
,
{
id
:
"system-feedback-tpl"
,
type
:
"text/template"
}).
text
(
feedbackTpl
))
window
.
UPLOAD_ASSET_CALLBACK_URL
=
"/upload"
@
requests
=
requests
=
[]
@
xhr
=
sinon
.
useFakeXMLHttpRequest
()
@
xhr
.
onCreate
=
(
xhr
)
->
requests
.
push
(
xhr
)
@
model
=
new
CMS
.
Models
.
FileUpload
()
@
chapter
=
new
CMS
.
Models
.
Chapter
()
...
...
@@ -288,8 +285,8 @@ describe "CMS.Views.UploadDialog", ->
afterEach
->
delete
window
.
UPLOAD_ASSET_CALLBACK_URL
@
xhr
.
restore
()
describe
"Basic"
,
->
it
"should be shown by default"
,
->
expect
(
@
view
.
options
.
shown
).
toBeTruthy
()
...
...
@@ -329,6 +326,17 @@ describe "CMS.Views.UploadDialog", ->
# can't test: this blows up the spec runner
# expect($("body")).not.toHaveClass("dialog-is-shown")
describe
"Uploads"
,
->
beforeEach
->
@
requests
=
requests
=
[]
@
xhr
=
sinon
.
useFakeXMLHttpRequest
()
@
xhr
.
onCreate
=
(
xhr
)
->
requests
.
push
(
xhr
)
@
clock
=
sinon
.
useFakeTimers
()
afterEach
->
@
xhr
.
restore
()
@
clock
.
restore
()
it
"can upload correctly"
,
->
@
view
.
upload
()
expect
(
@
model
.
get
(
"uploading"
)).
toBeTruthy
()
...
...
@@ -350,42 +358,6 @@ describe "CMS.Views.UploadDialog", ->
expect
(
@
model
.
get
(
"title"
)).
toMatch
(
/error/
)
expect
(
@
view
.
remove
).
not
.
toHaveBeenCalled
()
describe
"CMS.Views.UploadDialog timing"
,
->
tpl
=
readFixtures
(
"upload-dialog.underscore"
)
beforeEach
->
setFixtures
(
$
(
"<script>"
,
{
id
:
"upload-dialog-tpl"
,
type
:
"text/template"
}).
text
(
tpl
))
appendSetFixtures
(
$
(
"<script>"
,
{
id
:
"system-feedback-tpl"
,
type
:
"text/template"
}).
text
(
feedbackTpl
))
window
.
UPLOAD_ASSET_CALLBACK_URL
=
"/upload"
@
requests
=
requests
=
[]
@
xhr
=
sinon
.
useFakeXMLHttpRequest
()
@
xhr
.
onCreate
=
(
xhr
)
->
requests
.
push
(
xhr
)
@
model
=
new
CMS
.
Models
.
FileUpload
()
@
chapter
=
new
CMS
.
Models
.
Chapter
()
@
view
=
new
CMS
.
Views
.
UploadDialog
({
model
:
@
model
,
chapter
:
@
chapter
})
spyOn
(
@
view
,
'remove'
).
andCallThrough
()
# create mock file input, so that we aren't subject to browser restrictions
@
mockFiles
=
[]
mockFileInput
=
jasmine
.
createSpy
(
'mockFileInput'
)
mockFileInput
.
files
=
@
mockFiles
jqMockFileInput
=
jasmine
.
createSpyObj
(
'jqMockFileInput'
,
[
'get'
,
'replaceWith'
])
jqMockFileInput
.
get
.
andReturn
(
mockFileInput
)
realMethod
=
@
view
.
$
spyOn
(
@
view
,
"$"
).
andCallFake
(
selector
)
->
if
selector
==
"input[type=file]"
jqMockFileInput
else
realMethod
.
apply
(
this
,
arguments
)
@
clock
=
sinon
.
useFakeTimers
()
afterEach
->
delete
window
.
UPLOAD_ASSET_CALLBACK_URL
@
xhr
.
restore
()
@
clock
.
restore
()
it
"removes itself after two seconds on successful upload"
,
->
@
view
.
upload
()
@
requests
[
0
].
respond
(
200
,
{
"Content-Type"
:
"application/json"
},
...
...
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