Skip to content

Instantly share code, notes, and snippets.

@tsouk
Last active December 12, 2015 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsouk/4730530 to your computer and use it in GitHub Desktop.
Save tsouk/4730530 to your computer and use it in GitHub Desktop.
/** @lint */
/**
* @module orb/features/_orbevents
*/
define('orb/features/_orbevents', ['orb/lib/_event'], function (event) {
'use strict';
var win;
/**
Add Public event API
@author Michael Mathews
@author Nikos Tsouknidas
*/
var exports = function () {
win.orb = win.orb || {};
event.mixin(win.orb);
};
/**
Initialise the orbevents module.
Allows dependency injection of window for testing purposes.
@protected
@param {object} w - a window object.
*/
exports._init = function(w) {
win = w;
};
// Initialise the default properties of the module
exports._init(window);
return exports;
});
-------------- Test ----------------
describe('The orb/features/_orbevents feature', function() {
var module = null;
getmodule('orb/features/_orbevents');
it('it has the expected API', function() {
waitsFor(function () {
return (module !== null);
}, 'the module to be loaded', 1000);
runs (function () {
expect(typeof module).toBe('function');
expect(typeof module._init).toBe('function');
});
});
it('creates an orb object on the window, that has an event method', function() {
waitsFor(function () {
return (module !== null);
}, 'the module to be loaded', 1000);
runs (function () {
var mockWindow = {};
module._init(mockWindow);
expect(typeof mockWindow.orb).toBe('object');
expect(typeof mockWindow.orb.event).toBe('function');
});
});
function getmodule(modulename) {
blqTestPage.require([modulename], function(m) {
module = m;
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment