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

Commit

Permalink
merge test split
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbender committed Mar 27, 2013
2 parents 5322b54 + b4460e1 commit 1ea9a85
Show file tree
Hide file tree
Showing 141 changed files with 2,132 additions and 723 deletions.
32 changes: 27 additions & 5 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,19 +359,41 @@ module.exports = function( grunt ) {
urls: (function() {
// Find the test files
var suites = grunt.util._.without( ( grunt.option( "suites" ) || "" ).split( "," ), "" ),
patterns, paths, idx,
types = grunt.util._.without( ( grunt.option( "types" ) || "" ).split( "," ), "" ),
patterns, paths, idx, prefixes = ["tests/unit/", "tests/integration/"],
onePath = "",
uniquePaths = [],
versionedPaths = [],
jQueries = grunt.util._.without( ( grunt.option( "jqueries" ) || process.env.JQUERIES || "" ).split( "," ), "" );

if( types.length ){
prefixes = [];
types.forEach(function( type ) {
prefixes.push( "tests/" + type +"/" );
});
}

patterns = [];

if ( suites.length ) {
patterns = [];
suites.forEach( function( suite ) {
patterns = patterns.concat( [ "tests/unit/" + suite + "/index.html", "tests/unit/" + suite + "/*/index.html", "tests/unit/" + suite + "/**/*-tests.html" ] );
suites.forEach( function( unit ) {
prefixes.forEach( function( prefix ) {
patterns = patterns.concat([
prefix + unit + "/",
prefix + unit + "/index.html",
prefix + unit + "/*/index.html",
prefix + unit + "/**/*-tests.html"
]);
});
});
} else {
patterns = [ "tests/unit/*/index.html", "tests/unit/*/*/index.html", "tests/unit/**/*-tests.html" ];
prefixes.forEach( function( prefix ) {
patterns = patterns.concat([
prefix + "*/index.html",
prefix + "*/*/index.html",
prefix + "**/*-tests.html"
]);
});
}

paths = grunt.file.expand( patterns )
Expand Down
27 changes: 27 additions & 0 deletions tests/integration/button-markup/buttonMarkup_core.js
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);
79 changes: 79 additions & 0 deletions tests/integration/button-markup/index.html
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>
150 changes: 150 additions & 0 deletions tests/integration/checkboxradio/checkboxradio_core.js
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);
2 changes: 2 additions & 0 deletions tests/integration/checkboxradio/form-result.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<div id="form-result" data-role="page">
</div>
Loading

0 comments on commit 1ea9a85

Please sign in to comment.