Skip to content
Permalink
Browse files

Removed use of .data() for getting/setting options in tests; using ea…

…ch plugin's option method instead. Fixes #4853 - Remove use of .data() for options in tests.
  • Loading branch information
scottgonzalez committed Nov 9, 2009
1 parent b0733bb commit b3a095d3ef7a186fe27fe19a0a40eeb496978284
@@ -31,11 +31,11 @@ test("init", function() {
ok(true, 'arbitrary method called after init');

var el = $('<div></div>').accordion();
var foo = el.data("foo.accordion");
var foo = el.accordion("option", "foo");
el.remove();
ok(true, 'arbitrary option getter after init');

$('<div></div>').accordion().data("foo.accordion", "bar").remove();
$('<div></div>').accordion().accordion("option", "foo", "bar").remove();
ok(true, 'arbitrary option setter after init');
});

@@ -52,14 +52,6 @@ test("destroy", function() {
$('<div></div>').accordion().accordion("destroy").accordion("foo").remove();
ok(true, 'arbitrary method called after destroy');

var el = $('<div></div>').accordion();
var foo = el.accordion("destroy").data("foo.accordion");
el.remove();
ok(true, 'arbitrary option getter after destroy');

$('<div></div>').accordion().accordion("destroy").data("foo.accordion", "bar").remove();
ok(true, 'arbitrary option setter after destroy');

var expected = $('<div></div>').accordion(),
actual = expected.accordion('destroy');
equals(actual, expected, 'destroy is chainable');
@@ -28,17 +28,15 @@ test("init", function() {
ok(true, 'arbitrary method called after init');

el = $('<div></div>').dialog();
var foo = el.data("foo.dialog");
var foo = el.dialog("option", "foo");
el.remove();
ok(true, 'arbitrary option getter after init');

$('<div></div>').dialog().data("foo.dialog", "bar").remove();
$('<div></div>').dialog().dialog("option", "foo", "bar").remove();
ok(true, 'arbitrary option setter after init');
});

test("destroy", function() {
expect(7);

$("<div></div>").appendTo('body').dialog().dialog("destroy").remove();
ok(true, '.dialog("destroy") called on element');

@@ -51,14 +49,6 @@ test("destroy", function() {
$('<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');

var expected = $('<div></div>').dialog(),
actual = expected.dialog('destroy');
equals(actual, expected, 'destroy is chainable');
@@ -54,9 +54,9 @@ test("buttons", function() {
}
};

same(el.data("buttons.dialog"), buttons, '.data("buttons.dialog") getter');
el.data("buttons.dialog", newButtons);
same(el.data("buttons.dialog"), newButtons, '.data("buttons.dialog", ...) setter');
same(el.dialog("option", "buttons"), buttons, '.dialog("option", "buttons") getter');
el.dialog("option", "buttons", newButtons);
same(el.dialog("option", "buttons"), newButtons, '.dialog("option", "buttons", ...) setter');

btn = $("button", dlg());
equals(btn.length, 1, "number of buttons after setter");
@@ -155,7 +155,7 @@ test("height", function() {
el.remove();

el = $('<div></div>').dialog();
el.data('height.dialog', 438);
el.dialog('option', 'height', 438);
equals(dlg().height(), 438, "explicit height set after init");
el.remove();
});
@@ -173,7 +173,7 @@ test("maxHeight", function() {
equals(heightAfter, 400, "maxHeight");
el.remove();

el = $('<div></div>').dialog({ maxHeight: 400 }).data('maxHeight.dialog', 600);
el = $('<div></div>').dialog({ maxHeight: 400 }).dialog('option', 'maxHeight', 600);
drag('.ui-resizable-n', -1000, -1000);
equals(heightAfter, 600, "maxHeight");
el.remove();
@@ -192,7 +192,7 @@ test("maxWidth", function() {
equals(widthAfter, 400, "maxWidth");
el.remove();

el = $('<div></div>').dialog({ maxWidth: 400 }).data('maxWidth.dialog', 600);
el = $('<div></div>').dialog({ maxWidth: 400 }).dialog('option', 'maxWidth', 600);
drag('.ui-resizable-w', -1000, -1000);
equals(widthAfter, 600, "maxWidth");
el.remove();
@@ -211,7 +211,7 @@ test("minHeight", function() {
equals(heightAfter, 10, "minHeight");
el.remove();

el = $('<div></div>').dialog({ minHeight: 10 }).data('minHeight.dialog', 30);
el = $('<div></div>').dialog({ minHeight: 10 }).dialog('option', 'minHeight', 30);
drag('.ui-resizable-n', 1000, 1000);
equals(heightAfter, 30, "minHeight");
el.remove();
@@ -230,7 +230,7 @@ test("minWidth", function() {
equals(widthAfter, 10, "minWidth");
el.remove();

el = $('<div></div>').dialog({ minWidth: 30 }).data('minWidth.dialog', 30);
el = $('<div></div>').dialog({ minWidth: 30 }).dialog('option', 'minWidth', 30);
drag('.ui-resizable-w', 1000, 1000);
equals(widthAfter, 30, "minWidth");
el.remove();
@@ -258,13 +258,13 @@ test("resizable", function() {

el = $('<div></div>').dialog();
shouldresize("[default]");
el.data('resizable.dialog', false);
el.dialog('option', 'resizable', false);
shouldnotresize('disabled after init');
el.remove();

el = $('<div></div>').dialog({ resizable: false });
shouldnotresize("disabled in init options");
el.data('resizable.dialog', true);
el.dialog('option', 'resizable', true);
shouldresize('enabled after init');
el.remove();
});
@@ -296,7 +296,7 @@ test("title", function() {
equals(titleText(), "bar", "title in init options should override title in element attribute");
el.remove();

el = $('<div></div>').dialog().data('title.dialog', 'foo');
el = $('<div></div>').dialog().dialog('option', 'title', 'foo');
equals(titleText(), 'foo', 'title after init');
el.remove();
});
@@ -310,7 +310,7 @@ test("width", function() {

el = $('<div></div>').dialog({width: 437 });
equals(dlg().width(), 437, "explicit width");
el.data('width.dialog', 438);
el.dialog('option', 'width', 438);
equals(dlg().width(), 438, 'explicit width after init');
el.remove();
});
@@ -30,16 +30,14 @@ test("init", function() {
$("<div></div>").draggable().draggable("foo");
ok(true, 'arbitrary method called after init');

$("<div></div>").draggable().data("foo.draggable");
$("<div></div>").draggable().draggable("option", "foo");
ok(true, 'arbitrary option getter after init');

$("<div></div>").draggable().data("foo.draggable", "bar");
$("<div></div>").draggable().draggable("option", "foo", "bar");
ok(true, 'arbitrary option setter after init');
});

test("destroy", function() {
expect(7);

$("<div></div>").appendTo('body').draggable().draggable("destroy").remove();
ok(true, '.draggable("destroy") called on element');

@@ -52,12 +50,6 @@ test("destroy", function() {
$("<div></div>").draggable().draggable("destroy").draggable("foo");
ok(true, 'arbitrary method called after destroy');

$("<div></div>").draggable().draggable("destroy").data("foo.draggable");
ok(true, 'arbitrary option getter after destroy');

$("<div></div>").draggable().draggable("destroy").data("foo.draggable", "bar");
ok(true, 'arbitrary option setter after destroy');

var expected = $('<div></div>').draggable(),
actual = expected.draggable('destroy');
equals(actual, expected, 'destroy is chainable');
@@ -69,14 +61,14 @@ test("enable", function() {
shouldnotmove('.draggable({ disabled: true })');
el.draggable("enable");
shouldmove('.draggable("enable")');
equals(el.data("disabled.draggable"), false, "disabled.draggable getter");
equals(el.draggable("option", "disabled"), false, "disabled option getter");

el.draggable("destroy");
el.draggable({ disabled: true });
shouldnotmove('.draggable({ disabled: true })');
el.data("disabled.draggable", false);
equals(el.data("disabled.draggable"), false, "disabled.draggable setter");
shouldmove('.data("disabled.draggable", false)');
el.draggable("option", "disabled", false);
equals(el.draggable("option", "disabled"), false, "disabled option setter");
shouldmove('.draggable("option", "disabled", false)');

var expected = $('<div></div>').draggable(),
actual = expected.draggable('enable');
@@ -89,15 +81,15 @@ test("disable", function() {
shouldmove('.draggable({ disabled: false })');
el.draggable("disable");
shouldnotmove('.draggable("disable")');
equals(el.data("disabled.draggable"), true, "disabled.draggable getter");
equals(el.draggable("option", "disabled"), true, "disabled option getter");

el.draggable("destroy");

el.draggable({ disabled: false });
shouldmove('.draggable({ disabled: false })');
el.data("disabled.draggable", true);
equals(el.data("disabled.draggable"), true, "disabled.draggable setter");
shouldnotmove('.data("disabled.draggable", true)');
el.draggable("option", "disabled", true);
equals(el.draggable("option", "disabled"), true, "disabled option setter");
shouldnotmove('.draggable("option", "disabled", true)');

var expected = $('<div></div>').draggable(),
actual = expected.draggable('disable');
@@ -20,16 +20,14 @@ test("init", function() {
$("<div></div>").droppable().droppable("foo");
ok(true, 'arbitrary method called after init');

$("<div></div>").droppable().data("foo.droppable");
$("<div></div>").droppable().droppable("option", "foo");
ok(true, 'arbitrary option getter after init');

$("<div></div>").droppable().data("foo.droppable", "bar");
$("<div></div>").droppable().droppable("option", "foo", "bar");
ok(true, 'arbitrary option setter after init');
});

test("destroy", function() {
expect(7);

$("<div></div>").appendTo('body').droppable().droppable("destroy").remove();
ok(true, '.droppable("destroy") called on element');

@@ -41,12 +39,6 @@ test("destroy", function() {

$("<div></div>").droppable().droppable("destroy").droppable("foo");
ok(true, 'arbitrary method called after destroy');

$("<div></div>").droppable().droppable("destroy").data("foo.droppable");
ok(true, 'arbitrary option getter after destroy');

$("<div></div>").droppable().droppable("destroy").data("foo.droppable", "bar");
ok(true, 'arbitrary option setter after destroy');

var expected = $('<div></div>').droppable(),
actual = expected.droppable('destroy');
@@ -59,12 +51,12 @@ test("enable", function() {
shouldNotBeDroppable();
el.droppable("enable");
shouldBeDroppable();
equals(el.data("disabled.droppable"), false, "disabled.droppable getter");
equals(el.droppable("option", "disabled"), false, "disabled option getter");
el.droppable("destroy");
el.droppable({ disabled: true });
shouldNotBeDroppable();
el.data("disabled.droppable", false);
equals(el.data("disabled.droppable"), false, "disabled.droppable setter");
el.droppable("option", "disabled", false);
equals(el.droppable("option", "disabled"), false, "disabled option setter");
shouldBeDroppable();

var expected = $('<div></div>').droppable(),
@@ -78,12 +70,12 @@ test("disable", function() {
shouldBeDroppable();
el.droppable("disable");
shouldNotBeDroppable();
equals(el.data("disabled.droppable"), true, "disabled.droppable getter");
equals(el.droppable("option", "disabled"), true, "disabled option getter");
el.droppable("destroy");
el.droppable({ disabled: false });
shouldBeDroppable();
el.data("disabled.droppable", true);
equals(el.data("disabled.droppable"), true, "disabled.droppable setter");
el.droppable("option", "disabled", true);
equals(el.droppable("option", "disabled"), true, "disabled option setter");
shouldNotBeDroppable();

var expected = $('<div></div>').droppable(),
@@ -21,17 +21,15 @@ test("init", function() {
ok(true, 'arbitrary method called after init');

el = $('<div></div>').resizable()
var foo = el.data("foo.resizable");
var foo = el.resizable("option", "foo");
el.remove();
ok(true, 'arbitrary option getter after init');

$('<div></div>').resizable().data("foo.resizable", "bar").remove();
$('<div></div>').resizable().resizable("option", "foo", "bar").remove();
ok(true, 'arbitrary option setter after init');
});

test("destroy", function() {
expect(7);

$("<div></div>").appendTo('body').resizable().resizable("destroy").remove();
ok(true, '.resizable("destroy") called on element');

@@ -44,14 +42,6 @@ test("destroy", function() {
$('<div></div>').resizable().resizable("destroy").resizable("foo").remove();
ok(true, 'arbitrary method called after destroy');

el = $('<div></div>').resizable();
var foo = el.resizable("destroy").data("foo.resizable");
el.remove();
ok(true, 'arbitrary option getter after destroy');

$('<div></div>').resizable().resizable("destroy").data("foo.resizable", "bar").remove();
ok(true, 'arbitrary option setter after destroy');

var expected = $('<div></div>').resizable(),
actual = expected.resizable('destroy');
equals(actual, expected, 'destroy is chainable');
@@ -21,17 +21,15 @@ test("init", function() {
ok(true, 'arbitrary method called after init');

el = $("<div></div>").selectable()
var foo = el.data("foo.selectable");
var foo = el.selectable("option", "foo");
el.remove();
ok(true, 'arbitrary option getter after init');

$("<div></div>").selectable().data("foo.selectable", "bar").remove();
$("<div></div>").selectable().selectable("option", "foo", "bar").remove();
ok(true, 'arbitrary option setter after init');
});

test("destroy", function() {
expect(7);

$("<div></div>").appendTo('body').selectable().selectable("destroy").remove();
ok(true, '.selectable("destroy") called on element');

@@ -44,14 +42,6 @@ test("destroy", function() {
$("<div></div>").selectable().selectable("destroy").selectable("foo").remove();
ok(true, 'arbitrary method called after destroy');

el = $("<div></div>").selectable();
var foo = el.selectable("destroy").data("foo.selectable");
el.remove();
ok(true, 'arbitrary option getter after destroy');

$("<div></div>").selectable().selectable("destroy").data("foo.selectable", "bar").remove();
ok(true, 'arbitrary option setter after destroy');

var expected = $('<div></div>').selectable(),
actual = expected.selectable('destroy');
equals(actual, expected, 'destroy is chainable');

0 comments on commit b3a095d

Please sign in to comment.
You can’t perform that action at this time.