]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - tests/qunit/suites/resources/jquery/jquery.tabIndex.test.js
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / tests / qunit / suites / resources / jquery / jquery.tabIndex.test.js
diff --git a/tests/qunit/suites/resources/jquery/jquery.tabIndex.test.js b/tests/qunit/suites/resources/jquery/jquery.tabIndex.test.js
new file mode 100644 (file)
index 0000000..ec3539b
--- /dev/null
@@ -0,0 +1,35 @@
+( function ( $ ) {
+       QUnit.module( 'jquery.tabIndex', QUnit.newMwEnvironment() );
+
+       QUnit.test( 'firstTabIndex', function ( assert ) {
+               var html, $testA, $testB;
+               html = '<form>' +
+                       '<input tabindex="7" />' +
+                       '<input tabindex="9" />' +
+                       '<textarea tabindex="2">Foobar</textarea>' +
+                       '<textarea tabindex="5">Foobar</textarea>' +
+                       '</form>';
+
+               $testA = $( '<div>' ).html( html ).appendTo( '#qunit-fixture' );
+               assert.strictEqual( $testA.firstTabIndex(), 2, 'First tabindex should be 2 within this context.' );
+
+               $testB = $( '<div>' );
+               assert.strictEqual( $testB.firstTabIndex(), null, 'Return null if none available.' );
+       } );
+
+       QUnit.test( 'lastTabIndex', function ( assert ) {
+               var html, $testA, $testB;
+               html = '<form>' +
+                       '<input tabindex="7" />' +
+                       '<input tabindex="9" />' +
+                       '<textarea tabindex="2">Foobar</textarea>' +
+                       '<textarea tabindex="5">Foobar</textarea>' +
+                       '</form>';
+
+               $testA = $( '<div>' ).html( html ).appendTo( '#qunit-fixture' );
+               assert.strictEqual( $testA.lastTabIndex(), 9, 'Last tabindex should be 9 within this context.' );
+
+               $testB = $( '<div>' );
+               assert.strictEqual( $testB.lastTabIndex(), null, 'Return null if none available.' );
+       } );
+}( jQuery ) );