Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Checkboxradio: Depend on vmouse and test custom, widget-only-build
Browse files Browse the repository at this point in the history
(cherry picked from commit dc3fa7d)

Closes gh-7295
Fixes gh-7294
Re gh-5987
  • Loading branch information
Gabriel Schulhof committed Apr 24, 2014
1 parent 5f2dd7e commit 26b1d16
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions js/widgets/forms/checkboxradio.js
Expand Up @@ -10,6 +10,7 @@
//>>css.theme: ../css/themes/default/jquery.mobile.theme.css

define( [ "jquery",
"../../vmouse",
"../../navigation/path",
"../../jquery.mobile.core",
"../../jquery.mobile.widget",
Expand Down
36 changes: 36 additions & 0 deletions tests/unit/individual-modules/checkboxradio-tests.html
@@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery Mobile Collapsible Test Suite</title>

<script src="../../../external/requirejs/require.js"></script>
<script src="../../../js/requirejs.config.js"></script>
<script src="../../../js/jquery.tag.inserter.js"></script>
<script src="../../jquery.setNameSpace.js"></script>
<script src="../../../tests/jquery.testHelper.js"></script>

<link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css"/>
<link rel="stylesheet" href="../../../external/qunit/qunit.css"/>
<link rel="stylesheet" href="../../jqm-tests.css"/>
<script src="../../../external/qunit/qunit.js"></script>
<script>
$.testHelper.asyncLoad([
[
"widgets/forms/checkboxradio"
],
[
"checkboxradio_core.js"
]
]);
</script>

<script src="../../swarminject.js"></script>
</head>
<body>
<div id="qunit"></div>

<label>The Checkbox<input type="checkbox" id="the-checkbox"></label>
</body>
</html>
14 changes: 14 additions & 0 deletions tests/unit/individual-modules/checkboxradio_core.js
@@ -0,0 +1,14 @@
test( "Checkboxradio widget works correctly", function() {
var checkbox = $( "#the-checkbox" ).checkboxradio(),
initiallyChecked = checkbox.prop( "checked" );

deepEqual( checkbox.parent().hasClass( "ui-checkbox" ), true,
"Wrapper has class ui-checkbox" );
deepEqual( checkbox.siblings( "label" ).hasClass( "ui-btn" ), true,
"Input has a sibling <label> with class ui-btn" );

checkbox.siblings( "label" ).click();

deepEqual( checkbox.prop( "checked" ), !initiallyChecked,
"Clicking the label toggles the checkbox" );
});

0 comments on commit 26b1d16

Please sign in to comment.