Created
March 6, 2013 18:06
-
-
Save johnantoni/5101566 to your computer and use it in GitHub Desktop.
assert.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
| .pass:before { | |
| content: 'PASS: '; | |
| color: blue; | |
| font-weight: bold; | |
| } | |
| .fail:before { | |
| content: 'FAIL: '; | |
| color: red; | |
| font-weight: bold; | |
| } |
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
| var output = document.getElementById('output'); | |
| function assert( outcome, description ) { | |
| var li = document.createElement('li'); | |
| li.className = outcome ? 'pass' : 'fail'; | |
| li.appendChild( document.createTextNode( description ) ); | |
| output.appendChild(li); | |
| }; |
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-US"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Easy JavaScript Testing </title> | |
| <style> | |
| .pass:before { | |
| content: 'PASS: '; | |
| color: blue; | |
| font-weight: bold; | |
| } | |
| .fail:before { | |
| content: 'FAIL: '; | |
| color: red; | |
| font-weight: bold; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <ul id="output"></ul> | |
| <script> | |
| var output = document.getElementById('output'); | |
| function assert( outcome, description ) { | |
| var li = document.createElement('li'); | |
| li.className = outcome ? 'pass' : 'fail'; | |
| li.appendChild( document.createTextNode( description ) ); | |
| output.appendChild(li); | |
| }; | |
| </script> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://net.tutsplus.com/tutorials/javascript-ajax/quick-tip-quick-and-easy-javascript-testing-with-assert/