// {{{ICINGA_LICENSE_HEADER}}} /** * This file is part of Icinga Web 2. * * Icinga Web 2 - Head for multiple monitoring backends. * Copyright (C) 2013 Icinga Development Team * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * @copyright 2013 Icinga Development Team * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 * @author Icinga Development Team * */ // {{{ICINGA_LICENSE_HEADER}}} /** * {{LICENSE_HEADER}} * {{LICENSE_HEADER}} **/ /** * This node module acts as a mock for requirejs and allows you to * define your own dependencies in your tests. It also removes the * asynchronous character of dependency loading, so you don't need * to handle everthing in the callbacks. * * Per default it resolves the 'logging' dependency by routing it * to console. * **/ var path = require('path'); var registeredDependencies = {}; /** * Mock for the requirejs(dependencyList, callback) function, loads * all dependencies that have been registered under the given names * in dependencies and calls fn with them as the parameter * **/ var debug = false; var requireJsMock = function(dependencies, fn) { var fnArgs = []; for (var i=0;iobject map of dependencies * for lookup with requirejs()/define() **/ function registerDependencies(obj) { for(var name in obj) { registeredDependencies[name] = obj[name]; } } var base = path.normalize(__dirname+"../../../../public/js"); GLOBAL.requireNew = function(key) { key = path.normalize(base+"/"+key); delete require.cache[key]; return require(key); }; /** * The API for this module **/ module.exports = { purgeDependencies: purgeDependencies, registerDependencies: registerDependencies, getDefine: function(name) { if (typeof name === "undefined") { return registeredDependencies.__define__; } else { return registeredDependencies[name]; } } };