@@ -10,24 +10,21 @@ test("accessibility", function () {
10
10
var link = button . children ( "a" ) ;
11
11
var ul = menu . children ( "ul" )
12
12
var links = ul . find ( "li.ui-menu-item a" ) ;
13
- expect ( 12 + links . length * 2 ) ;
14
-
15
- equals ( button . attr ( "aria-disabled" ) , "false" , "button aria-disabled" ) ;
16
- equals ( link . attr ( "aria-disabled" ) , "false" , "button link aria-disabled" ) ;
17
- equals ( link . attr ( "aria-haspopup" ) , "true" , "button link aria-haspopup" ) ;
18
- equals ( link . attr ( "role" ) , "button" , "button link role" ) ;
19
- equals ( link . attr ( "aria-owns" ) , ul . attr ( "id" ) , "button link aria-owns" ) ;
20
- equals ( link . attr ( "tabindex" ) , 0 , "button link tabindex" ) ;
13
+ expect ( 9 + links . length * 2 ) ;
21
14
22
- equals ( ul . attr ( "aria-hidden" ) , "true" , "menu aria-hidden" ) ;
23
- equals ( ul . attr ( "aria-disabled" ) , "false" , "menu aria-disabled" ) ;
24
- equals ( ul . attr ( "aria-labelledby" ) , link . attr ( "id" ) , "menu aria-labelledby" ) ;
25
- equals ( ul . attr ( "role" ) , "menubox" , "menu role" ) ;
26
- equals ( ul . attr ( "tabindex" ) , 0 , "menu tabindex" ) ;
27
- equals ( ul . attr ( "aria-activedescendant" ) , links . eq ( element [ 0 ] . selectedIndex ) . attr ( "id" ) , "menu aria-activedescendant" ) ;
15
+ equals ( "true" , link . attr ( "aria-haspopup" ) , "button link aria-haspopup" ) ;
16
+ equals ( "button" , link . attr ( "role" ) , "button link role" ) ;
17
+ equals ( ul . attr ( "id" ) , link . attr ( "aria-owns" ) , "button link aria-owns" ) ;
18
+ equals ( 0 , link . attr ( "tabindex" ) , "button link tabindex" ) ;
19
+
20
+ equals ( "true" , ul . attr ( "aria-hidden" ) , "menu aria-hidden" ) ;
21
+ equals ( link . attr ( "id" ) , ul . attr ( "aria-labelledby" ) , "menu aria-labelledby" ) ;
22
+ equals ( "menubox" , ul . attr ( "role" ) , "menu role" ) ;
23
+ equals ( 0 , ul . attr ( "tabindex" ) , "menu tabindex" ) ;
24
+ equals ( links . eq ( element [ 0 ] . selectedIndex ) . attr ( "id" ) , ul . attr ( "aria-activedescendant" ) , "menu aria-activedescendant" ) ;
28
25
$ . each ( links , function ( index ) {
29
- equals ( $ ( this ) . attr ( "role" ) , "option" , "menu link #" + index + " role" ) ;
30
- equals ( $ ( this ) . attr ( "tabindex" ) , - 1 , "menu link #" + index + " tabindex" ) ;
26
+ equals ( "option" , $ ( this ) . attr ( "role" ) , "menu link #" + index + " role" ) ;
27
+ equals ( - 1 , $ ( this ) . attr ( "tabindex" ) , "menu link #" + index + " tabindex" ) ;
31
28
} ) ;
32
29
} ) ;
33
30
@@ -43,24 +40,26 @@ $.each([
43
40
}
44
41
] , function ( i , settings ) {
45
42
test ( "state synchronization - " + settings . type , function ( ) {
46
- expect ( 6 ) ;
43
+ expect ( 5 ) ;
47
44
var element = $ ( settings . selector ) . selectmenu ( ) ;
48
45
var widget = element . selectmenu ( "widget" ) ;
49
46
var button = widget . filter ( ".ui-selectmenu-button" ) ;
50
47
var menu = widget . filter ( ".ui-selectmenu-menu" ) ;
48
+ var link = button . find ( "a" ) ;
49
+ var selected = element . find ( "option:selected" ) ;
51
50
52
- equals ( element [ 0 ] . value , element . selectmenu ( "option" , "value" ) , "inital value" ) ;
53
- equals ( element . find ( "option:selected" ) . text ( ) , button . text ( ) , "inital button text" ) ;
51
+ equals ( button . text ( ) , selected . text ( ) , "inital button text" ) ;
54
52
55
- button . find ( "a" ) . simulate ( "keydown" , { keyCode : $ . ui . keyCode . DOWN } ) ;
56
- equals ( element [ 0 ] . value , element . selectmenu ( "option" , "value" ) , "after keydown value " ) ;
57
- equals ( element . find ( "option:selected" ) . text ( ) , button . text ( ) , "after keydown button text" ) ;
53
+ link . simulate ( "keydown" , { keyCode : $ . ui . keyCode . DOWN } ) ;
54
+ equals ( element . find ( "option:selected" ) . val ( ) , selected . next ( "option" ) . val ( ) , "after keydown original select state " ) ;
55
+ equals ( button . text ( ) , selected . next ( "option" ) . text ( ) , "after keydown button text" ) ;
58
56
59
- button . find ( "a" ) . simulate ( "click" ) ;
60
- menu . find ( "a" ) . last ( ) . simulate ( "click" ) ;
61
- equals ( element [ 0 ] . value , element . selectmenu ( "option" , "value" ) , "after click value " ) ;
62
- equals ( element . find ( "option:selected " ) . text ( ) , button . text ( ) , "after click button text" ) ;
57
+ link . simulate ( "click" ) ;
58
+ menu . find ( "a" ) . last ( ) . simulate ( "mouseover" ) . simulate ( " click" ) ;
59
+ equals ( element . find ( "option:selected" ) . val ( ) , element . find ( "option" ) . last ( ) . val ( ) , "after click original select state " ) ;
60
+ equals ( button . text ( ) , element . find ( "option" ) . last ( ) . text ( ) , "after click button text" ) ;
63
61
} ) ;
64
62
} ) ;
65
63
64
+
66
65
} ) ( jQuery ) ;
0 commit comments