updating tests to latest QUnit, using same, fixing a few assertions that relied on type casting (mostly null/undefined)

This commit is contained in:
Jörn Zaefferer 2008-10-13 21:32:42 +00:00
parent 59109b7894
commit b6cb342c65
5 changed files with 27 additions and 38 deletions

View File

@ -11,11 +11,11 @@ var defaults = {
autoResize: true, autoResize: true,
buttons: {}, buttons: {},
disabled: false, disabled: false,
dialogClass: null, dialogClass: undefined,
draggable: true, draggable: true,
height: 200, height: 200,
maxHeight: null, maxHeight: undefined,
maxWidth: null, maxWidth: undefined,
minHeight: 100, minHeight: 100,
minWidth: 150, minWidth: 150,
modal: false, modal: false,
@ -67,7 +67,7 @@ function moved(dx, dy, msg) {
msg = msg ? msg + "." : ""; msg = msg ? msg + "." : "";
var actual = { left: offsetAfter.left, top: offsetAfter.top }; var actual = { left: offsetAfter.left, top: offsetAfter.top };
var expected = { left: offsetBefore.left + dx, top: offsetBefore.top + dy }; var expected = { left: offsetBefore.left + dx, top: offsetBefore.top + dy };
compare2(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg); same(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
} }
function shouldmove(why) { function shouldmove(why) {
@ -86,7 +86,7 @@ function resized(dw, dh, msg) {
msg = msg ? msg + "." : ""; msg = msg ? msg + "." : "";
var actual = { width: widthAfter, height: heightAfter }; var actual = { width: widthAfter, height: heightAfter };
var expected = { width: widthBefore + dw, height: heightBefore + dh }; var expected = { width: widthBefore + dw, height: heightBefore + dh };
compare2(actual, expected, 'resized[' + dragged.dx + ', ' + dragged.dy + '] ' + msg); same(actual, expected, 'resized[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
} }
function shouldresize(why) { function shouldresize(why) {
@ -185,10 +185,8 @@ test("element types", function() {
test("defaults", function() { test("defaults", function() {
el = $('<div/>').dialog(); el = $('<div/>').dialog();
$.each(defaults, function(key, val) { $.each(defaults, function(key, val) {
var actual = el.data(key + ".dialog"), expected = val, var actual = el.data(key + ".dialog"), expected = val;
method = (expected && expected.constructor == Object) ? same(actual, expected, key);
compare2 : equals;
method(actual, expected, key);
}); });
el.remove(); el.remove();
}); });
@ -244,7 +242,7 @@ test("autoResize", function() {
handle = $(".ui-resizable-se", dlg()); handle = $(".ui-resizable-se", dlg());
drag(handle, 50, 50); drag(handle, 50, 50);
actual = { height: el.height() }; actual = { height: el.height() };
compare2(actual, expected, '.dialog({ autoResize: false })'); same(actual, expected, '.dialog({ autoResize: false })');
el.remove(); el.remove();
el = $('<div>content<br>content<br>content<br>content<br>content</div>').dialog({ autoResize: true }); el = $('<div>content<br>content<br>content<br>content<br>content</div>').dialog({ autoResize: true });
before = { width: el.width(), height: el.height() }; before = { width: el.width(), height: el.height() };
@ -252,7 +250,7 @@ test("autoResize", function() {
drag(handle, 50, 50); drag(handle, 50, 50);
expected = { width: before.width + 50, height: before.height + 50 }; expected = { width: before.width + 50, height: before.height + 50 };
actual = { width: el.width(), height: el.height() }; actual = { width: el.width(), height: el.height() };
compare2(actual, expected, '.dialog({ autoResize: true })'); same(actual, expected, '.dialog({ autoResize: true })');
el.remove(); el.remove();
}); });

View File

@ -22,7 +22,7 @@ var moved = function (dx, dy, msg) {
msg = msg ? msg + "." : ""; msg = msg ? msg + "." : "";
var actual = { left: offsetAfter.left, top: offsetAfter.top }; var actual = { left: offsetAfter.left, top: offsetAfter.top };
var expected = { left: offsetBefore.left + dx, top: offsetBefore.top + dy }; var expected = { left: offsetBefore.left + dx, top: offsetBefore.top + dy };
compare2(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg); same(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
} }
function shouldmove(why) { function shouldmove(why) {
@ -266,7 +266,7 @@ test("{ containment: 'parent' }, relative", function() {
left: po.left + border(p, 'left') + margin(el, 'left'), left: po.left + border(p, 'left') + margin(el, 'left'),
top: po.top + border(p, 'top') + margin(el, 'top') top: po.top + border(p, 'top') + margin(el, 'top')
} }
compare2(offsetAfter, expected, 'compare offset to parent'); same(offsetAfter, expected, 'compare offset to parent');
}); });
test("{ containment: 'parent' }, absolute", function() { test("{ containment: 'parent' }, absolute", function() {
@ -277,7 +277,7 @@ test("{ containment: 'parent' }, absolute", function() {
left: po.left + border(p, 'left') + margin(el, 'left'), left: po.left + border(p, 'left') + margin(el, 'left'),
top: po.top + border(p, 'top') + margin(el, 'top') top: po.top + border(p, 'top') + margin(el, 'top')
} }
compare2(offsetAfter, expected, 'compare offset to parent'); same(offsetAfter, expected, 'compare offset to parent');
}); });
test("{ cursor: 'move' }", function() { test("{ cursor: 'move' }", function() {
@ -571,7 +571,7 @@ test("{ helper: 'clone' }, absolute", function() {
drag(el, 1, 1); drag(el, 1, 1);
compare2({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] '); same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
}); });
@ -587,7 +587,7 @@ test("{ helper: 'clone' }, absolute with scroll offset on parent", function() {
drag(el, 1, 1); drag(el, 1, 1);
compare2({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] '); same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
$("#main")[0].scrollTop = 0; $("#main")[0].scrollTop = 0;
}); });
@ -604,7 +604,7 @@ test("{ helper: 'clone' }, absolute with scroll offset on root", function() {
drag(el, 1, 1); drag(el, 1, 1);
compare2({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] '); same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
$(document).scrollTop(0); $(document).scrollTop(0);
}); });
@ -622,7 +622,7 @@ test("{ helper: 'clone' }, absolute with scroll offset on root and parent", func
drag(el, 1, 1); drag(el, 1, 1);
compare2({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] '); same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
$(document).scrollTop(0); $(document).scrollTop(0);
$("#main")[0].scrollTop = 0; $("#main")[0].scrollTop = 0;

View File

@ -21,19 +21,19 @@ var drag = function(el, dx, dy, complete) {
}; };
var defaults = { var defaults = {
alsoResize: null, alsoResize: undefined,
aspectRatio: false, aspectRatio: false,
autoHide: false, autoHide: false,
containment: null, containment: undefined,
grid: null, grid: undefined,
handles: 'e,s,se', handles: 'e,s,se',
helper: null, helper: null,
disabled: false, disabled: false,
maxHeight: null, maxHeight: undefined,
maxWidth: null, maxWidth: undefined,
minHeight: 10, minHeight: 10,
minWidth: 10, minWidth: 10,
proportionallyResize: null proportionallyResize: undefined
}; };
// Resizable Tests // Resizable Tests
@ -107,10 +107,8 @@ test("element types", function() {
test("defaults", function() { test("defaults", function() {
el = $('<div/>').resizable(); el = $('<div/>').resizable();
$.each(defaults, function(key, val) { $.each(defaults, function(key, val) {
var actual = el.data(key + ".resizable"), expected = val, var actual = el.data(key + ".resizable"), expected = val;
method = (expected && expected.constructor == Object) ? same(actual, expected, key);
compare2 : equals;
method(actual, expected, key);
}); });
el.remove(); el.remove();
}); });

View File

@ -79,10 +79,8 @@ test("defaults", function() {
filter: '*' filter: '*'
}; };
$.each(defaults, function(key, val) { $.each(defaults, function(key, val) {
var actual = el.data(key + ".selectable"), expected = val, var actual = el.data(key + ".selectable"), expected = val;
method = (expected && expected.constructor == Object) ? same(actual, expected, key);
compare2 : equals;
method(actual, expected, key);
}); });
el.remove(); el.remove();
}); });

View File

@ -61,12 +61,7 @@ module('tabs');
for (var optionName in expected) { for (var optionName in expected) {
var actual = el.data(optionName + '.tabs'), expects = expected[optionName]; var actual = el.data(optionName + '.tabs'), expects = expected[optionName];
same(actual, expects, optionName);
if (optionName == 'disabled')
compare(actual, expects, optionName);
else
equals(actual, expects, optionName);
} }
}); });