Permalink
Browse files

namespaced Jocha classes in Jocha wrapper, added verify method for al…

…l mocked objects

git-svn-id: file:///Users/jyurek/Backups/repositories/jocha/trunk@12 5317845c-832e-0410-b2c0-db6c5bc7c761
  • Loading branch information...
1 parent 45b0773 commit 4899965d6af898823c56412db5de590d0f4ce54d tfwright committed Apr 20, 2007
Showing with 18 additions and 7 deletions.
  1. +12 −7 jocha.js
  2. +6 −0 test/jocha_test.html
View
@@ -29,14 +29,17 @@ Object.prototype.attributes = function(){
return attributes;
}
-Mock = Class.create();
-Mock.prototype = {
+Jocha = {
+ mocks: []
+}
+Jocha.Mock = Class.create();
+Jocha.Mock.prototype = {
initialize : function() {
this.expectations = new Array();
}
}
-Expectation = Class.create();
-Expectation.prototype = {
+Jocha.Expectation = Class.create();
+Jocha.Expectation.prototype = {
initialize : function(functionName) {
this.functionName = functionName;
this.params = [];
@@ -57,9 +60,11 @@ Object.extend(Object.prototype, {
this[functionName] = function() {
return this.methodMocked(functionName, arguments);
};
- if (!this.mock)
- this.mock = new Mock();
- expectation = new Expectation(functionName);
+ if (!this.mock) {
+ this.mock = new Jocha.Mock();
+ Jocha.mocks.push(this.mock);
+ }
+ expectation = new Jocha.Expectation(functionName);
this.mock.expectations.push(expectation);
return expectation;
},
View
@@ -46,6 +46,12 @@
assertTrue(obj.verify());
}
+ function testWithHashParams() {
+ obj.expects("test").withParams({x:"x", y:"y"});
+ obj.test({x:"x", y:"y"});
+ assertTrue(obj.verify());
+ }
+
</script>
</body>
</html>

0 comments on commit 4899965

Please sign in to comment.