]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Added test for close with ESCAPE for DropdownMenu.
authorMarius Olbertz <marius.olbertz@gmail.com>
Fri, 28 Apr 2017 05:37:03 +0000 (07:37 +0200)
committerMarius Olbertz <marius.olbertz@gmail.com>
Fri, 28 Apr 2017 05:37:03 +0000 (07:37 +0200)
test/javascript/components/dropdownMenu.js

index 897589262cef08d352ff6130828df6a65ee354bf..8c35b8d4a3b6c1637121e7cc835cf6622edf6bd8 100644 (file)
@@ -56,17 +56,19 @@ describe('Dropdown Menu', function () {
   });
 
   describe('keyboard events', function () {
-    it.skip('closes current sub menu using ESC', function () {
+    it('closes current sub menu using ESCAPE', function () {
       $html = $(template).appendTo('body');
       plugin = new Foundation.DropdownMenu($html, {});
 
       // Open it first
-      plugin._show($html.find('> li:nth-child(1)'));
+      plugin._show($html.find('> li:nth-child(1) > ul'));
 
-      $html.find('> li:nth-child(1) > a > li:first-child > a').focus()
+      $html.find('> li:nth-child(1) > ul > li:nth-child(1) > a').focus()
         .trigger(window.mockKeyboardEvent('ESCAPE'));
 
-      $html.find('li a').first();
+      $html.find('> li:nth-child(1)').should.not.have.class('is-active');
+      $html.find('> li:nth-child(1) > ul').should.not.have.class('js-dropdown-active');
+      document.activeElement.should.be.equal($html.find('> li:nth-child(1) > a')[0]);
     });
     it('moves focus to next tab on ARROW_RIGHT', function () {
       $html = $(template).appendTo('body');