Skip to content

Instantly share code, notes, and snippets.

@biot023
Created July 18, 2012 09:44
Show Gist options
  • Save biot023/3135295 to your computer and use it in GitHub Desktop.
Save biot023/3135295 to your computer and use it in GitHub Desktop.
describe( "setFailed()", function() {
var imageBox = new ImageBox( widget, boxesList );
var element = new MockElement();
var subject = function() { imageBox.setFailed(); return imageBox; }
beforeEach( function() {
widget.imageBoxes = [ {}, imageBox, {} ];
imageBox.element = element;
spyOn( element, "removeClass" );
spyOn( element, "addClass" );
spyOn( element, "delay" ).andReturn( element );
spyOn( element, "fadeOut" ).andCallThrough();
spyOn( element, "remove" );
spyOn( widget, "populateImageBoxes" );
spyOn( widget, "setSelectionBox" );
} );
it( "should change the class to 'failed'", function() {
subject();
expect( element.removeClass ).toHaveBeenCalledWith( "uploading" );
expect( element.addClass ).toHaveBeenCalledWith( "failed" );
} );
it( "should set the state as 'failed'", function() {
expect( subject().state ).toEqual( "failed" );
} );
it( "should set itself to disappear", function() {
subject();
expect( element.delay ).toHaveBeenCalled();
expect( element.fadeOut ).toHaveBeenCalled();
expect( element.remove ).toHaveBeenCalled();
} );
xit( "should remove itself from the widget's image boxes collection", function() {
subject();
expect( widget.imageBoxes ).not.toContain( imageBox );
} );
xit( "should tell its owning widget to populate its image boxes", function() {
subject();
expect( widget.populateImageBoxes ).toHaveBeenCalled();
} );
xit( "should tell its owning widget to set its selection box", function() {
subject();
expect( widget.setSelectionBox ).toHaveBeenCalled();
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment