diff options
author | Richard Worth <rdworth@gmail.com> | 2009-02-04 04:35:18 +0000 |
---|---|---|
committer | Richard Worth <rdworth@gmail.com> | 2009-02-04 04:35:18 +0000 |
commit | 52005f42dda87e4dc06d5688c27bf6b82ad80621 (patch) | |
tree | b41f7bce68c7384a1157e0902cd3004e02c529b3 /tests/unit/dialog/dialog_methods.js | |
parent | b18da5cd646fbe86ae9396c5faf2c519ac989f09 (diff) | |
download | jquery-ui-52005f42dda87e4dc06d5688c27bf6b82ad80621.tar.gz jquery-ui-52005f42dda87e4dc06d5688c27bf6b82ad80621.zip |
dialog unit tests: split tests into individual files
Diffstat (limited to 'tests/unit/dialog/dialog_methods.js')
-rw-r--r-- | tests/unit/dialog/dialog_methods.js | 67 |
1 files changed, 65 insertions, 2 deletions
diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index 16037ae7c..897c74581 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -5,8 +5,71 @@ module("dialog: methods"); -test("testname", function() { - ok(false, "missing test - untested code is broken code."); +test("init", function() { + expect(7); + + $("<div></div>").appendTo('body').dialog().remove(); + ok(true, '.dialog() called on element'); + + $([]).dialog().remove(); + ok(true, '.dialog() called on empty collection'); + + $('<div></div>').dialog().remove(); + ok(true, '.dialog() called on disconnected DOMElement - never connected'); + + $('<div></div>').appendTo('body').remove().dialog().remove(); + ok(true, '.dialog() called on disconnected DOMElement - removed'); + + $('<div></div>').dialog().dialog("foo").remove(); + ok(true, 'arbitrary method called after init'); + + el = $('<div></div>').dialog(); + var foo = el.data("foo.dialog"); + el.remove(); + ok(true, 'arbitrary option getter after init'); + + $('<div></div>').dialog().data("foo.dialog", "bar").remove(); + ok(true, 'arbitrary option setter after init'); +}); + +test("destroy", function() { + expect(6); + + $("<div></div>").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'); + + $('<div></div>').dialog().dialog("destroy").remove(); + ok(true, '.dialog("destroy") called on disconnected DOMElement'); + + $('<div></div>').dialog().dialog("destroy").dialog("foo").remove(); + ok(true, 'arbitrary method called after destroy'); + + el = $('<div></div>').dialog(); + var foo = el.dialog("destroy").data("foo.dialog"); + el.remove(); + ok(true, 'arbitrary option getter after destroy'); + + $('<div></div>').dialog().dialog("destroy").data("foo.dialog", "bar").remove(); + ok(true, 'arbitrary option setter after destroy'); +}); + +test("isOpen", function() { + expect(4); + + el = $('<div></div>').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 = $('<div></div>').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); |