Merged dimensions with core
[jquery.git] / test / unit / dimensions.js
1 module("dimensions");
2
3 test("innerWidth()", function() {
4         expect(3);
5
6         var $div = $("#nothiddendiv");
7         // set styles
8         $div.css({
9                 margin: 10,
10                 border: "2px solid #fff",
11                 width: 30
12         });
13         
14         equals($div.innerWidth(), 30, "Test with margin and border");
15         $div.css("padding", "20px");
16         equals($div.innerWidth(), 70, "Test with margin, border and padding");
17         $div.hide();
18         equals($div.innerWidth(), 70, "Test hidden div");
19         
20         // reset styles
21         $div.css({ display: "", border: "", padding: "", width: "", height: "" });
22 });
23
24 test("innerHeight()", function() {
25         expect(3);
26         
27         var $div = $("#nothiddendiv");
28         // set styles
29         $div.css({
30                 margin: 10,
31                 border: "2px solid #fff",
32                 height: 30
33         });
34         
35         equals($div.innerHeight(), 30, "Test with margin and border");
36         $div.css("padding", "20px");
37         equals($div.innerHeight(), 70, "Test with margin, border and padding");
38         $div.hide();
39         equals($div.innerHeight(), 70, "Test hidden div");
40         
41         // reset styles
42         $div.css({ display: "", border: "", padding: "", width: "", height: "" });
43 });
44
45 test("outerWidth()", function() {
46         expect(6);
47         
48         var $div = $("#nothiddendiv");
49         $div.css("width", 30);
50         
51         equals($div.outerWidth(), 30, "Test with only width set");
52         $div.css("padding", "20px");
53         equals($div.outerWidth(), 70, "Test with padding");
54         $div.css("border", "2px solid #fff");
55         equals($div.outerWidth(), 74, "Test with padding and border");
56         $div.css("margin", "10px");
57         equals($div.outerWidth(), 74, "Test with padding, border and margin without margin option");
58         equals($div.outerWidth(true), 94, "Test with padding, border and margin with margin option");
59         $div.hide();
60         equals($div.outerWidth(true), 94, "Test hidden div with padding, border and margin with margin option");
61         
62         // reset styles
63         $div.css({ display: "", border: "", padding: "", width: "", height: "" });
64 });
65
66 test("outerHeight()", function() {
67         expect(6);
68         
69         var $div = $("#nothiddendiv");
70         $div.css("height", 30);
71         
72         equals($div.outerHeight(), 30, "Test with only width set");
73         $div.css("padding", "20px");
74         equals($div.outerHeight(), 70, "Test with padding");
75         $div.css("border", "2px solid #fff");
76         equals($div.outerHeight(), 74, "Test with padding and border");
77         $div.css("margin", "10px");
78         equals($div.outerHeight(), 74, "Test with padding, border and margin without margin option");
79         equals($div.outerHeight(true), 94, "Test with padding, border and margin with margin option");
80         $div.hide();
81         equals($div.outerHeight(true), 94, "Test hidden div with padding, border and margin with margin option");
82         
83         // reset styles
84         $div.css({ display: "", border: "", padding: "", width: "", height: "" });
85 });