Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 72 lines (60 sloc) 2.01 KB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>jocha.js</title>
<script language="JavaScript" type="text/javascript" src="jsunit/app/jsUnitCore.js"></script>
<script language="JavaScript" type="text/javascript" src="../prototype.js"></script>
<script language="JavaScript" type="text/javascript" src="../jocha.js"></script>
</head>
<body>
<script language="JavaScript" type="text/javascript">
function setUp() {
obj = new Object();
}
function tearDown() {
}
function testExpectsOnAnyObjectOverwritesTheNamedMethodAndVerifiesCalls() {
obj.expects("test");
assertFalse(obj.verify());
obj.test();
assertTrue(obj.verify());
}
function testWithParams() {
obj.expects("test").withParams("x", "y");
obj.test();
assertFalse(obj.verify());
obj.test("x","y")
assertTrue(obj.verify());
}
function testAndReturns() {
obj.expects("test").andReturns("pooka");
assertEquals("pooka", obj.test());
assertTrue(obj.verify());
}
function testAndReturnsWithParams() {
obj.expects("test").withParams("x", "y").andReturns("pooka");
assertNotEquals("pooka", obj.test());
assertFalse(obj.verify());
assertEquals("pooka", obj.test("x", "y"));
assertTrue(obj.verify());
}
function testWithHashParams() {
obj.expects("test").withParams({x:"x", y:"y"});
obj.test({x:"x", y:"y"});
assertTrue(obj.verify());
}
function testVerifyAll() {
var obj1 = new Object();
var obj2 = new Object();
var obj3 = new Object();
obj1.expects("a")
obj2.expects("a").withParams("x")
obj3.expects("a").withParams(1)
assertEquals(3, Jocha.mocks.length)
// Ironically and pathetically, testing failure here will actually fail the test
}
</script>
</body>
</html>