From: Nicolas Coden Date: Tue, 31 Jul 2018 21:54:51 +0000 (+0200) Subject: test: add unit tests for Drilldown resizing on toggling X-Git-Tag: v6.6.0~3^2~124^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43c1fac659ac96ff5d1be08e1ca003c571323f48;p=thirdparty%2Ffoundation%2Ffoundation-sites.git test: add unit tests for Drilldown resizing on toggling --- diff --git a/test/javascript/components/drilldown.js b/test/javascript/components/drilldown.js index d3e83187e..9d805a7a1 100644 --- a/test/javascript/components/drilldown.js +++ b/test/javascript/components/drilldown.js @@ -26,6 +26,15 @@ describe('Drilldown Menu', function() {
  • Item 3
  • `; + var templateWithToggler = ` +
    + + +
    + `; + afterEach(function() { plugin.destroy(); document.activeElement.blur(); @@ -218,6 +227,41 @@ describe('Drilldown Menu', function() { }); }); + describe('toggle events', function () { + + this.timeout(0); + var $trigger, $target, $menu, togglerPlugin; + + beforeEach(function () { + $html = $(templateWithToggler).appendTo('body'); + $trigger = $html.find('#trigger'); + $target = $html.find('#target'); + $menu = $html.find('#m1'); + + togglerPlugin = new Foundation.Toggler($target, {}); + plugin = new Foundation.Drilldown($menu, {}); + }); + + it('correctly resize when opened', function () { + // Open the Drilldown + $trigger.focus().trigger('click'); + + $menu.height().should.be.within(110, 120); + }); + + it('correctly resize when closed', function () { + // Open then close the Drilldown + $trigger.focus().trigger('click'); + $trigger.focus().trigger('click'); + + $menu.height().should.be.equal(0); + }); + + afterEach(function () { + togglerPlugin.destroy(); + }); + + }); describe('keyboard events', function() { // Currently not testable, as triggered event won't move on focus