Last active
December 12, 2015 06:38
-
-
Save tsouk/4730530 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @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