]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Use pull request #11210 from ncoden/chore/delete-components-after-tests for v6.5.0
authorNicolas Coden <nicolas@ncoden.fr>
Sat, 16 Jun 2018 08:08:12 +0000 (10:08 +0200)
committerNicolas Coden <nicolas@ncoden.fr>
Sat, 16 Jun 2018 20:58:48 +0000 (22:58 +0200)
b7ccd984d chore: clean component after DropdownMenu tests #11074
814d2e55f chore: clean component after Toggler tests
f9b61ff83 chore: clean focus after tests involving focus
9d39644d9 docs: add back comments in dropdownMenu tests

Signed-off-by: Nicolas Coden <nicolas@ncoden.fr>
test/javascript/components/accordion.js
test/javascript/components/drilldown.js
test/javascript/components/dropdown.js
test/javascript/components/dropdownMenu.js
test/javascript/components/offcanvas.js
test/javascript/components/reveal.js
test/javascript/components/toggler.js
test/javascript/util/keyboard.js

index 5ee78e112f04fe644fc2386866343fabb719ff4d..362a8fef197f902a78177e0ff1e2ce4288a2877d 100644 (file)
@@ -27,6 +27,7 @@ describe('Accordion', function() {
 
   afterEach(function() {
     plugin.destroy();
+    document.activeElement.blur();
     $html.remove();
   });
 
@@ -139,7 +140,7 @@ describe('Accordion', function() {
       $html.find('.accordion-content').eq(0).should.have.attr('aria-hidden', 'false');
     });
   });
-  
+
   describe('keyboard events', function() {
     it('opens next panel on ARROW_DOWN', function() {
       $html = $(template).appendTo('body');
@@ -186,4 +187,4 @@ describe('Accordion', function() {
       $html.find('.accordion-content').eq(1).should.have.attr('aria-hidden', 'false');
     });
   });
-});
\ No newline at end of file
+});
index 7c13921a1aa8309d913c2642488f81f546284246..d3e83187ec448a8152c11e758b9ee2b9ed6c1345 100644 (file)
@@ -28,6 +28,7 @@ describe('Drilldown Menu', function() {
 
   afterEach(function() {
     plugin.destroy();
+    document.activeElement.blur();
     $html.remove();
   });
 
@@ -177,7 +178,7 @@ describe('Drilldown Menu', function() {
 
       // Open one first
       plugin._show($html.find('li.is-drilldown-submenu-parent').eq(2));
-      
+
       $html.one('closed.zf.drilldown', function() {
         $html.find('ul[data-submenu].is-active').each(function() {
           // Checking with .be.hidden is not possible because they don't have display: block but z-index: -1
@@ -310,7 +311,7 @@ describe('Drilldown Menu', function() {
 
       $html.find('> li:nth-child(1) > a').focus()
         .trigger(window.mockKeyboardEvent('ARROW_RIGHT'));
-      
+
       setTimeout(function() { // Timeout to make sure transition has ended
         $html.find('> li:nth-child(1) > ul > li[data-is-parent-link] a')[0].should.be.equal(document.activeElement);
         done();
@@ -329,4 +330,4 @@ describe('Drilldown Menu', function() {
       $html.find('> li:nth-child(1) > ul').should.have.class('is-closing');
     });
   });
-});
\ No newline at end of file
+});
index 9f7696a2410a9496be9cf5e59b58cee1350f4f25..e0331b06039c1a2aca3720b62fafd383521107f0 100644 (file)
@@ -17,6 +17,7 @@ describe('Dropdown', function() {
 
   afterEach(function() {
     plugin.destroy();
+    document.activeElement.blur();
     $dropdownController.remove();
     $dropdownContainer.remove();
   });
index 248fff807a05be362dd69466d6ad01c1df8b043d..73315ccdbc391a009b43c08e4a9a1bf1606a9044 100644 (file)
@@ -42,6 +42,7 @@ describe('Dropdown Menu', function () {
 
   afterEach(function () {
     plugin.destroy();
+    document.activeElement.blur();
     $html.remove();
   });
 
@@ -93,7 +94,7 @@ describe('Dropdown Menu', function () {
 
         $html.find('> li:nth-child(1)').should.have.class('is-active');
         $html.find('> li:nth-child(1) > ul').should.have.class('js-dropdown-active');
-        document.activeElement.should.be.equal($html.find('> li:nth-child(1) > ul > li:nth-child(1) > a')[0]); 
+        document.activeElement.should.be.equal($html.find('> li:nth-child(1) > ul > li:nth-child(1) > a')[0]);
       });
       it('moves focus to previous sub element on ARROW_UP', function () {
         // Open it first
@@ -113,7 +114,7 @@ describe('Dropdown Menu', function () {
 
         $html.find('> li:nth-child(1) > ul > li:nth-child(2)').should.have.class('is-active');
         $html.find('> li:nth-child(1) > ul > li:nth-child(2) > ul').should.have.class('js-dropdown-active');
-        document.activeElement.should.be.equal($html.find('> li:nth-child(1) > ul > li:nth-child(2) > ul > li:nth-child(1) > a')[0]);  
+        document.activeElement.should.be.equal($html.find('> li:nth-child(1) > ul > li:nth-child(2) > ul > li:nth-child(1) > a')[0]);
       });
     });
     describe('vertical', function() {
@@ -139,12 +140,9 @@ describe('Dropdown Menu', function () {
 
         $html.find('> li:nth-child(1)').should.have.class('is-active');
         $html.find('> li:nth-child(1) > ul').should.have.class('js-dropdown-active');
-        document.activeElement.should.be.equal($html.find('> li:nth-child(1) > ul > li:nth-child(1) > a')[0]); 
+        document.activeElement.should.be.equal($html.find('> li:nth-child(1) > ul > li:nth-child(1) > a')[0]);
       });
       it('moves focus to previous sub element on ARROW_UP', function () {
-        $html = $(template).appendTo('body');
-        plugin = new Foundation.DropdownMenu($html, {});
-
         // Open it first
         plugin._show($html.find('> li:nth-child(1) > ul'));
 
@@ -154,9 +152,6 @@ describe('Dropdown Menu', function () {
         document.activeElement.should.be.equal($html.find('> li:nth-child(1) > ul > li:nth-child(1) > a')[0]);
       });
       it('opens child element of sub menu on ARROW_RIGHT', function() {
-        $html = $(template).appendTo('body');
-        plugin = new Foundation.DropdownMenu($html, {});
-
         // Open it first
         plugin._show($html.find('> li:nth-child(1) > ul'));
 
@@ -165,8 +160,8 @@ describe('Dropdown Menu', function () {
 
         $html.find('> li:nth-child(1) > ul > li:nth-child(2)').should.have.class('is-active');
         $html.find('> li:nth-child(1) > ul > li:nth-child(2) > ul').should.have.class('js-dropdown-active');
-        document.activeElement.should.be.equal($html.find('> li:nth-child(1) > ul > li:nth-child(2) > ul > li:nth-child(1) > a')[0]);  
+        document.activeElement.should.be.equal($html.find('> li:nth-child(1) > ul > li:nth-child(2) > ul > li:nth-child(1) > a')[0]);
       });
     });
   });
-});
\ No newline at end of file
+});
index a031723316844bd91d57625e9ce1eb592cc7f9fc..7391de6334244d2cb488683d3541e312c1dd3fa8 100644 (file)
@@ -34,6 +34,7 @@ describe('Off Canvas', function() {
 
   afterEach(function() {
     plugin.destroy();
+    document.activeElement.blur();
     $html.remove();
   });
 
@@ -252,7 +253,7 @@ describe('Off Canvas', function() {
       plugin.toggle();
     });
   });
-  
+
   describe('keyboard events', function() {
     it('closes Off Canvas on ESCAPE', function(done) {
       $html = $(template).appendTo('body');
index 5e38b431b9de8ed7aa6a54c3074fe78ba67a5137..1c20797a8ec1dacd08bb0e9436398c75bfa551fc 100644 (file)
@@ -10,6 +10,7 @@ describe('Reveal', function() {
 
   afterEach(function() {
     plugin.destroy();
+    document.activeElement.blur();
     $html.remove();
   });
 
index 7d90107950121e9b4f69084a35509a326bef268f..84a82a2972a9363dd60b8afff11f89f6be160899 100644 (file)
@@ -54,7 +54,6 @@ describe('Toggler', function() {
       plugin = new Foundation.Toggler($html, {});
 
       $triggers.find('[data-open], [data-close], [data-toggle]').should.have.attr('aria-controls', 'toggler');
-
       $triggers.remove();
     });
 
@@ -64,6 +63,7 @@ describe('Toggler', function() {
       plugin = new Foundation.Toggler($html, {});
 
       $triggers.find('[data-open], [data-close], [data-toggle]').should.have.attr('aria-expanded', 'true');
+      $triggers.remove();
     });
 
     it('sets aria-expanded to false if the element is invisible', function() {
@@ -73,6 +73,7 @@ describe('Toggler', function() {
       plugin = new Foundation.Toggler($html, {});
 
       $triggers.find('[data-open], [data-close], [data-toggle]').should.have.attr('aria-expanded', 'false');
+      $triggers.remove();
       $css.remove();
     });
   });
@@ -104,6 +105,8 @@ describe('Toggler', function() {
 
       plugin._toggleClass();
       $triggers.find('[data-open], [data-close], [data-toggle]').should.have.attr('aria-expanded', 'false');
+
+      $triggers.remove();
     });
   });
 
index ecec0f5206d59c4c23dbf0f570f746cc4cbb3321..836c69a0c8d6134e7b4fa1e6b3841dd29cd4f3d3 100644 (file)
@@ -19,6 +19,10 @@ describe('Keyboard util', function() {
     'ARROW_DOWN': 40
   };
 
+  afterEach(function() {
+    document.activeElement.blur();
+  });
+
   it('exists on the Foundation API', function() {
     (window.Foundation.Keyboard).should.be.an('object');
   });