From: Jeffrey de Graaf Date: Mon, 6 Mar 2017 19:43:48 +0000 (+0100) Subject: Added test for additional reveal classes X-Git-Tag: v6.4.0-rc1~103^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a676ee68643e103d0b347cd6afc1f83812d75112;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Added test for additional reveal classes While writing the test I've also refactored the additionalOverlayClasses check. --- diff --git a/js/foundation.reveal.js b/js/foundation.reveal.js index d0a8b81ea..21e5a036d 100644 --- a/js/foundation.reveal.js +++ b/js/foundation.reveal.js @@ -81,8 +81,14 @@ class Reveal { * @private */ _makeOverlay() { + var additionalOverlayClasses = ''; + + if (this.options.additionalOverlayClasses) { + additionalOverlayClasses = ' ' + this.options.additionalOverlayClasses; + } + return $('
') - .addClass('reveal-overlay' + ' ' + this.options.additionalOverlayClassNames) + .addClass('reveal-overlay' + additionalOverlayClasses) .appendTo(this.options.appendTo); } @@ -583,12 +589,12 @@ Reveal.defaults = { */ appendTo: "body", /** - * Allows adding additional class names to the reveal overlay + * Allows adding additional class names to the reveal overlay. * @option * @type {string} * @default '' */ - additionalOverlayClassNames: '' + additionalOverlayClasses: '' }; // Window exports diff --git a/test/javascript/components/reveal.js b/test/javascript/components/reveal.js index 433a9256b..717b6c55a 100644 --- a/test/javascript/components/reveal.js +++ b/test/javascript/components/reveal.js @@ -99,8 +99,16 @@ describe('Reveal', function() { $('body').should.have.class('is-reveal-open'); }); + it('adds optional overlay classes overlay element', function() { + $html = $(template).appendTo('body'); + plugin = new Foundation.Reveal($html, {additionalOverlayClasses: 'default'}); + + plugin.open(); + + $('.reveal-overlay').should.have.class('default'); + }); // TODO: Check if this.$element.trigger('closeme.zf.reveal', this.id) is correctly used. - + // it('closes previously opened modal if multipleOpened option is false', function(done) { // $html = $(template).appendTo('body'); // $html2 = $(template).attr('id', 'exampleModal2').appendTo('body'); @@ -187,7 +195,7 @@ describe('Reveal', function() { $('body').should.not.have.class('is-reveal-open'); done(); }); - + plugin.close(); }); it('does not remove class from body if another reveal is open', function(done) { @@ -223,7 +231,7 @@ describe('Reveal', function() { $html.should.be.hidden; done(); }); - + plugin.close(); }); @@ -298,4 +306,4 @@ describe('Reveal', function() { $html.should.be.visible; }); }); -}); \ No newline at end of file +});