From 9b28a543a325042b03e6dfca33a1b81820ab938b Mon Sep 17 00:00:00 2001 From: Marius Olbertz Date: Sat, 5 Nov 2016 15:40:34 +0100 Subject: [PATCH] Added unit tests for trapFocus option for Reveal. --- test/javascript/components/reveal.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/javascript/components/reveal.js b/test/javascript/components/reveal.js index 802d9ed62..bca91dc47 100644 --- a/test/javascript/components/reveal.js +++ b/test/javascript/components/reveal.js @@ -128,6 +128,17 @@ describe('Reveal', function() { plugin.open(); }); + + it('traps focus if trapFocus option is true', function() { + $html = $(template).appendTo('body'); + plugin = new Foundation.Reveal($html, {trapFocus: true}); + + let spy = sinon.spy(Foundation.Keyboard, 'trapFocus'); + plugin.open(); + + sinon.assert.called(spy); + Foundation.Keyboard.trapFocus.restore(); + }); }); describe('close()', function() { @@ -189,6 +200,20 @@ describe('Reveal', function() { plugin.close(); }); + + it('releases focus if trapFocus option is true', function() { + $html = $(template).appendTo('body'); + plugin = new Foundation.Reveal($html, {trapFocus: true}); + + // Open it first + plugin.open(); + + let spy = sinon.spy(Foundation.Keyboard, 'releaseFocus'); + plugin.close(); + + sinon.assert.called(spy); + Foundation.Keyboard.releaseFocus.restore(); + }); }); describe('toggle()', function() { -- 2.47.2