From: Marius Olbertz Date: Thu, 20 Apr 2017 15:28:43 +0000 (+0200) Subject: Added tests for keyboard events for Off Canvas. X-Git-Tag: v6.4.0-rc1~50^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9434f4e80c0a843598a3e1f314be5580cdfda84b;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Added tests for keyboard events for Off Canvas. --- diff --git a/test/javascript/components/offcanvas.js b/test/javascript/components/offcanvas.js index f4f297429..a03172331 100644 --- a/test/javascript/components/offcanvas.js +++ b/test/javascript/components/offcanvas.js @@ -252,5 +252,23 @@ describe('Off Canvas', function() { plugin.toggle(); }); }); + + describe('keyboard events', function() { + it('closes Off Canvas on ESCAPE', function(done) { + $html = $(template).appendTo('body'); + plugin = new Foundation.OffCanvas($html.find('[data-off-canvas]'), {}); + + $html.one('opened.zf.offcanvas', function() { + plugin.$element.focus() + .trigger(window.mockKeyboardEvent('ESCAPE')); + + plugin.$element.should.not.have.class('is-open'); + done(); + }); + + // Open it first + plugin.open(); + }); + }); });