]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
test: add tabindex test for findFocusable() 12165/head
authorEric Defore <eric.defore@gmail.com>
Mon, 12 Oct 2020 20:43:28 +0000 (16:43 -0400)
committerEric Defore <eric.defore@gmail.com>
Mon, 12 Oct 2020 20:43:28 +0000 (16:43 -0400)
Added a test for the sorting element of Keyboard.findFocusable() to ensure tabindex sorting works properly

test/javascript/util/keyboard.js

index 836c69a0c8d6134e7b4fa1e6b3841dd29cd4f3d3..a9b4860e0923ce34eaff2130bea48b05948b549c 100644 (file)
@@ -177,6 +177,20 @@ describe('Keyboard util', function() {
 
       $html.remove();
     });
+
+    it('does sort by tabindex', function() {
+      let $html = $(`<div>
+            <a href="#" tabindex="1">Link1</a>
+            <a href="#">Link3</a>
+            <a href="#" tabindex="2">Link2</a>
+          </div>`).appendTo('body');
+
+      let $focusable = Foundation.Keyboard.findFocusable($html);
+
+      $focusable.eq(2)[0].should.be.equal($html.find('a').eq(1)[0]);
+
+      $html.remove();
+    });
   });
 
   describe('trapFocus()', function() {