Merge "Beware that getContent() may return null"
[lhc/web/wiklou.git] / tests / qunit / suites / resources / jquery / jquery.tabIndex.test.js
1 ( function ( $ ) {
2 QUnit.module( 'jquery.tabIndex', QUnit.newMwEnvironment() );
3
4 QUnit.test( 'firstTabIndex', 2, function ( assert ) {
5 var html, $testA, $testB;
6 html =
7 '<form>' +
8 '<input tabindex="7" />' +
9 '<input tabindex="9" />' +
10 '<textarea tabindex="2">Foobar</textarea>' +
11 '<textarea tabindex="5">Foobar</textarea>' +
12 '</form>';
13
14 $testA = $( '<div>' ).html( html ).appendTo( '#qunit-fixture' );
15 assert.strictEqual( $testA.firstTabIndex(), 2, 'First tabindex should be 2 within this context.' );
16
17 $testB = $( '<div>' );
18 assert.strictEqual( $testB.firstTabIndex(), null, 'Return null if none available.' );
19 });
20
21 QUnit.test( 'lastTabIndex', 2, function ( assert ) {
22 var html, $testA, $testB;
23 html =
24 '<form>' +
25 '<input tabindex="7" />' +
26 '<input tabindex="9" />' +
27 '<textarea tabindex="2">Foobar</textarea>' +
28 '<textarea tabindex="5">Foobar</textarea>' +
29 '</form>';
30
31 $testA = $( '<div>' ).html( html ).appendTo( '#qunit-fixture' );
32 assert.strictEqual( $testA.lastTabIndex(), 9, 'Last tabindex should be 9 within this context.' );
33
34 $testB = $( '<div>' );
35 assert.strictEqual( $testB.lastTabIndex(), null, 'Return null if none available.' );
36 });
37 }( jQuery ) );