Skip to content

Instantly share code, notes, and snippets.

@tsouk
Last active December 12, 2015 06:38

Revisions

  1. tsouk revised this gist Feb 7, 2013. 1 changed file with 11 additions and 2 deletions.
    13 changes: 11 additions & 2 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    /**
    * @module orb/features/_orbevents
    */
    define('orb/features/_orbevents', ['orb/lib/_$'], function ($) {
    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;
  2. tsouk created this gist Feb 7, 2013.
    68 changes: 68 additions & 0 deletions gistfile1.js
    Original 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;
    });
    }

    });