/* * dialog_methods.js */ (function($) { module("dialog: methods"); test("init", function() { expect(7); $("
").appendTo('body').dialog().remove(); ok(true, '.dialog() called on element'); $([]).dialog().remove(); ok(true, '.dialog() called on empty collection'); $('').dialog().remove(); ok(true, '.dialog() called on disconnected DOMElement - never connected'); $('').appendTo('body').remove().dialog().remove(); ok(true, '.dialog() called on disconnected DOMElement - removed'); $('').dialog().dialog("foo").remove(); ok(true, 'arbitrary method called after init'); el = $('').dialog(); var foo = el.data("foo.dialog"); el.remove(); ok(true, 'arbitrary option getter after init'); $('').dialog().data("foo.dialog", "bar").remove(); ok(true, 'arbitrary option setter after init'); }); test("destroy", function() { expect(6); $("").appendTo('body').dialog().dialog("destroy").remove(); ok(true, '.dialog("destroy") called on element'); $([]).dialog().dialog("destroy").remove(); ok(true, '.dialog("destroy") called on empty collection'); $('').dialog().dialog("destroy").remove(); ok(true, '.dialog("destroy") called on disconnected DOMElement'); $('').dialog().dialog("destroy").dialog("foo").remove(); ok(true, 'arbitrary method called after destroy'); el = $('').dialog(); var foo = el.dialog("destroy").data("foo.dialog"); el.remove(); ok(true, 'arbitrary option getter after destroy'); $('').dialog().dialog("destroy").data("foo.dialog", "bar").remove(); ok(true, 'arbitrary option setter after destroy'); }); test("isOpen", function() { expect(4); el = $('').dialog(); equals(el.dialog('isOpen'), true, "dialog is open after init"); el.dialog('close'); equals(el.dialog('isOpen'), false, "dialog is closed"); el.remove(); el = $('').dialog({autoOpen: false}); equals(el.dialog('isOpen'), false, "dialog is closed after init"); el.dialog('open'); equals(el.dialog('isOpen'), true, "dialog is open"); el.remove(); }); })(jQuery);