]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Abide plug-in unit tests for checkbox and select 9784/head
authorKristofer Krause <kris.krause@gmail.com>
Thu, 16 Feb 2017 00:52:15 +0000 (19:52 -0500)
committerKristofer Krause <kris.krause@gmail.com>
Thu, 16 Feb 2017 00:52:15 +0000 (19:52 -0500)
test/javascript/components/abide.js

index b476bfe9269b65d6a6230033f96e1a4f9c6326be..13ae0e98b64bb0286207c010846eca982a7443b1 100644 (file)
@@ -34,6 +34,34 @@ describe('Abide', function() {
 
       plugin.validateInput($html.find("input")).should.equal(true);
     });
-  });
 
+    it('returns true for checked checkboxes', function() {
+      $html = $("<form data-abide><input type='checkbox' required checked='checked'></form>").appendTo("body");
+      plugin = new Foundation.Abide($html, {});
+
+      plugin.validateInput($html.find("input")).should.equal(true);
+    });
+
+    it('returns false for unchecked checkboxes', function() {
+      $html = $("<form data-abide><input type='checkbox' required></form>").appendTo("body");
+      plugin = new Foundation.Abide($html, {});
+
+      plugin.validateInput($html.find("input")).should.equal(false);
+    });
+
+    it('returns true for selected select option', function() {
+      $html = $("<form data-abide><select required><option value=''></option><option value='One'>One</option><option value='Two' selected='selected'>Two</option></select></form>").appendTo("body");
+      plugin = new Foundation.Abide($html, {});
+
+      plugin.validateInput($html.find("select")).should.equal(true);
+      $html.find("select").val().should.equal("Two");
+    });
+
+    it('returns false for unselected select option', function() {
+      $html = $("<form data-abide><select required><option value=''></option><option value='One'>One</option><option value='Two'>Two</option></select></form>").appendTo("body");
+      plugin = new Foundation.Abide($html, {});
+
+      plugin.validateInput($html.find("select")).should.equal(false);
+    });
+  });
 });