1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
/*
* core unit tests
*/
(function($) {
module('core - jQuery extensions');
test('focus', function() {
expect(3);
var el = $('#inputTabindex0'),
// used to remove focus from the main element
other = $('#inputTabindex10');
// test original functionality
el.focus(function() {
ok(true, 'event triggered');
});
el.focus();
other.focus();
// trigger event handler + callback
stop();
el.focus(500, function() {
ok(true, 'callback triggered');
start();
});
other.focus();
});
test('zIndex', function() {
var el = $('#zIndexAutoWithParent'),
parent = el.parent();
equals(el.zIndex(), 100, 'zIndex traverses up to find value');
equals(parent.zIndex(200), parent, 'zIndex setter is chainable');
equals(el.zIndex(), 200, 'zIndex setter changed zIndex');
el = $('#zIndexAutoWithParentViaCSS');
equals(el.zIndex(), 0, 'zIndex traverses up to find CSS value, not found because not positioned');
el = $('#zIndexAutoWithParentViaCSSPositioned');
equals(el.zIndex(), 100, 'zIndex traverses up to find CSS value');
el.parent().zIndex(200);
equals(el.zIndex(), 200, 'zIndex setter changed zIndex, overriding CSS');
equals($('#zIndexAutoNoParent').zIndex(), 0, 'zIndex never explicitly set in hierarchy');
});
test( "innerWidth - getter", function() {
var el = $( "#dimensions" );
equals( el.innerWidth(), 122, "getter passthru" );
el.hide();
equals( el.innerWidth(), 122, "getter passthru when hidden" );
});
test( "innerWidth - setter", function() {
var el = $( "#dimensions" );
el.innerWidth( 120 );
equals( el.width(), 98, "width set properly" );
el.hide();
el.innerWidth( 100 );
equals( el.width(), 78, "width set properly when hidden" );
});
test( "innerHeight - getter", function() {
var el = $( "#dimensions" );
equals( el.innerHeight(), 70, "getter passthru" );
el.hide();
equals( el.innerHeight(), 70, "getter passthru when hidden" );
});
test( "innerHeight - setter", function() {
var el = $( "#dimensions" );
el.innerHeight( 60 );
equals( el.height(), 40, "height set properly" );
el.hide();
el.innerHeight( 50 );
equals( el.height(), 30, "height set properly when hidden" );
});
test( "outerWidth - getter", function() {
var el = $( "#dimensions" );
equals( el.outerWidth(), 140, "getter passthru" );
el.hide();
equals( el.outerWidth(), 140, "getter passthru when hidden" );
});
test( "outerWidth - setter", function() {
var el = $( "#dimensions" );
el.outerWidth( 130 );
equals( el.width(), 90, "width set properly" );
el.hide();
el.outerWidth( 120 );
equals( el.width(), 80, "width set properly when hidden" );
});
test( "outerWidth(true) - getter", function() {
var el = $( "#dimensions" );
equals( el.outerWidth(true), 154, "getter passthru w/ margin" );
el.hide();
equals( el.outerWidth(true), 154, "getter passthru w/ margin when hidden" );
});
test( "outerWidth(true) - setter", function() {
var el = $( "#dimensions" );
el.outerWidth( 130, true );
equals( el.width(), 76, "width set properly" );
el.hide();
el.outerWidth( 120, true );
equals( el.width(), 66, "width set properly when hidden" );
});
test( "outerHeight - getter", function() {
var el = $( "#dimensions" );
equals( el.outerHeight(), 86, "getter passthru" );
el.hide();
equals( el.outerHeight(), 86, "getter passthru when hidden" );
});
test( "outerHeight - setter", function() {
var el = $( "#dimensions" );
el.outerHeight( 80 );
equals( el.height(), 44, "height set properly" );
el.hide();
el.outerHeight( 70 );
equals( el.height(), 34, "height set properly when hidden" );
});
test( "outerHeight(true) - getter", function() {
var el = $( "#dimensions" );
equals( el.outerHeight(true), 98, "getter passthru w/ margin" );
el.hide();
equals( el.outerHeight(true), 98, "getter passthru w/ margin when hidden" );
});
test( "outerHeight(true) - setter", function() {
var el = $( "#dimensions" );
el.outerHeight( 90, true );
equals( el.height(), 42, "height set properly" );
el.hide();
el.outerHeight( 80, true );
equals( el.height(), 32, "height set properly when hidden" );
});
})(jQuery);
|