michael@0: module("dimensions"); michael@0: michael@0: test("innerWidth()", function() { michael@0: expect(3); michael@0: michael@0: var $div = $("#nothiddendiv"); michael@0: // set styles michael@0: $div.css({ michael@0: margin: 10, michael@0: border: "2px solid #fff", michael@0: width: 30 michael@0: }); michael@0: michael@0: equals($div.innerWidth(), 30, "Test with margin and border"); michael@0: $div.css("padding", "20px"); michael@0: equals($div.innerWidth(), 70, "Test with margin, border and padding"); michael@0: $div.hide(); michael@0: equals($div.innerWidth(), 70, "Test hidden div"); michael@0: michael@0: // reset styles michael@0: $div.css({ display: "", border: "", padding: "", width: "", height: "" }); michael@0: }); michael@0: michael@0: test("innerHeight()", function() { michael@0: expect(3); michael@0: michael@0: var $div = $("#nothiddendiv"); michael@0: // set styles michael@0: $div.css({ michael@0: margin: 10, michael@0: border: "2px solid #fff", michael@0: height: 30 michael@0: }); michael@0: michael@0: equals($div.innerHeight(), 30, "Test with margin and border"); michael@0: $div.css("padding", "20px"); michael@0: equals($div.innerHeight(), 70, "Test with margin, border and padding"); michael@0: $div.hide(); michael@0: equals($div.innerHeight(), 70, "Test hidden div"); michael@0: michael@0: // reset styles michael@0: $div.css({ display: "", border: "", padding: "", width: "", height: "" }); michael@0: }); michael@0: michael@0: test("outerWidth()", function() { michael@0: expect(6); michael@0: michael@0: var $div = $("#nothiddendiv"); michael@0: $div.css("width", 30); michael@0: michael@0: equals($div.outerWidth(), 30, "Test with only width set"); michael@0: $div.css("padding", "20px"); michael@0: equals($div.outerWidth(), 70, "Test with padding"); michael@0: $div.css("border", "2px solid #fff"); michael@0: equals($div.outerWidth(), 74, "Test with padding and border"); michael@0: $div.css("margin", "10px"); michael@0: equals($div.outerWidth(), 74, "Test with padding, border and margin without margin option"); michael@0: $div.css("position", "absolute"); michael@0: equals($div.outerWidth(true), 94, "Test with padding, border and margin with margin option"); michael@0: $div.hide(); michael@0: equals($div.outerWidth(true), 94, "Test hidden div with padding, border and margin with margin option"); michael@0: michael@0: // reset styles michael@0: $div.css({ position: "", display: "", border: "", padding: "", width: "", height: "" }); michael@0: }); michael@0: michael@0: test("outerHeight()", function() { michael@0: expect(6); michael@0: michael@0: var $div = $("#nothiddendiv"); michael@0: $div.css("height", 30); michael@0: michael@0: equals($div.outerHeight(), 30, "Test with only width set"); michael@0: $div.css("padding", "20px"); michael@0: equals($div.outerHeight(), 70, "Test with padding"); michael@0: $div.css("border", "2px solid #fff"); michael@0: equals($div.outerHeight(), 74, "Test with padding and border"); michael@0: $div.css("margin", "10px"); michael@0: equals($div.outerHeight(), 74, "Test with padding, border and margin without margin option"); michael@0: equals($div.outerHeight(true), 94, "Test with padding, border and margin with margin option"); michael@0: $div.hide(); michael@0: equals($div.outerHeight(true), 94, "Test hidden div with padding, border and margin with margin option"); michael@0: michael@0: // reset styles michael@0: $div.css({ display: "", border: "", padding: "", width: "", height: "" }); michael@0: });