Skip to content

Instantly share code, notes, and snippets.

@djom202
Created September 8, 2015 19:03
Show Gist options
  • Save djom202/3045e01c6bc46718d7d3 to your computer and use it in GitHub Desktop.
Save djom202/3045e01c6bc46718d7d3 to your computer and use it in GitHub Desktop.
QUnit (Pruebas Unitarias en Js)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/qunit/qunit-1.19.0.css" media="all" />
</head>
<body>
<div class="testing">
<div id="qunit"></div>
<div id="qunit-fixture"></div
</div>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/qunit/qunit-1.19.0.js"></script>
<script src="script.js"></script>
<script src="tests.js"></script>
</body>
</html>
function checkNumber( my_string ){
return (parseFloat(my_string) == my_string ? true : false);
}
$(function(){
/* My testing */
QUnit.test( "Testing checkNumber()", function( assert ) {
assert.ok( checkNumber( 0 ), "Passed!" );
assert.ok( checkNumber( 2 ), "Passed!" );
assert.ok( checkNumber( -4 ), "Passed!" );
assert.ok( checkNumber( 1 ), "Passed!" );
assert.ok( checkNumber( 'asdf' ), "NO Passed!" );
assert.ok( !checkNumber( 'asdf' ), "Passed!" );
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment