Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
48 lines (48 sloc) 1.75 KB
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>fn Test</title>
<meta name="author" content="Nick Kallen">
<script src="jspec.js"></script>
<script src="jquery-1.2.3.js"></script>
<script src="jquery.fn.js"></script>
<script>
$(document).ready(function() {
jspec.describe("fn", function() {
it("registers and applies a function bound to a name", function() {
var element = $("<div></div>");
element.fn({ name: function() { return "function invoked" } });
element.fn('name').should("==", "function invoked");
});
it("registers and applies a function of any arity", function() {
var element = $("<div></div>");
element.fn({ name: function(a, b, c) { return [a, b, c] } });
element.fn('name', 1, 2, 3).should("eq", [1, 2, 3]);
});
it("registers many functions", function() {
var element = $("<div></div>");
element.fn({
name1: function() { return 1 },
name2: function() { return 2 }
});
element.fn('name1').should("==", 1);
element.fn('name2').should("==", 2);
});
it("applies bound functions to each item in a collection", function() {
var elements = $("<div></div>").add($("<div></div>"));
var i = 0;
elements.fn({ call: function() { i++ } });
elements.fn('call');
i.should("==", 2);
});
});
});
</script>
</head>
<style type="text/css">
div#wrapper { display: none ;}
</style>
<body>
<div id="wrapper"><div id="hello">Hello</div></div>
</body>
</html>
Something went wrong with that request. Please try again.