Skip to content

Instantly share code, notes, and snippets.

@radamant
Created July 21, 2011 20:43
Show Gist options
  • Save radamant/1098154 to your computer and use it in GitHub Desktop.
Save radamant/1098154 to your computer and use it in GitHub Desktop.
Jasmine spec in coffeescript
describe 'jQuery.fn.ignoreEnter', ->
beforeEach ->
setFixtures '<input />'
$('input').ignoreEnter()
describe 'pressing enter', ->
event = null
beforeEach ->
event = jQuery.Event 'keypress'
event.which = '13'
spyOn event, 'preventDefault'
$('input').trigger(event)
it 'should prevent the event from bubbling', ->
expect(event.which).toEqual('13')
expect(event.preventDefault).toHaveBeenCalled()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment