Add tests for click events on views
This commit is contained in:
@@ -23,6 +23,7 @@ describe "CMS.Models.SystemFeedback", ->
|
||||
expect(@model.get("shown")).toEqual(false)
|
||||
expect(spy).toHaveBeenCalled()
|
||||
|
||||
|
||||
describe "CMS.Models.WarningMessage", ->
|
||||
beforeEach ->
|
||||
@model = new CMS.Models.WarningMessage()
|
||||
@@ -43,4 +44,3 @@ describe "CMS.Models.ConfirmationMessage", ->
|
||||
|
||||
it "should have the correct type", ->
|
||||
expect(@model.get("type")).toEqual("confirmation")
|
||||
|
||||
|
||||
@@ -50,3 +50,28 @@ describe "CMS.Views.SystemFeedback", ->
|
||||
@model.hide()
|
||||
# expect($("body")).not.toHaveClass("prompt-is-shown")
|
||||
|
||||
describe "SystemFeedback click events", ->
|
||||
beforeEach ->
|
||||
@model = new CMS.Models.WarningMessage(
|
||||
title: "Unsaved",
|
||||
message: "Your content is currently unsaved.",
|
||||
actions:
|
||||
primary:
|
||||
text: "Save",
|
||||
click: jasmine.createSpy('primaryClick')
|
||||
secondary: [{
|
||||
text: "Revert",
|
||||
click: jasmine.createSpy('secondaryClick')
|
||||
}]
|
||||
|
||||
)
|
||||
|
||||
@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()
|
||||
|
||||
Reference in New Issue
Block a user