From 43c1fac659ac96ff5d1be08e1ca003c571323f48 Mon Sep 17 00:00:00 2001 From: Nicolas Coden Date: Tue, 31 Jul 2018 23:54:51 +0200 Subject: [PATCH] test: add unit tests for Drilldown resizing on toggling --- test/javascript/components/drilldown.js | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+) 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 -- 2.47.2