44
55( function ( $ ) {
66
7+ module ( "Filterable tests" ) ;
8+
9+ asyncTest ( "filterReveal filterable shows all items when all items match filter text" , function ( ) {
10+ var input = $ ( "#test-filter-reveal-show-all-input" ) ,
11+ list = $ ( "#test-filter-reveal-show-all-list" ) ;
12+
13+ expect ( 1 ) ;
14+
15+ input . val ( "Test" ) . trigger ( "change" ) ;
16+
17+ setTimeout ( function ( ) {
18+ deepEqual ( list . children ( ".ui-screen-hidden" ) . length , 0 ,
19+ "All items visible when search value matches them all" ) ;
20+ start ( ) ;
21+ } , 500 ) ;
22+ } ) ;
23+
724module ( "Backwards compatibility tests" ) ;
825
926test ( "Listview with filter has hideDividers option set to true" , function ( ) {
@@ -27,17 +44,19 @@ test( "Filterable input prevents default on ENTER", function() {
2744 deepEqual ( event . isDefaultPrevented ( ) , true , "Subsequent keypress default is also prevented" ) ;
2845} ) ;
2946
30- asyncTest ( "filterReveal filterable shows all items when all items match filter text " , function ( ) {
31- var input = $ ( "#test-filter-reveal-show-all-input " ) ,
32- list = $ ( "#test-filter-reveal-show-all-list " ) ;
33-
34- expect ( 1 ) ;
47+ asyncTest ( "Working filterable is instantiated on dynamic listview when data- filter='true' " , function ( ) {
48+ var list = $ ( "<ul data-nstest-filter='true'><li>Chicago</li><li>Berlin</li><li>Windsor</li></ul> " )
49+ . appendTo ( "#content " )
50+ . listview ( ) ,
51+ input = list . prev ( ) . find ( "input" ) ;
3552
36- input . val ( "Test" ) . trigger ( "change" ) ;
53+ expect ( 3 ) ;
3754
55+ deepEqual ( ! ! list . data ( "mobile-filterable" ) , true , "Filterable widget is present on listview" ) ;
56+ input . val ( "o" ) . trigger ( "change" ) ;
3857 setTimeout ( function ( ) {
39- deepEqual ( list . children ( ".ui-screen-hidden" ) . length , 0 ,
40- "All items visible when search value matches them all " ) ;
58+ deepEqual ( list . children ( ".ui-screen-hidden" ) . length , 1 , "One child was hidden" ) ;
59+ deepEqual ( list . children ( ".ui-screen-hidden" ) . text ( ) , "Berlin" , "'Berlin' was hidden " ) ;
4160 start ( ) ;
4261 } , 500 ) ;
4362} ) ;
0 commit comments