b320d6381723eeb52102a9a4d945b0a616e286a9
[lhc/web/wiklou.git] / tests / qunit / suites / resources / jquery / jquery.tabIndex.js
1 module( 'jquery.tabIndex.js' );
2
3 test( '-- Initial check', function(){
4 expect(2);
5
6 ok( $.fn.firstTabIndex, '$.fn.firstTabIndex defined' );
7 ok( $.fn.lastTabIndex, '$.fn.lastTabIndex defined' );
8
9 });
10
11 test( 'firstTabIndex', function(){
12 expect(2);
13
14 var testEnvironment =
15 '<form>' +
16 '<input tabindex="7" />' +
17 '<input tabindex="9" />' +
18 '<textarea tabindex="2">Foobar</textarea>' +
19 '<textarea tabindex="5">Foobar</textarea>' +
20 '</form>';
21 var $testA = $( '<div />' ).html( testEnvironment ).appendTo( 'body' );
22
23 deepEqual( $testA.firstTabIndex(), 2, 'First tabindex should be 2 within this context.' );
24
25 var $testB = $( '<div />' );
26
27 deepEqual( $testB.firstTabIndex(), null, 'Return null if none available.' );
28
29 // Clean up
30 $testA.add( $testB).remove();
31 });
32
33 test( 'lastTabIndex', function(){
34 expect(2);
35
36 var testEnvironment =
37 '<form>' +
38 '<input tabindex="7" />' +
39 '<input tabindex="9" />' +
40 '<textarea tabindex="2">Foobar</textarea>' +
41 '<textarea tabindex="5">Foobar</textarea>' +
42 '</form>';
43 var $testA = $( '<div />' ).html( testEnvironment ).appendTo( 'body' );
44
45 deepEqual( $testA.lastTabIndex(), 9, 'Last tabindex should be 9 within this context.' );
46
47 var $testB = $( '<div />' );
48
49 deepEqual( $testB.lastTabIndex(), null, 'Return null if none available.' );
50
51 // Clean up
52 $testA.add( $testB).remove();
53 });