I've been working on a simple project on Adobe Extend Script Toolkit and is having trouble implementing tests on private members. I have come up with a solution which is to expose the privates inside a callback to a special function. I'm not sure if this is a good pattern. I need suggestions.
Heres the pattern:
(function (global) {
var Loader, Require, Modules;
Require = 'Require Object';
Modules = 'Modules object';
Loader = {};
global.estk = global.estk || {};
global.estk.loader = Loader;
// This MUST be used for testing purposes only.
// Use this to test for private members.
global.estk.loader.__test__ = function (callback) {
callback.call(this, {
Require: Require,
Modules: Modules,
Loader: Loader
});
};
}($.global));
In my test file I can then call the exposed privates like this:
(function(global) {
#include '../estk/loader.jsxinc';
estk.loader.__test__(function (obj) {
$.writeln(obj.Require);
$.writeln(obj.Modules);
$.writeln(obj.Loader);
});
}($.global));