98ff55081c07c52ec021488324c071c1ca45d1ee
[lhc/web/wiklou.git] / tests / qunit / suites / resources / jquery / jquery.tabIndex.test.js
1 module( 'jquery.tabIndex', QUnit.newMwEnvironment() );
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 test( 'firstTabIndex', function() {
11 expect(2);
12
13 var testEnvironment =
14 '<form>' +
15 '<input tabindex="7" />' +
16 '<input tabindex="9" />' +
17 '<textarea tabindex="2">Foobar</textarea>' +
18 '<textarea tabindex="5">Foobar</textarea>' +
19 '</form>';
20
21 var $testA = $( '<div>' ).html( testEnvironment ).appendTo( '#qunit-fixture' );
22 strictEqual( $testA.firstTabIndex(), 2, 'First tabindex should be 2 within this context.' );
23
24 var $testB = $( '<div>' );
25 strictEqual( $testB.firstTabIndex(), null, 'Return null if none available.' );
26 });
27
28 test( 'lastTabIndex', function() {
29 expect(2);
30
31 var testEnvironment =
32 '<form>' +
33 '<input tabindex="7" />' +
34 '<input tabindex="9" />' +
35 '<textarea tabindex="2">Foobar</textarea>' +
36 '<textarea tabindex="5">Foobar</textarea>' +
37 '</form>';
38
39 var $testA = $( '<div>' ).html( testEnvironment ).appendTo( '#qunit-fixture' );
40 strictEqual( $testA.lastTabIndex(), 9, 'Last tabindex should be 9 within this context.' );
41
42 var $testB = $( '<div>' );
43 strictEqual( $testB.lastTabIndex(), null, 'Return null if none available.' );
44 });