Skip to content

Instantly share code, notes, and snippets.

@searls
Created November 4, 2011 15:36
Show Gist options
  • Save searls/1339606 to your computer and use it in GitHub Desktop.
Save searls/1339606 to your computer and use it in GitHub Desktop.
describe "CallListView", ->
beforeEach ->
@model = jasmine.createSpyObj('CallList',['bind','moveUp'])
@subject = new CallListView model: @model
describe "events", ->
it "binds to up-arrow clicks", ->
expect(@subject.events).toEqual "click .up-arrow": 'moveUp'
describe "#moveUp", ->
beforeEach ->
$upArrow = $(@subject.el).inject('up-arrow').text('C')
@subject.moveUp target: $upArrow[0]
it "tells the model to move up the arrow's text", ->
expect(@model.moveUp).toHaveBeenCalledWith 'C'
class CallListView extends Backbone.View
events:
"click .up-arrow": "moveUp"
moveUp: (e) ->
@model.moveUp $(e.target).text()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment