Return to Snippet

Revision: 30923
at August 26, 2010 00:39 by Nettuts


Updated Code
<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title> Assert </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');
	
	// Via Resig
	function assert( outcome, explanation ) {
		var li = document.createElement('li');
		li.className = outcome ? 'pass' : 'fail';
		li.appendChild( document.createTextNode( explanation ) );
		output.appendChild(li);
	}
	
	assert( Array.prototype.each, 'Checking if the each method of the Array object is available, as an example.' );
</script>

Revision: 30922
at August 25, 2010 14:22 by Nettuts


Updated Code
<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title> Assert </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');
	
	// Via Resig
	function assert( outcome, explanation ) {
		var li = document.createElement('li');
		li.className = outcome ? 'pass' : 'fail';
		li.appendChild( document.createTextNode( explanation ) );
		results.appendChild(li);
	}
	
	assert( Array.prototype.each, 'Checking if the each method of the Array object is available, as an example.' );
</script>

Revision: 30921
at August 25, 2010 14:19 by Nettuts


Initial Code
<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title> Assert </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');
	
	// Via Resig
	function assert( outcome, explanation ) {
		var li = document.createElement('li');
		li.className = outcome ? 'pass' : 'fail';
		li.appendChild( document.createTextNode( explanation ) );
		results.appendChild(li);
	}
	
	assert( !!Array.prototype.each, 'Checking if the each method of the Array object is available, as an example.' );
</script>

Initial URL

                                

Initial Description

                                

Initial Title
Super Simple Assert JavaScript Testing

Initial Tags

                                

Initial Language
JavaScript