Created
August 8, 2012 04:34
-
-
Save fivetanley/3292068 to your computer and use it in GitHub Desktop.
jasmine again
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define( [ 'views/SearchView' ], function( SearchView ){ | |
describe('SearchView', function() { | |
var searchView, spy | |
beforeEach(function() { | |
setFixtures( $( "<input type='search' id='search'/>" ) ) | |
searchView = new SearchView() | |
searchView.render() | |
spy = jasmine.createSpyObj( 'event', [ 'handler' ] ) | |
}) | |
describe('when user is typing', function() { | |
it('triggers a search event the user types something', function() { | |
searchView.on( 'search', spy.handler ) | |
var typeEvent = $.Event( 'textinput' ) | |
// lowercase 't' | |
, keycode = 84 | |
$( '#search' ).trigger( typeEvent ) | |
expect( spy.handler ).toHaveBeenCalled() | |
}) | |
it( 'triggers the search event with the content of the search box' | |
, function() { | |
searchView.on( 'search', spy.handler ) | |
$( '#search' ).val( 'foo' ) | |
var typeEvent = $.Event( 'textinput' ) | |
// lowercase 't' | |
typeEvent.keycode = 84 | |
$( '#search' ).trigger( typeEvent ) | |
expect( spy.handler ).toHaveBeenCalledWith( 'foot' ) | |
}) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment