Skip to content

Instantly share code, notes, and snippets.

@hojberg
Created February 13, 2010 12:29
Show Gist options
  • Save hojberg/303425 to your computer and use it in GitHub Desktop.
Save hojberg/303425 to your computer and use it in GitHub Desktop.
how to make testing possible of sandboxed api #2
(function () {
var PublicAPI = window.PublicAPI = {};
PublicAPI.publicFunction = function (foo) {
PrivateAPI.privateFunction(foo);
return 'bar';
};
var PrivateAPI = {};
PrivateAPI.privateFunction = function (foo) {
// Make secret stuff that never gets returned to the public
// Could be an XHR call.
};
// Assign PrivateAPI to window in order to perform unit testing of PrivateAPI.
// Remove this in production
window.PrivateAPI = PrivateAPI;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment