mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Spinner test: currency and decimal options
test all: .load to load html from single html
This commit is contained in:
parent
9858045fcc
commit
9da87e28e6
81
tests/all_2.html
Normal file
81
tests/all_2.html
Normal file
@ -0,0 +1,81 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>jQuery UI All Tests</title>
|
||||
<link rel="stylesheet" href="qunit/testsuite.css" type="text/css" media="screen">
|
||||
|
||||
<script type="text/javascript" src="../jquery-1.2.6.js"></script>
|
||||
<script type="text/javascript" src="../ui/ui.core.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var components = ["accordion","autocomplete","datepicker","dialog","draggable","progressbar","resizable","selectable","slider","sortable","spinner"];
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
var $list = $("#individual_list"),
|
||||
$main = $("#main");
|
||||
|
||||
$.each(components, function(i, val){
|
||||
$list.append('<li><a href="' + val + '.html">' + val + '</a></li>');
|
||||
$('<div class="component_panel" id="' + val + '">').appendTo($main);
|
||||
$('div#'+val).load(val + '.html #main *');
|
||||
});
|
||||
|
||||
loadScripts();
|
||||
|
||||
function loadScripts() {
|
||||
if ( $("div.component_panel").length == components.length ) {
|
||||
$.each(components, function(i, val){
|
||||
$('head').append('<script type="text/javascript" src="'+val+'.js"></scr'+'pit>');
|
||||
});
|
||||
} else {
|
||||
setTimeout( function (){ loadScripts(); } ,10);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="../ui/ui.accordion.js"></script>
|
||||
<script type="text/javascript" src="../ui/ui.autocomplete.js"></script>
|
||||
<script type="text/javascript" src="../ui/ui.datepicker.js"></script>
|
||||
<script type="text/javascript" src="../ui/ui.dialog.js"></script>
|
||||
<script type="text/javascript" src="../ui/ui.draggable.js"></script>
|
||||
<script type="text/javascript" src="../ui/ui.droppable.js"></script>
|
||||
<script type="text/javascript" src="../ui/ui.progressbar.js"></script>
|
||||
<script type="text/javascript" src="../ui/ui.resizable.js"></script>
|
||||
<script type="text/javascript" src="../ui/ui.selectable.js"></script>
|
||||
<script type="text/javascript" src="../ui/ui.slider.js"></script>
|
||||
<script type="text/javascript" src="../ui/ui.sortable.js"></script>
|
||||
<script type="text/javascript" src="../ui/ui.spinner.js"></script>
|
||||
<script type="text/javascript" src="../ui/ui.tabs.js"></script>
|
||||
|
||||
<script type="text/javascript" src="qunit/testrunner.js"></script>
|
||||
<script type="text/javascript" src="simulate/jquery.simulate.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
@import "../themes/flora/flora.datepicker.css";
|
||||
.xerror, .error { display: none }
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body class="flora">
|
||||
<h1>jQuery UI All Tests</h1>
|
||||
<h2 id="banner"></h2>
|
||||
<h2 id="userAgent"></h2>
|
||||
|
||||
<h4>Run individual testsuites or doubleclick a test below</h4>
|
||||
<ul id="individual_list">
|
||||
</ul>
|
||||
|
||||
<ol id="tests"></ol>
|
||||
|
||||
<div id="main" style="position:absolute;top:-2000000px;">
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -17,15 +17,48 @@ test("init", function() {
|
||||
test("destroy", function() {
|
||||
expect(1);
|
||||
|
||||
$("#spin").spinner().spinner("destroy");
|
||||
$("#spin").spinner().spinner("destroy");
|
||||
ok(true, '.spinner("destroy") called on element');
|
||||
|
||||
});
|
||||
|
||||
test("re-attach", function() {
|
||||
expect(1);
|
||||
|
||||
el = $("#spin").spinner().spinner("destroy").spinner();
|
||||
ok(true, '.spinner().spinner("destroy").spinner() called on element');
|
||||
|
||||
});
|
||||
|
||||
test("disabled on init", function() {
|
||||
expect(1);
|
||||
|
||||
$("#spin").spinner({disabled:true});
|
||||
ok(true, '.spinner({disabled:true}) called on element');
|
||||
|
||||
});
|
||||
|
||||
test("disable", function() {
|
||||
expect(1);
|
||||
|
||||
$("#spin").spinner().spinner("disable");
|
||||
ok(true, '.spinner("disable") called on element');
|
||||
|
||||
});
|
||||
|
||||
test("enable", function() {
|
||||
expect(1);
|
||||
|
||||
$("#spin").spinner().spinner("destroy").spinner("enable");
|
||||
ok(true, '.spinner("enable") called on element');
|
||||
|
||||
});
|
||||
|
||||
test("defaults", function() {
|
||||
expect(5);
|
||||
expect(6);
|
||||
el = $("#spin").spinner();
|
||||
|
||||
equals(el.data("currency.spinner"), false, "currency");
|
||||
equals(el.data("incremental.spinner"), true, "incremental");
|
||||
equals(el.data("max.spinner"), undefined, "max");
|
||||
equals(el.data("min.spinner"), undefined, "min");
|
||||
@ -35,9 +68,10 @@ test("defaults", function() {
|
||||
});
|
||||
|
||||
test("set defaults on init", function() {
|
||||
expect(5);
|
||||
el = $("#spin").spinner({ incremental:false, max:200, min:-100, start:50, stepping:2 });
|
||||
expect(6);
|
||||
el = $("#spin").spinner({ currency:true, incremental:false, max:200, min:-100, start:50, stepping:2 });
|
||||
|
||||
equals(el.data("currency.spinner"), true, "currency");
|
||||
equals(el.data("incremental.spinner"), false, "incremental");
|
||||
equals(el.data("max.spinner"), 200, "max");
|
||||
equals(el.data("min.spinner"), -100, "min");
|
||||
@ -102,6 +136,31 @@ test("keydown on input with options", function() {
|
||||
equals(el.val(), -100, "Home key to min");
|
||||
|
||||
|
||||
});
|
||||
|
||||
test("currency and decimal options", function() {
|
||||
expect(4);
|
||||
|
||||
el = $("#spin").spinner({ currency:"$", incremental:false, max:120, min:-50, stepping:0.15 });
|
||||
|
||||
equals(el.val(), "$0.00", "start number");
|
||||
|
||||
el.simulate("keydown",{keyCode:$.simulate.VK_UP})
|
||||
.simulate("keyup",{keyCode:$.simulate.VK_UP});
|
||||
|
||||
equals(el.val(), "$0.15", "Stepping 0.15");
|
||||
|
||||
el.simulate("keydown",{keyCode:$.simulate.VK_END})
|
||||
.simulate("keyup",{keyCode:$.simulate.VK_END});
|
||||
|
||||
equals(el.val(), "$120.00", "End key to max");
|
||||
|
||||
el.simulate("keydown",{keyCode:$.simulate.VK_HOME})
|
||||
.simulate("keyup",{keyCode:$.simulate.VK_HOME});
|
||||
|
||||
equals(el.val(), "-$50.00", "Home key to min");
|
||||
|
||||
|
||||
});
|
||||
|
||||
test("spin without auto-incremental stepping", function() {
|
||||
@ -188,13 +247,13 @@ test("callback", function() {
|
||||
}
|
||||
});
|
||||
|
||||
for ( var i = 1 ; i<=10 ; i++ ) {
|
||||
for ( var i = 1 ; i<=5 ; i++ ) {
|
||||
el.simulate("keydown",{keyCode:$.simulate.VK_UP});
|
||||
}
|
||||
|
||||
el.simulate("keyup",{keyCode:$.simulate.VK_UP});
|
||||
|
||||
equals(s, 10, "Spin 10 times");
|
||||
equals(s, 5, "Spin 5 times");
|
||||
|
||||
el.simulate("keydown",{keyCode:$.simulate.VK_UP}).simulate("keyup",{keyCode:$.simulate.VK_UP});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user