Commit 5620d6c9 authored by Romain Courteaud's avatar Romain Courteaud

declareMethod is callable on the class.

parent 275c38f2
...@@ -940,7 +940,7 @@ ...@@ -940,7 +940,7 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// RenderJSGadget.declareMethod // RenderJSGadget.declareMethod
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
module("RenderJSGadget.declareMethod"); module("RenderJSGadgetKlass.declareMethod");
test('is chainable', function () { test('is chainable', function () {
// Check that declareMethod is chainable // Check that declareMethod is chainable
...@@ -950,14 +950,15 @@ ...@@ -950,14 +950,15 @@
}, gadget, result; }, gadget, result;
Klass.prototype = new RenderJSGadget(); Klass.prototype = new RenderJSGadget();
Klass.prototype.constructor = Klass; Klass.prototype.constructor = Klass;
Klass.declareMethod = RenderJSGadget.declareMethod;
gadget = new Klass(); gadget = new Klass();
equal(gadget.testFoo, undefined); equal(gadget.testFoo, undefined);
result = gadget.declareMethod('testFoo', function () { result = Klass.declareMethod('testFoo', function () {
var a; var a;
}); });
// declareMethod is chainable // declareMethod is chainable
equal(result, gadget); equal(result, Klass);
}); });
test('creates methods on the prototype', function () { test('creates methods on the prototype', function () {
...@@ -969,10 +970,11 @@ ...@@ -969,10 +970,11 @@
}, gadget, called, result; }, gadget, called, result;
Klass.prototype = new RenderJSGadget(); Klass.prototype = new RenderJSGadget();
Klass.prototype.constructor = Klass; Klass.prototype.constructor = Klass;
Klass.declareMethod = RenderJSGadget.declareMethod;
gadget = new Klass(); gadget = new Klass();
equal(gadget.testFoo, undefined); equal(gadget.testFoo, undefined);
gadget.declareMethod('testFoo', function (value) { Klass.declareMethod('testFoo', function (value) {
called = value; called = value;
}); });
// Method is added on the instance class prototype // Method is added on the instance class prototype
...@@ -996,9 +998,10 @@ ...@@ -996,9 +998,10 @@
}, gadget; }, gadget;
Klass.prototype = new RenderJSGadget(); Klass.prototype = new RenderJSGadget();
Klass.prototype.constructor = Klass; Klass.prototype.constructor = Klass;
Klass.declareMethod = RenderJSGadget.declareMethod;
gadget = new Klass(); gadget = new Klass();
gadget.declareMethod('testFoo', function (value) { Klass.declareMethod('testFoo', function (value) {
return value; return value;
}); });
...@@ -1025,9 +1028,10 @@ ...@@ -1025,9 +1028,10 @@
}, gadget; }, gadget;
Klass.prototype = new RenderJSGadget(); Klass.prototype = new RenderJSGadget();
Klass.prototype.constructor = Klass; Klass.prototype.constructor = Klass;
Klass.declareMethod = RenderJSGadget.declareMethod;
gadget = new Klass(); gadget = new Klass();
gadget.declareMethod('testFoo', function (value) { Klass.declareMethod('testFoo', function (value) {
var dfr = $.Deferred(); var dfr = $.Deferred();
setTimeout(function () { setTimeout(function () {
dfr.reject(value); dfr.reject(value);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment