Skip to content

Commit

Permalink
Add console log plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaclayton committed Jun 3, 2010
1 parent 9eb369a commit c729aa5
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions console-log-plugin.html
@@ -0,0 +1,46 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="qunit.css" type="text/css"/>
<script src="http://code.jquery.com/jquery-1.4.2.js"> </script>
<script type="text/javascript" src="qunit.js"></script>

<script type="text/javascript">
// selector plugin
$.fn.log = function() {
return this.each(function() {
console.log($(this));
});
};
</script>
<script type="text/javascript">
var loggedItems = []
oldConsoleLog = console.log;

console.log = function(whatever) {
loggedItems.push(whatever.get());
oldConsoleLog(whatever);
}

QUnit.testStart = function(name) {
loggedItems = [];
};
test("console logging", function() {
$("div.workspace").log();

same(loggedItems,
[$("div.workspace").get()],
"logged items should contain workspace")
});
</script>
</head>
<body>
<h1 id="qunit-header">QUnit example</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests">
</ol>
<div class="workspace"></div>
</body>
</html>

0 comments on commit c729aa5

Please sign in to comment.