]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Added test for additional reveal classes 9840/head
authorJeffrey de Graaf <jegr@avivasolutions.nl>
Mon, 6 Mar 2017 19:43:48 +0000 (20:43 +0100)
committerJeffrey de Graaf <jegr@avivasolutions.nl>
Mon, 6 Mar 2017 19:43:48 +0000 (20:43 +0100)
While writing the test I've also refactored the additionalOverlayClasses
check.

js/foundation.reveal.js
test/javascript/components/reveal.js

index d0a8b81ea9d3a00ef2315eb9609b7684eb81295b..21e5a036d66e10c091739233d92e327b11241f04 100644 (file)
@@ -81,8 +81,14 @@ class Reveal {
    * @private
    */
   _makeOverlay() {
+    var additionalOverlayClasses = '';
+
+    if (this.options.additionalOverlayClasses) {
+      additionalOverlayClasses = ' ' + this.options.additionalOverlayClasses;
+    }
+
     return $('<div></div>')
-      .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
index 433a9256b731dafc97e8785d9e7682b6a61378f0..717b6c55a7e593319259b3fe253ee977e35a78f8 100644 (file)
@@ -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
+});