polarblau / capycorder

Chrome extension, generating Capybara request spec steps based on user interaction.
https://chrome.google.com/webstore/detail/niijdolnjmjdjakbanogihdlhcbhfkho
83 stars 15 forks source link

Trigger `OK` on enter when naming test #6

Closed polarblau closed 12 years ago

simi commented 12 years ago

Hello. I wrote this feature. Unfortunately without tests. I'm probably able to write tests with some another dependency (https://github.com/jquery/jquery-ui/blob/master/tests/jquery.simulate.js). I'm coffee newbie, so please review.

polarblau commented 12 years ago

Ah, sorry, missed this comment when replying to the pull request (regarding missing test). You can "mock" any kind of jQuery event e.g. like this (no need for an extra dependency):

ENTER_EVENT = $.Event 'keypress', 'which': 13

Then use it like so:

$('#my-input').trigger ENTER_EVENT

If you want to take a crack at writing a test for this, I'd appreciate it. I'm happy to help.

Also not sure if this shouldn't be a keyup event rather.