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
dc76d71c
Commit
dc76d71c
authored
May 15, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
4-space indents for coffeescript
parent
fcf4cdc7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
103 additions
and
103 deletions
+103
-103
cms/static/coffee/spec/models/feedback_spec.coffee
+20
-20
cms/static/coffee/spec/views/feedback_spec.coffee
+83
-83
No files found.
cms/static/coffee/spec/models/feedback_spec.coffee
View file @
dc76d71c
describe
"CMS.Models.SystemFeedback"
,
->
beforeEach
->
@
model
=
new
CMS
.
Models
.
SystemFeedback
()
beforeEach
->
@
model
=
new
CMS
.
Models
.
SystemFeedback
()
it
"should have an empty message by default"
,
->
expect
(
@
model
.
get
(
"message"
)).
toEqual
(
""
)
it
"should have an empty message by default"
,
->
expect
(
@
model
.
get
(
"message"
)).
toEqual
(
""
)
it
"should have an empty title by default"
,
->
expect
(
@
model
.
get
(
"title"
)).
toEqual
(
""
)
it
"should have an empty title by default"
,
->
expect
(
@
model
.
get
(
"title"
)).
toEqual
(
""
)
it
"should not have a type set by default"
,
->
expect
(
@
model
.
get
(
"type"
)).
toBeNull
()
it
"should not have a type set by default"
,
->
expect
(
@
model
.
get
(
"type"
)).
toBeNull
()
describe
"CMS.Models.WarningMessage"
,
->
beforeEach
->
@
model
=
new
CMS
.
Models
.
WarningMessage
()
beforeEach
->
@
model
=
new
CMS
.
Models
.
WarningMessage
()
it
"should have the correct type"
,
->
expect
(
@
model
.
get
(
"type"
)).
toEqual
(
"warning"
)
it
"should have the correct type"
,
->
expect
(
@
model
.
get
(
"type"
)).
toEqual
(
"warning"
)
describe
"CMS.Models.ErrorMessage"
,
->
beforeEach
->
@
model
=
new
CMS
.
Models
.
ErrorMessage
()
beforeEach
->
@
model
=
new
CMS
.
Models
.
ErrorMessage
()
it
"should have the correct type"
,
->
expect
(
@
model
.
get
(
"type"
)).
toEqual
(
"error"
)
it
"should have the correct type"
,
->
expect
(
@
model
.
get
(
"type"
)).
toEqual
(
"error"
)
describe
"CMS.Models.ConfirmationMessage"
,
->
beforeEach
->
@
model
=
new
CMS
.
Models
.
ConfirmationMessage
()
beforeEach
->
@
model
=
new
CMS
.
Models
.
ConfirmationMessage
()
it
"should have the correct type"
,
->
expect
(
@
model
.
get
(
"type"
)).
toEqual
(
"confirmation"
)
it
"should have the correct type"
,
->
expect
(
@
model
.
get
(
"type"
)).
toEqual
(
"confirmation"
)
cms/static/coffee/spec/views/feedback_spec.coffee
View file @
dc76d71c
describe
"CMS.Views.Alert as base class"
,
->
tpl
=
readFixtures
(
'alert.underscore'
)
tpl
=
readFixtures
(
'alert.underscore'
)
beforeEach
->
setFixtures
(
sandbox
({
id
:
"page-alert"
}))
appendSetFixtures
(
$
(
"<script>"
,
{
id
:
"alert-tpl"
,
type
:
"text/template"
}).
text
(
tpl
))
beforeEach
->
setFixtures
(
sandbox
({
id
:
"page-alert"
}))
appendSetFixtures
(
$
(
"<script>"
,
{
id
:
"alert-tpl"
,
type
:
"text/template"
}).
text
(
tpl
))
@
model
=
new
CMS
.
Models
.
ConfirmationMessage
({
"title"
:
"Portal"
"message"
:
"Welcome to the Aperture Science Computer-Aided Enrichment Center"
})
# it will be interesting to see when this.render is called, so lets spy on it
spyOn
(
CMS
.
Views
.
Alert
.
prototype
,
'render'
).
andCallThrough
()
@
model
=
new
CMS
.
Models
.
ConfirmationMessage
({
title
:
"Portal"
message
:
"Welcome to the Aperture Science Computer-Aided Enrichment Center"
})
# it will be interesting to see when this.render is called, so lets spy on it
spyOn
(
CMS
.
Views
.
Alert
.
prototype
,
'render'
).
andCallThrough
()
it
"renders on initalize"
,
->
view
=
new
CMS
.
Views
.
Alert
({
model
:
@
model
})
expect
(
view
.
render
).
toHaveBeenCalled
()
it
"renders on initalize"
,
->
view
=
new
CMS
.
Views
.
Alert
({
model
:
@
model
})
expect
(
view
.
render
).
toHaveBeenCalled
()
it
"renders the template"
,
->
view
=
new
CMS
.
Views
.
Alert
({
model
:
@
model
})
expect
(
view
.
$
(
".action-close"
)).
toBeDefined
()
expect
(
view
.
$
(
'.wrapper'
)).
toHaveClass
(
"is-shown"
)
text
=
view
.
$el
.
text
()
expect
(
text
).
toMatch
(
/Portal/
)
expect
(
text
).
toMatch
(
/Aperture Science/
)
it
"renders the template"
,
->
view
=
new
CMS
.
Views
.
Alert
({
model
:
@
model
})
expect
(
view
.
$
(
".action-close"
)).
toBeDefined
()
expect
(
view
.
$
(
'.wrapper'
)).
toHaveClass
(
"is-shown"
)
text
=
view
.
$el
.
text
()
expect
(
text
).
toMatch
(
/Portal/
)
expect
(
text
).
toMatch
(
/Aperture Science/
)
it
"close button sends a .hide() message"
,
->
spyOn
(
CMS
.
Views
.
Alert
.
prototype
,
'hide'
).
andCallThrough
()
it
"close button sends a .hide() message"
,
->
spyOn
(
CMS
.
Views
.
Alert
.
prototype
,
'hide'
).
andCallThrough
()
view
=
new
CMS
.
Views
.
Alert
({
model
:
@
model
})
view
.
$
(
".action-close"
).
click
()
view
=
new
CMS
.
Views
.
Alert
({
model
:
@
model
})
view
.
$
(
".action-close"
).
click
()
expect
(
CMS
.
Views
.
Alert
.
prototype
.
hide
).
toHaveBeenCalled
()
expect
(
view
.
$
(
'.wrapper'
)).
not
.
toHaveClass
(
"is-shown"
)
expect
(
view
.
$
(
'.wrapper'
)).
toHaveClass
(
"is-hiding"
)
expect
(
CMS
.
Views
.
Alert
.
prototype
.
hide
).
toHaveBeenCalled
()
expect
(
view
.
$
(
'.wrapper'
)).
not
.
toHaveClass
(
"is-shown"
)
expect
(
view
.
$
(
'.wrapper'
)).
toHaveClass
(
"is-hiding"
)
describe
"CMS.Views.Notification"
,
->
tpl
=
readFixtures
(
'notification.underscore'
)
beforeEach
->
setFixtures
(
sandbox
({
id
:
"page-notification"
}))
appendSetFixtures
(
$
(
"<script>"
,
{
id
:
"notification-tpl"
,
type
:
"text/template"
}).
text
(
tpl
))
@
model
=
new
CMS
.
Models
.
ConfirmationMessage
({
"title"
:
"Portal"
"message"
:
"Welcome to the Aperture Science Computer-Aided Enrichment Center"
})
# for some reason, expect($("body")) blows up the test runner, so this test
# just exercises the Prompt rather than asserting on anything. Best I can
# do for now. :(
it
"changes class on body"
,
->
# expect($("body")).not.toHaveClass("prompt-is-shown")
view
=
new
CMS
.
Views
.
Prompt
({
model
:
@
model
})
# expect($("body")).toHaveClass("prompt-is-shown")
view
.
hide
()
# expect($("body")).not.toHaveClass("prompt-is-shown")
tpl
=
readFixtures
(
'notification.underscore'
)
beforeEach
->
setFixtures
(
sandbox
({
id
:
"page-notification"
}))
appendSetFixtures
(
$
(
"<script>"
,
{
id
:
"notification-tpl"
,
type
:
"text/template"
}).
text
(
tpl
))
@
model
=
new
CMS
.
Models
.
ConfirmationMessage
({
title
:
"Portal"
message
:
"Welcome to the Aperture Science Computer-Aided Enrichment Center"
})
# for some reason, expect($("body")) blows up the test runner, so this test
# just exercises the Prompt rather than asserting on anything. Best I can
# do for now. :(
it
"changes class on body"
,
->
# expect($("body")).not.toHaveClass("prompt-is-shown")
view
=
new
CMS
.
Views
.
Prompt
({
model
:
@
model
})
# expect($("body")).toHaveClass("prompt-is-shown")
view
.
hide
()
# expect($("body")).not.toHaveClass("prompt-is-shown")
describe
"CMS.Views.Alert click events"
,
->
tpl
=
readFixtures
(
'alert.underscore'
)
beforeEach
->
@
model
=
new
CMS
.
Models
.
WarningMessage
(
title
:
"Unsaved"
,
message
:
"Your content is currently u
nsaved."
,
actions
:
primary
:
text
:
"Save"
,
class
:
"save-button"
,
click
:
jasmine
.
createSpy
(
'primaryClick'
)
secondary
:
[{
text
:
"Revert"
,
class
:
"cancel-button"
,
click
:
jasmine
.
createSpy
(
'secondaryClick'
)
}]
)
setFixtures
(
sandbox
({
id
:
"page-alert"
}))
appendSetFixtures
(
$
(
"<script>"
,
{
id
:
"alert-tpl"
,
type
:
"text/template"
}).
text
(
tpl
))
@
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
()
it
"should apply class to primary action"
,
->
expect
(
@
view
.
$
(
".action-primary"
)).
toHaveClass
(
"save-button"
)
it
"should apply class to secondary action"
,
->
expect
(
@
view
.
$
(
".action-secondary"
)).
toHaveClass
(
"cancel-button"
)
tpl
=
readFixtures
(
'alert.underscore'
)
beforeEach
->
@
model
=
new
CMS
.
Models
.
WarningMessage
(
title
:
"Unsaved"
,
message
:
"Your content is currently U
nsaved."
,
actions
:
primary
:
text
:
"Save"
,
class
:
"save-button"
,
click
:
jasmine
.
createSpy
(
'primaryClick'
)
secondary
:
[{
text
:
"Revert"
,
class
:
"cancel-button"
,
click
:
jasmine
.
createSpy
(
'secondaryClick'
)
}]
)
setFixtures
(
sandbox
({
id
:
"page-alert"
}))
appendSetFixtures
(
$
(
"<script>"
,
{
id
:
"alert-tpl"
,
type
:
"text/template"
}).
text
(
tpl
))
@
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
()
it
"should apply class to primary action"
,
->
expect
(
@
view
.
$
(
".action-primary"
)).
toHaveClass
(
"save-button"
)
it
"should apply class to secondary action"
,
->
expect
(
@
view
.
$
(
".action-secondary"
)).
toHaveClass
(
"cancel-button"
)
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