Last active
December 12, 2015 06:38
Revisions
-
tsouk revised this gist
Feb 7, 2013 . 1 changed file with 11 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ /** * @module orb/features/_orbevents */ define('orb/features/_orbevents', ['orb/lib/_event'], function (event) { 'use strict'; var win; @@ -15,13 +15,22 @@ define('orb/features/_orbevents', ['orb/lib/_$'], function ($) { */ 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; -
tsouk created this gist
Feb 7, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,68 @@ /** @lint */ /** * @module orb/features/_orbevents */ define('orb/features/_orbevents', ['orb/lib/_$'], function ($) { 'use strict'; var win; /** Add Public event API @author Michael Mathews @author Nikos Tsouknidas */ var exports = function () { }; exports._init = function(w) { win = w; }; 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; }); } });