Skip to content

Commit

Permalink
Update specs to validate empty inputs.
Browse files Browse the repository at this point in the history
  • Loading branch information
stas committed Apr 25, 2012
1 parent a577f3a commit 2df5033
Showing 1 changed file with 15 additions and 4 deletions.
Expand Up @@ -13,25 +13,36 @@ describe( 'controllers/todos', function() {
).to.equal( controller.inputView.get( 'placeholder' ) );
});

it( 'should not allow empty values on edits', function() {
var editorField = controller.todoEditor.create({ value: title });
editorField.whenDone();
expect( editorField.get( 'value' ) ).to.equal( title );
});

it( 'should create new entry on newline', function() {
controller.inputView.set( 'value', title );
controller.inputView.insertNewline();
expect( controller.get( 'lastObject' ).title ).to.equal( title );
controller.removeObject( controller.get( 'lastObject' ) );
});

it( 'should not allow empty values on entry changes', function() {
controller.createNew( title );
var entry = controller.get( 'lastObject' );
entry.set( 'title', ' ' );
expect( entry.title ).to.equal( title );
});

it( 'should reflect the same number of items as in store', function() {
controller.inputView.set( 'value', title );
controller.inputView.insertNewline();
controller.createNew( 'value', title );
var visibles = controller.todosView.
get( 'childViews' )[ 0 ].get( 'childViews' ).length;
expect( controller.get( 'content' ).length ).to.equal( visibles );
controller.removeObject( controller.get( 'lastObject' ) );
});

it( 'should allow removing entries', function( done ) {
controller.inputView.set( 'value', title );
controller.inputView.insertNewline();
controller.createNew( 'value', title );
setTimeout( function(){
controller.allDoneCheckbox.set( 'value', true );
}, 100 );
Expand Down

0 comments on commit 2df5033

Please sign in to comment.