/
positioning4b_tests.js
48 lines (36 loc) · 1.83 KB
/
positioning4b_tests.js
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
module("combobox4 test", {
setup: function(){
S.open("//canui/form/combobox/positioning4b.html");
}
})
/*
* 4. Combobox positioning tests - Combobox appended to documentElement:
*
* 4a Tests that if the element can be positioned without scrolling below target, the dropdown opens bellow the target with full height.
* 4b Tests that if the element can be positioned with scrolling greater than min height, the dropdown opens bellow with height equal the space available.
* 4c Tests if the space above is greater than the space below and dropdown doesnt fit in space above, the dropdown opens to fit space avaialble above
* 4d Tests if the space above is less than the space below and the dropdown doesnt fit the space available the dropdown opens bellow to fi the space avaialble
*/
/*
* 4b Tests that if the element can be positioned with scrolling greater than min height,
* the dropdown opens bellow with height equal the space available.
*/
test("4b Tests that if the element can be positioned with scrolling greater than min height, the dropdown opens bellow with height equal the space available.", function() {
S("#combobox4b").exists();
S("#combobox4b").visible();
var comboOffset = S("#combobox4b").offset(),
comboTop = comboOffset.top,
comboBottom = comboTop + S("#combobox4b").outerHeight(),
windowHeight = S(S.window).height();
S("#combobox4b").find("input[type=text]").click();
S("#combobox4b_dropdown").visible();
// make sure the dropdown position is right
S("#combobox4b_dropdown").offset( function(offset) {
var dropTop = offset.top;
return Math.abs(comboBottom - dropTop) < 1;
});
// make sure dropdown height fits space available bellow
S("#combobox4b_dropdown").outerHeight( function(outerHeight) {
return Math.abs(outerHeight - windowHeight + comboBottom) < 1;
} );
});