]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Added tests for #10604.
authorMarius Olbertz <marius.olbertz@gmail.com>
Sat, 7 Oct 2017 19:14:50 +0000 (21:14 +0200)
committerMarius Olbertz <marius.olbertz@gmail.com>
Sat, 7 Oct 2017 19:14:50 +0000 (21:14 +0200)
test/javascript/components/reveal.js

index 23908548bfd7dc69324fec58a1a234df674b23d0..5e38b431b9de8ed7aa6a54c3074fe78ba67a5137 100644 (file)
@@ -296,6 +296,27 @@ describe('Reveal', function() {
         }, 0);
       });
 
+      plugin.close();
+    });
+    it('sets focus to anchor that opened it', function(done) {
+      $html = $(template).appendTo('body');
+      var $anchor = $('<button data-open="exampleModal1">Open</button>').appendTo('body');
+      var $anchor2 = $('<button data-open="exampleModal1">Open2</button>').appendTo('body');
+      plugin = new Foundation.Reveal($html, {});
+      $anchor.focus();
+
+      // Open it first
+      plugin.open();
+
+      $html.on('closed.zf.reveal', function() {
+        setTimeout(function() {
+          $anchor[0].should.be.equal(document.activeElement);
+          $anchor.remove();
+          $anchor2.remove();
+          done();
+        }, 0);
+      });
+
       plugin.close();
     });
   });