Skip to content
Permalink
Browse files

Spinner tests: Fixed line endings.

  • Loading branch information
scottgonzalez committed Aug 7, 2011
1 parent 380c2e6 commit 8799ba08225d00113df2ed9d5ff4cf9f69b1dd22
@@ -1,45 +1,45 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Spinner Test Suite</title>

<link rel="stylesheet" href="../../../themes/base/jquery.ui.spinner.css">

<script src="../../jquery.js"></script>
<script src="../../../external/jquery.mousewheel-3.0.4.js"></script>
<script src="../../../external/jquery.global.js"></script>
<script src="../../../ui/jquery.ui.core.js"></script>
<script src="../../../ui/jquery.ui.widget.js"></script>
<script src="../../../ui/jquery.ui.button.js"></script>
<script src="../../../ui/jquery.ui.spinner.js"></script>

<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>

<script src="spinner_test_helpers.js"></script>
<script src="spinner_core.js"></script>
<script src="spinner_defaults.js"></script>
<script src="spinner_events.js"></script>
<script src="spinner_methods.js"></script>
<script src="spinner_options.js"></script>

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

<h1 id="qunit-header">jQuery UI Spinner Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">

<input id="spin" class="foo">
<input id="spin2" value="2">

</div>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Spinner Test Suite</title>

<link rel="stylesheet" href="../../../themes/base/jquery.ui.spinner.css">

<script src="../../jquery.js"></script>
<script src="../../../external/jquery.mousewheel-3.0.4.js"></script>
<script src="../../../external/jquery.global.js"></script>
<script src="../../../ui/jquery.ui.core.js"></script>
<script src="../../../ui/jquery.ui.widget.js"></script>
<script src="../../../ui/jquery.ui.button.js"></script>
<script src="../../../ui/jquery.ui.spinner.js"></script>

<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>

<script src="spinner_test_helpers.js"></script>
<script src="spinner_core.js"></script>
<script src="spinner_defaults.js"></script>
<script src="spinner_events.js"></script>
<script src="spinner_methods.js"></script>
<script src="spinner_options.js"></script>

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

<h1 id="qunit-header">jQuery UI Spinner Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">

<input id="spin" class="foo">
<input id="spin2" value="2">

</div>
</body>
</html>
@@ -1,151 +1,151 @@
(function( $ ) {

module( "spinner: core" );

// TODO: move to spinner_methods
test( "destroy", function() {
expect( 1 );
// TODO: is this cheat still needed?
// cheat a bit to get IE6 to pass
$( "#spin" ).val( 0 );
domEqual( "#spin", function() {
$( "#spin" ).spinner().spinner( "destroy" );
});
});

test( "keydown UP on input, increases value not greater than max", function() {
expect( 5 );
var element = $( "#spin" ).spinner({
max: 100,
value: 70,
step: 10
});

spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
equals( element.val(), 80 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
equals( element.val(), 90 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
equals( element.val(), 100 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
equals( element.val(), 100 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
equals( element.val(), 100 );
});

test( "keydown DOWN on input, decreases value not less than min", function() {
expect( 5 );
var element = $( "#spin" ).spinner({
min: 20,
value: 50,
step: 10
});

spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
equals( element.val(), 40 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
equals( element.val(), 30 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
equals( element.val(), 20 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
equals( element.val(), 20 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
equals( element.val(), 20 );
});

test( "keydown PGUP on input, increases value not greater than max", function() {
expect( 5 );
var element = $( "#spin" ).spinner({
max: 100,
value: 70,
page: 10
});

spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
equals( element.val(), 80 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
equals( element.val(), 90 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
equals( element.val(), 100 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
equals( element.val(), 100 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
equals( element.val(), 100 );
});

test( "keydown PGDN on input, decreases value not less than min", function() {
expect( 5 );
var element = $( "#spin" ).spinner({
min: 20,
value: 50,
page: 10
});

spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
equals( element.val(), 40 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
equals( element.val(), 30 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
equals( element.val(), 20 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
equals( element.val(), 20 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
equals( element.val(), 20 );
});

test( "mouse click on buttons", function() {
expect( 2 );
var element = $( "#spin" ).spinner(),
val = 0;

$( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );
equals( element.val(), ++val, "mouse click on up" );

$( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
equals( element.val(), --val, "mouse click on down");
});

test( "mouse wheel on input", function() {
expect( 4 );

var element = $( "#spin" ).spinner();
equal( element.val(), 0 );
element.trigger( "mousewheel", 1 );
equal( element.val(), 1 );

element.trigger( "mousewheel", -1 );
equal( element.val(), 0 );

element.trigger( "mousewheel", -1 );
equal(element.val(), -1 );
});

test( "reading HTML5 attributes", function() {
expect( 4 );
var element = $( "<input id='spinner' type='number' min='-100' max='100' value='5' step='2'>" ).spinner();
equals( element.spinner( "option", "value" ), 5, "value" );
equals( element.spinner( "option", "max" ), 100, "max" );
equals( element.spinner( "option", "min" ), -100, "min" );
equals( element.spinner( "option", "step" ), 2, "step" );
});

test( "ARIA attributes", function() {
expect( 7 );
var element = $( "#spin" ).spinner({ min: -5, max: 5, value: 2 });

equals( element.attr( "role" ), "spinbutton", "role" );
equals( element.attr( "aria-valuemin" ), -5, "aria-valuemin" );
equals( element.attr( "aria-valuemax" ), 5, "aria-valuemax" );
equals( element.attr( "aria-valuenow" ), 2, "aria-valuenow" );

element.spinner( "stepUp" );

equals( element.attr( "aria-valuenow" ), 3, "stepUp 1 step changes aria-valuenow" );

element.spinner( "option", { min: -10, max: 10 } );

equals( element.attr( "aria-valuemin" ), -10, "min option changed aria-valuemin changes" );
equals( element.attr( "aria-valuemax" ), 10, "max option changed aria-valuemax changes" );
});

})( jQuery );
(function( $ ) {

module( "spinner: core" );

// TODO: move to spinner_methods
test( "destroy", function() {
expect( 1 );
// TODO: is this cheat still needed?
// cheat a bit to get IE6 to pass
$( "#spin" ).val( 0 );
domEqual( "#spin", function() {
$( "#spin" ).spinner().spinner( "destroy" );
});
});

test( "keydown UP on input, increases value not greater than max", function() {
expect( 5 );
var element = $( "#spin" ).spinner({
max: 100,
value: 70,
step: 10
});

spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
equals( element.val(), 80 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
equals( element.val(), 90 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
equals( element.val(), 100 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
equals( element.val(), 100 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
equals( element.val(), 100 );
});

test( "keydown DOWN on input, decreases value not less than min", function() {
expect( 5 );
var element = $( "#spin" ).spinner({
min: 20,
value: 50,
step: 10
});

spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
equals( element.val(), 40 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
equals( element.val(), 30 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
equals( element.val(), 20 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
equals( element.val(), 20 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
equals( element.val(), 20 );
});

test( "keydown PGUP on input, increases value not greater than max", function() {
expect( 5 );
var element = $( "#spin" ).spinner({
max: 100,
value: 70,
page: 10
});

spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
equals( element.val(), 80 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
equals( element.val(), 90 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
equals( element.val(), 100 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
equals( element.val(), 100 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
equals( element.val(), 100 );
});

test( "keydown PGDN on input, decreases value not less than min", function() {
expect( 5 );
var element = $( "#spin" ).spinner({
min: 20,
value: 50,
page: 10
});

spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
equals( element.val(), 40 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
equals( element.val(), 30 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
equals( element.val(), 20 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
equals( element.val(), 20 );
spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
equals( element.val(), 20 );
});

test( "mouse click on buttons", function() {
expect( 2 );
var element = $( "#spin" ).spinner(),
val = 0;

$( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );
equals( element.val(), ++val, "mouse click on up" );

$( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
equals( element.val(), --val, "mouse click on down");
});

test( "mouse wheel on input", function() {
expect( 4 );

var element = $( "#spin" ).spinner();
equal( element.val(), 0 );
element.trigger( "mousewheel", 1 );
equal( element.val(), 1 );

element.trigger( "mousewheel", -1 );
equal( element.val(), 0 );

element.trigger( "mousewheel", -1 );
equal(element.val(), -1 );
});

test( "reading HTML5 attributes", function() {
expect( 4 );
var element = $( "<input id='spinner' type='number' min='-100' max='100' value='5' step='2'>" ).spinner();
equals( element.spinner( "option", "value" ), 5, "value" );
equals( element.spinner( "option", "max" ), 100, "max" );
equals( element.spinner( "option", "min" ), -100, "min" );
equals( element.spinner( "option", "step" ), 2, "step" );
});

test( "ARIA attributes", function() {
expect( 7 );
var element = $( "#spin" ).spinner({ min: -5, max: 5, value: 2 });

equals( element.attr( "role" ), "spinbutton", "role" );
equals( element.attr( "aria-valuemin" ), -5, "aria-valuemin" );
equals( element.attr( "aria-valuemax" ), 5, "aria-valuemax" );
equals( element.attr( "aria-valuenow" ), 2, "aria-valuenow" );

element.spinner( "stepUp" );

equals( element.attr( "aria-valuenow" ), 3, "stepUp 1 step changes aria-valuenow" );

element.spinner( "option", { min: -10, max: 10 } );

equals( element.attr( "aria-valuemin" ), -10, "min option changed aria-valuemin changes" );
equals( element.attr( "aria-valuemax" ), 10, "max option changed aria-valuemax changes" );
});

})( jQuery );

0 comments on commit 8799ba0

Please sign in to comment.
You can’t perform that action at this time.