Created
August 10, 2012 03:16
-
-
Save fivetanley/3310715 to your computer and use it in GitHub Desktop.
moar sinon fun
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( function( require ) { | |
| var EntryListingView = require( 'views/EntryListingView' ) | |
| , $ = require( 'jquery' ) | |
| describe('EntryListingView', function() { | |
| var entryListingView | |
| , id = 'entry' | |
| , entry | |
| , stub | |
| , entryView | |
| , domElement | |
| beforeEach(function() { | |
| entry = new Backbone.Model() | |
| stub = sinon.stub( entry, 'get' ) | |
| .withArgs( 'id' ) | |
| .returns( id ) | |
| entryView = new EntryListingView({ model: entry } ) | |
| entryView.render() | |
| setFixtures( $( '</div>' ) ) | |
| domElement = entryView.$el | |
| appendSetFixtures( domElement ) | |
| }) | |
| describe('rendering', function() { | |
| it('should ask its model for information', function() { | |
| expect( stub ).toHaveBeenCalledOnce() | |
| }) | |
| it('should render the id', function() { | |
| expect( domElement ).toHaveText( id ) | |
| }) | |
| }) | |
| describe('toggling visibility', function() { | |
| it('should be able to be turned invisible', function() { | |
| entryView.hide() | |
| expect( domElement ).not.toBeVisible() | |
| }) | |
| it('should be able to be turned visible', function() { | |
| expect( stub ).toHaveBeenCalled() | |
| entryView.hide().show() | |
| expect( domElement ).toBeVisible() | |
| }) | |
| describe('toggling visibility with a query', function() { | |
| it('will hide if the model\'s id matches the query', function() { | |
| entryView.hide( id.substring( 0, id.length - 2 ) ) | |
| expect( domElement ).not.toBeVisible() | |
| }) | |
| it('will not hide if the models id does not match query', function() { | |
| entryView.hide( 'totallyNeverGonnaMatch' ) | |
| expect( domElement ).toBeVisible() | |
| }) | |
| it('will show if models id matches the query', function() { | |
| entryView.hide() | |
| entryView.show( id.substring( 0, id.length -2 ) ) | |
| expect( domElement ).toBeVisible() | |
| }) | |
| it('will not show if models id does not match query', function() { | |
| entryView.hide() | |
| entryView.show( 'totallyNeverGonnaMatch' ) | |
| expect( domElement ).not.toBeVisible() | |
| }) | |
| }) | |
| }) | |
| describe('highlighting', function() { | |
| it('changes its background color when told', function() { | |
| }) | |
| }) | |
| }) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment