Commit a5296b81 authored by Romain Courteaud's avatar Romain Courteaud

Test the ready method.

parent 5620d6c9
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
RenderJSGadget.ready_list = []; RenderJSGadget.ready_list = [];
RenderJSGadget.ready = function (callback) { RenderJSGadget.ready = function (callback) {
this.ready_list.push(callback); this.ready_list.push(callback);
return this;
}; };
RenderJSGadget.declareMethod = function (name, callback) { RenderJSGadget.declareMethod = function (name, callback) {
......
...@@ -938,7 +938,7 @@ ...@@ -938,7 +938,7 @@
}); });
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// RenderJSGadget.declareMethod // RenderJSGadgetKlass.declareMethod
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
module("RenderJSGadgetKlass.declareMethod"); module("RenderJSGadgetKlass.declareMethod");
test('is chainable', function () { test('is chainable', function () {
...@@ -1053,4 +1053,47 @@ ...@@ -1053,4 +1053,47 @@
}); });
}); });
/////////////////////////////////////////////////////////////////
// RenderJSGadgetKlass.ready
/////////////////////////////////////////////////////////////////
module("RenderJSGadgetKlass.ready");
test('is chainable', function () {
// Check that ready is chainable
// Subclass RenderJSGadget to not pollute its namespace
var Klass = function () {
RenderJSGadget.call(this);
}, gadget, result;
Klass.prototype = new RenderJSGadget();
Klass.prototype.constructor = Klass;
Klass.ready_list = [];
Klass.ready = RenderJSGadget.ready;
gadget = new Klass();
result = Klass.ready(function () {
var a;
});
// ready is chainable
equal(result, Klass);
});
test('store callback in the ready_list property', function () {
// Check that ready is chainable
// Subclass RenderJSGadget to not pollute its namespace
var Klass = function () {
RenderJSGadget.call(this);
}, gadget, result,
callback = function () {var a; };
Klass.prototype = new RenderJSGadget();
Klass.prototype.constructor = Klass;
Klass.ready_list = [];
Klass.ready = RenderJSGadget.ready;
gadget = new Klass();
Klass.ready(callback);
// ready is chainable
deepEqual(Klass.ready_list, [callback]);
});
}(document, jQuery, renderJS, QUnit, sinon)); }(document, jQuery, renderJS, QUnit, sinon));
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