Created
September 8, 2015 19:03
-
-
Save djom202/3045e01c6bc46718d7d3 to your computer and use it in GitHub Desktop.
QUnit (Pruebas Unitarias en Js)
This file contains hidden or 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
| <!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> |
This file contains hidden or 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
| function checkNumber( my_string ){ | |
| return (parseFloat(my_string) == my_string ? true : false); | |
| } |
This file contains hidden or 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
| $(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