This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
141 changed files
with
2,132 additions
and
723 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* mobile buttonMarkup tests | ||
*/ | ||
(function($){ | ||
module("jquery.mobile.buttonMarkup.js"); | ||
|
||
asyncTest( "ui-btn-* should be applied based on a setting", function() { | ||
// force touch support so the timeout is set | ||
$.Event.prototype.originalEvent = { | ||
type: "touch" | ||
}; | ||
|
||
var $btn = $( "#hover-delay" ); | ||
|
||
|
||
$btn.trigger( "vmousedown" ); | ||
|
||
setTimeout(function() { | ||
ok( $btn.attr("class").indexOf( "ui-btn-down" ) == -1, "button doesn't have the down class yet" ); | ||
}, $.mobile.buttonMarkup.hoverDelay / 2); | ||
|
||
setTimeout(function() { | ||
ok( $btn.attr("class").indexOf( "ui-btn-down" ) >= 0, "button has the down class yet" ); | ||
start(); | ||
}, $.mobile.buttonMarkup.hoverDelay + 100 ); | ||
}); | ||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>jQuery Mobile Button Markup Test Suite</title> | ||
<!-- meta viewport left out on purpose for test append --> | ||
<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="../../../external/qunit.js"></script> | ||
<script src="../../jquery.testHelper.js"></script> | ||
<script> | ||
$.testHelper.asyncLoad([ | ||
[ | ||
"jquery.mobile.buttonMarkup", | ||
"widgets/controlgroup", | ||
"widgets/fixedToolbar", | ||
"widgets/forms/button", | ||
], | ||
[ "jquery.mobile.init" ], | ||
[ | ||
"buttonMarkup_core.js" | ||
] | ||
]); | ||
</script> | ||
|
||
<link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css" /> | ||
<link rel="stylesheet" href="../../../external/qunit.css"/> | ||
|
||
<script src="../../swarminject.js"></script> | ||
</head> | ||
<body> | ||
|
||
<h1 id="qunit-header">jQuery Mobile Button Markup Test Suite</h1> | ||
<h2 id="qunit-banner"></h2> | ||
<h2 id="qunit-userAgent"></h2> | ||
<ol id="qunit-tests"> | ||
</ol> | ||
|
||
<div data-nstest-role="page" id="default"> | ||
<div data-nstest-role="header" id="page-header"> | ||
<a id="header-button-1" data-role="button" href="index.html">Header button 1</a> | ||
<a id="header-button-2" data-role="button" href="index.html">Header button 2</a> | ||
</div> | ||
<div data-nstest-role="content" id="control-group-content"> | ||
<input type="submit" data-nstest-role="button" value="Double Enhanced?" id="double-enhanced" /> | ||
<a href="index.html" data-nstest-role="button" data-nstest-shadow="false">No shadow</a> | ||
<a href="index.html" data-nstest-role="button" data-nstest-corners="false">No corners</a> | ||
<a href="index.html" data-nstest-role="button" data-nstest-shadow="false" data-nstest-corners="false">No shadow or corners</a> | ||
<a href="index.html" data-nstest-role="button" data-nstest-icon="delete" data-nstest-iconshadow="false">No iconshadow</a> | ||
<button data-nstest-shadow="false" data-nstest-corners="false" data-nstest-icon="delete" data-nstest-iconshadow="false">None of the above</button> | ||
<svg id="embedded-svg" width="120" height="120" viewPort="0 0 120 120" version="1.1" xmlns="http://www.w3.org/2000/svg"> | ||
<rect x="10" y="10" width="100" height="100"/> | ||
</svg> | ||
|
||
<a href="docs-bars.html" data-nstest-role="button" id="full">Fullsize</a> | ||
<a href="docs-bars.html" data-nstest-role="button" data-nstest-mini="true" id="mini">Mini</a> | ||
|
||
<div data-nstest-role="controlgroup" data-nstest-mini="true" id="mini-control"> | ||
<a href="index.html" data-nstest-role="button">Yes</a> | ||
</div> | ||
|
||
<a id="iconpos1" data-nstest-role="button" href="index.html" data-nstest-icon="check">Default iconpos</a> | ||
<a id="iconpos2" data-nstest-role="button" href="index.html" data-nstest-icon="check" data-nstest-iconpos="left">Left iconpos</a> | ||
<a id="iconpos3" data-nstest-role="button" href="index.html" data-nstest-icon="check" data-nstest-iconpos="right">Right iconpos</a> | ||
<a id="hover-delay" data-nstest-role="button" href="index.html"></a> | ||
</div> | ||
<div data-nstest-role="footer" id="control-group-footer" class="ui-bar" data-nstest-position="inline"> | ||
<div data-nstest-role="controlgroup" data-nstest-type="horizontal"> | ||
<a href="index.html" data-nstest-icon="delete">Remove</a> | ||
<a href="index.html" data-nstest-icon="plus">Add</a> | ||
<a href="index.html" data-nstest-icon="arrow-u">Up</a> | ||
<a href="index.html" data-nstest-icon="arrow-d">Down</a> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
/* | ||
* mobile checkboxradio unit tests | ||
*/ | ||
(function($){ | ||
module( 'jquery.mobile.forms.checkboxradio.js' ); | ||
|
||
asyncTest( "radio button labels should update the active button class to last clicked and clear checked", function(){ | ||
var $radioBtns = $( '#radio-active-btn-test input' ), | ||
singleActiveAndChecked = function(){ | ||
deepEqual( $( "#radio-active-btn-test .ui-radio-on" ).length, 1, "there should be only one active button" ); | ||
// Use the .checked property, not the checked attribute which is not dynamic | ||
var numChecked = 0; | ||
$( "#radio-active-btn-test input" ).each(function(i, e) { | ||
if( e.checked ) { | ||
numChecked++; | ||
} | ||
}); | ||
deepEqual( numChecked, 1, "there should be only one checked" ); | ||
}; | ||
|
||
$.testHelper.sequence([ | ||
function(){ | ||
$radioBtns.last().siblings( 'label' ).click(); | ||
}, | ||
|
||
function(){ | ||
ok( $radioBtns.last().prop( 'checked' ), "last input is checked" ); | ||
ok( $radioBtns.last().siblings( 'label' ).hasClass( 'ui-radio-on' ), | ||
"last input label is an active button" ); | ||
|
||
ok( !$radioBtns.first().prop( 'checked' ), "first input label is not active" ); | ||
ok( !$radioBtns.first().siblings( 'label' ).hasClass( 'ui-radio-on' ), | ||
"first input label is not active" ); | ||
|
||
singleActiveAndChecked(); | ||
|
||
$radioBtns.first().siblings( 'label' ).click(); | ||
}, | ||
|
||
function(){ | ||
ok( $radioBtns.first().prop( 'checked' )); | ||
ok( $radioBtns.first().siblings( 'label' ).hasClass( 'ui-radio-on' ), | ||
"first input label is an active button" ); | ||
|
||
ok( !$radioBtns.last().prop( 'checked' )); | ||
ok( !$radioBtns.last().siblings( 'label' ).hasClass( 'ui-radio-on' ), | ||
"last input label is not active" ); | ||
|
||
singleActiveAndChecked(); | ||
|
||
start(); | ||
} | ||
], 500); | ||
|
||
}); | ||
|
||
asyncTest( "clicking the label triggers a click on the element", function() { | ||
var clicked = false; | ||
|
||
expect( 1 ); | ||
|
||
$( "#checkbox-click-triggered" ).one('click', function() { | ||
clicked = true; | ||
}); | ||
|
||
$.testHelper.sequence([ | ||
function() { | ||
$( "[for='checkbox-click-triggered']" ).click(); | ||
}, | ||
|
||
function() { | ||
ok(clicked, "click was fired on input"); | ||
start(); | ||
} | ||
], 2000); | ||
}); | ||
|
||
asyncTest( "clicking the label triggers a change on the element", function() { | ||
var changed = false; | ||
|
||
expect( 1 ); | ||
|
||
$( "#checkbox-change-triggered" ).one('change', function() { | ||
changed = true; | ||
}); | ||
|
||
$.testHelper.sequence([ | ||
function() { | ||
$( "[for='checkbox-change-triggered']" ).click(); | ||
}, | ||
|
||
function() { | ||
ok(changed, "change was fired on input"); | ||
start(); | ||
} | ||
], 2000); | ||
}); | ||
|
||
asyncTest( "form submission should include radio button values", function() { | ||
var $form = $( "#radio-form" ), $input = $form.find("input").first(); | ||
|
||
$.testHelper.pageSequence([ | ||
function() { | ||
$input.click(); | ||
$form.submit(); | ||
}, | ||
|
||
function( timeout ){ | ||
var check = location.hash || location.search; | ||
|
||
ok( check.indexOf("radio1=1") >= 0, "the radio was checked" ); | ||
|
||
// if the changepage in the previous function failed don't go back | ||
if( !timeout ){ | ||
window.history.back(); | ||
} | ||
}, | ||
|
||
function(){ | ||
start(); | ||
} | ||
]); | ||
}); | ||
|
||
asyncTest( "form submission should include checkbox button values", function() { | ||
var $form = $( "#check-form" ), $inputs = $form.find("input"); | ||
|
||
$.testHelper.pageSequence([ | ||
function() { | ||
$inputs.click(); | ||
$form.submit(); | ||
}, | ||
|
||
function( timeout ){ | ||
var check = location.hash || location.search; | ||
|
||
ok( check.indexOf("checkbox-form=on") >= 0, "the first checkbox was checked" ); | ||
ok( check.indexOf("checkbox-form-2=on") >= 0, "the second checkbox was checked" ); | ||
// if the changepage in the previous function failed don't go back | ||
if( !timeout ){ | ||
window.history.back(); | ||
} | ||
}, | ||
|
||
function(){ | ||
start(); | ||
} | ||
]); | ||
}); | ||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<div id="form-result" data-role="page"> | ||
</div> |
Oops, something went wrong.