Adds unit tests for radio input widget.
authorSalvatore Iovene <salvatore.iovene@intel.com>
Wed, 16 Jan 2013 08:58:50 +0000 (10:58 +0200)
committerSalvatore Iovene <salvatore.iovene@intel.com>
Wed, 16 Jan 2013 08:58:50 +0000 (10:58 +0200)
tests/index.html
tests/unit/cowhide-radio-input.js [new file with mode: 0644]

index a3caf1f..f88140c 100644 (file)
@@ -38,6 +38,7 @@
   <script src="../src/javascripts/cowhide-checkbox-input.js"></script>
   <script src="../src/javascripts/cowhide-header.js"></script>
   <script src="../src/javascripts/cowhide-page.js"></script>
+  <script src="../src/javascripts/cowhide-radio-input.js"></script>
 
   <!-- unit tests -->
   <script src="unit/bootstrap-transition.js"></script>
@@ -59,6 +60,7 @@
   <script src="unit/cowhide-core.js"></script>
   <script src="unit/cowhide-header.js"></script>
   <script src="unit/cowhide-page.js"></script>
+  <script src="unit/cowhide-radio-input.js"></script>
 </head>
 <body>
   <div>
diff --git a/tests/unit/cowhide-radio-input.js b/tests/unit/cowhide-radio-input.js
new file mode 100644 (file)
index 0000000..0936006
--- /dev/null
@@ -0,0 +1,23 @@
+$(function () {
+
+    module("cowhide-radio-input", {
+      setup: function() {
+        // Resets the driving state
+        $.cowhide.setDrivingMode(false)
+      }
+    })
+
+      test("should be disabled when driving", function () {
+        var page = $('<div class="page"></div>')
+        var input = $('<input type="radio">test</input>')
+        input.appendTo(page)
+        input.ch_radio_input()
+        $.cowhide.setDrivingMode(true)
+        stop()
+        setTimeout(function () {
+          ok(input.attr('disabled'), 'input is disabled')
+          ok(input.hasClass('disabled'), 'input has disabled class')
+          start()
+        }, 0)
+      })
+})