Commit dc76d71c by David Baumgold

4-space indents for coffeescript

parent fcf4cdc7
describe "CMS.Models.SystemFeedback", -> describe "CMS.Models.SystemFeedback", ->
beforeEach -> beforeEach ->
@model = new CMS.Models.SystemFeedback() @model = new CMS.Models.SystemFeedback()
it "should have an empty message by default", -> it "should have an empty message by default", ->
expect(@model.get("message")).toEqual("") expect(@model.get("message")).toEqual("")
it "should have an empty title by default", -> it "should have an empty title by default", ->
expect(@model.get("title")).toEqual("") expect(@model.get("title")).toEqual("")
it "should not have a type set by default", -> it "should not have a type set by default", ->
expect(@model.get("type")).toBeNull() expect(@model.get("type")).toBeNull()
describe "CMS.Models.WarningMessage", -> describe "CMS.Models.WarningMessage", ->
beforeEach -> beforeEach ->
@model = new CMS.Models.WarningMessage() @model = new CMS.Models.WarningMessage()
it "should have the correct type", -> it "should have the correct type", ->
expect(@model.get("type")).toEqual("warning") expect(@model.get("type")).toEqual("warning")
describe "CMS.Models.ErrorMessage", -> describe "CMS.Models.ErrorMessage", ->
beforeEach -> beforeEach ->
@model = new CMS.Models.ErrorMessage() @model = new CMS.Models.ErrorMessage()
it "should have the correct type", -> it "should have the correct type", ->
expect(@model.get("type")).toEqual("error") expect(@model.get("type")).toEqual("error")
describe "CMS.Models.ConfirmationMessage", -> describe "CMS.Models.ConfirmationMessage", ->
beforeEach -> beforeEach ->
@model = new CMS.Models.ConfirmationMessage() @model = new CMS.Models.ConfirmationMessage()
it "should have the correct type", -> it "should have the correct type", ->
expect(@model.get("type")).toEqual("confirmation") expect(@model.get("type")).toEqual("confirmation")
describe "CMS.Views.Alert as base class", -> describe "CMS.Views.Alert as base class", ->
tpl = readFixtures('alert.underscore') tpl = readFixtures('alert.underscore')
beforeEach -> beforeEach ->
setFixtures(sandbox({id: "page-alert"})) setFixtures(sandbox({id: "page-alert"}))
appendSetFixtures($("<script>", {id: "alert-tpl", type: "text/template"}).text(tpl)) appendSetFixtures($("<script>", {id: "alert-tpl", type: "text/template"}).text(tpl))
@model = new CMS.Models.ConfirmationMessage({ @model = new CMS.Models.ConfirmationMessage({
"title": "Portal" title: "Portal"
"message": "Welcome to the Aperture Science Computer-Aided Enrichment Center" 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 # it will be interesting to see when this.render is called, so lets spy on it
spyOn(CMS.Views.Alert.prototype, 'render').andCallThrough() spyOn(CMS.Views.Alert.prototype, 'render').andCallThrough()
it "renders on initalize", -> it "renders on initalize", ->
view = new CMS.Views.Alert({model: @model}) view = new CMS.Views.Alert({model: @model})
expect(view.render).toHaveBeenCalled() expect(view.render).toHaveBeenCalled()
it "renders the template", -> it "renders the template", ->
view = new CMS.Views.Alert({model: @model}) view = new CMS.Views.Alert({model: @model})
expect(view.$(".action-close")).toBeDefined() expect(view.$(".action-close")).toBeDefined()
expect(view.$('.wrapper')).toHaveClass("is-shown") expect(view.$('.wrapper')).toHaveClass("is-shown")
text = view.$el.text() text = view.$el.text()
expect(text).toMatch(/Portal/) expect(text).toMatch(/Portal/)
expect(text).toMatch(/Aperture Science/) expect(text).toMatch(/Aperture Science/)
it "close button sends a .hide() message", -> it "close button sends a .hide() message", ->
spyOn(CMS.Views.Alert.prototype, 'hide').andCallThrough() spyOn(CMS.Views.Alert.prototype, 'hide').andCallThrough()
view = new CMS.Views.Alert({model: @model}) view = new CMS.Views.Alert({model: @model})
view.$(".action-close").click() view.$(".action-close").click()
expect(CMS.Views.Alert.prototype.hide).toHaveBeenCalled() expect(CMS.Views.Alert.prototype.hide).toHaveBeenCalled()
expect(view.$('.wrapper')).not.toHaveClass("is-shown") expect(view.$('.wrapper')).not.toHaveClass("is-shown")
expect(view.$('.wrapper')).toHaveClass("is-hiding") expect(view.$('.wrapper')).toHaveClass("is-hiding")
describe "CMS.Views.Notification", -> describe "CMS.Views.Notification", ->
tpl = readFixtures('notification.underscore') tpl = readFixtures('notification.underscore')
beforeEach -> beforeEach ->
setFixtures(sandbox({id: "page-notification"})) setFixtures(sandbox({id: "page-notification"}))
appendSetFixtures($("<script>", {id: "notification-tpl", type: "text/template"}).text(tpl)) appendSetFixtures($("<script>", {id: "notification-tpl", type: "text/template"}).text(tpl))
@model = new CMS.Models.ConfirmationMessage({ @model = new CMS.Models.ConfirmationMessage({
"title": "Portal" title: "Portal"
"message": "Welcome to the Aperture Science Computer-Aided Enrichment Center" message: "Welcome to the Aperture Science Computer-Aided Enrichment Center"
}) })
# for some reason, expect($("body")) blows up the test runner, so this test # 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 # just exercises the Prompt rather than asserting on anything. Best I can
# do for now. :( # do for now. :(
it "changes class on body", -> it "changes class on body", ->
# expect($("body")).not.toHaveClass("prompt-is-shown") # expect($("body")).not.toHaveClass("prompt-is-shown")
view = new CMS.Views.Prompt({model: @model}) view = new CMS.Views.Prompt({model: @model})
# expect($("body")).toHaveClass("prompt-is-shown") # expect($("body")).toHaveClass("prompt-is-shown")
view.hide() view.hide()
# expect($("body")).not.toHaveClass("prompt-is-shown") # expect($("body")).not.toHaveClass("prompt-is-shown")
describe "CMS.Views.Alert click events", -> describe "CMS.Views.Alert click events", ->
tpl = readFixtures('alert.underscore') tpl = readFixtures('alert.underscore')
beforeEach -> beforeEach ->
@model = new CMS.Models.WarningMessage( @model = new CMS.Models.WarningMessage(
title: "Unsaved", title: "Unsaved",
message: "Your content is currently unsaved.", message: "Your content is currently Unsaved.",
actions: actions:
primary: primary:
text: "Save", text: "Save",
class: "save-button", class: "save-button",
click: jasmine.createSpy('primaryClick') click: jasmine.createSpy('primaryClick')
secondary: [{ secondary: [{
text: "Revert", text: "Revert",
class: "cancel-button", class: "cancel-button",
click: jasmine.createSpy('secondaryClick') click: jasmine.createSpy('secondaryClick')
}] }]
) )
setFixtures(sandbox({id: "page-alert"})) setFixtures(sandbox({id: "page-alert"}))
appendSetFixtures($("<script>", {id: "alert-tpl", type: "text/template"}).text(tpl)) appendSetFixtures($("<script>", {id: "alert-tpl", type: "text/template"}).text(tpl))
@view = new CMS.Views.Alert({model: @model}) @view = new CMS.Views.Alert({model: @model})
it "should trigger the primary event on a primary click", -> it "should trigger the primary event on a primary click", ->
@view.primaryClick() @view.primaryClick()
expect(@model.get('actions').primary.click).toHaveBeenCalled() expect(@model.get('actions').primary.click).toHaveBeenCalled()
it "should trigger the secondary event on a secondary click", -> it "should trigger the secondary event on a secondary click", ->
@view.secondaryClick() @view.secondaryClick()
expect(@model.get('actions').secondary[0].click).toHaveBeenCalled() expect(@model.get('actions').secondary[0].click).toHaveBeenCalled()
it "should apply class to primary action", -> it "should apply class to primary action", ->
expect(@view.$(".action-primary")).toHaveClass("save-button") expect(@view.$(".action-primary")).toHaveClass("save-button")
it "should apply class to secondary action", -> it "should apply class to secondary action", ->
expect(@view.$(".action-secondary")).toHaveClass("cancel-button") expect(@view.$(".action-secondary")).toHaveClass("cancel-button")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment