diff --git a/static/scripts/galaxy-app-base.js b/static/scripts/galaxy-app-base.js index 256eb16e2ac..1e21cac3088 100644 --- a/static/scripts/galaxy-app-base.js +++ b/static/scripts/galaxy-app-base.js @@ -40,7 +40,6 @@ GalaxyApp.prototype._init = function init( options ){ self.debug( 'GalaxyApp.options: ', self.options ); self._patchGalaxy( window.Galaxy ); - self.debug( 'GalaxyApp.options: ', self.options ); self._initLogger( options.loggerOptions || {} ); self.debug( 'GalaxyApp.logger: ', self.logger ); diff --git a/test/qunit/tests/galaxy-app-base.html b/test/qunit/tests/galaxy-app-base.html new file mode 100644 index 00000000000..00e97f6ea8c --- /dev/null +++ b/test/qunit/tests/galaxy-app-base.html @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/test/qunit/tests/galaxy-app-base.js b/test/qunit/tests/galaxy-app-base.js new file mode 100644 index 00000000000..3f56be384df --- /dev/null +++ b/test/qunit/tests/galaxy-app-base.js @@ -0,0 +1,113 @@ +define( 'bootstrapped-data', function(){ + return { + config : { + "allow_user_deletion": false, + "allow_user_creation": true, + "wiki_url": "http://wiki.galaxyproject.org/", + "ftp_upload_site": null, + "support_url": "https://wiki.galaxyproject.org/Support", + "allow_user_dataset_purge": false, + "allow_library_path_paste": false, + "user_library_import_dir": null, + "terms_url": null, + "ftp_upload_dir": null, + "library_import_dir": null, + "logo_url": null, + "enable_unique_workflow_defaults": false + }, + user : { + "username": "test", + "quota_percent": null, + "total_disk_usage": 61815527, + "nice_total_disk_usage": "59.0 MB", + "email": "test@test.test", + "tags_used": [ + "test" + ], + "model_class": "User", + "id": "f2db41e1fa331b3e" + } + }; +}); +define([ + "galaxy-app-base", + 'bootstrapped-data', + "jquery", + "sinon-qunit" +], function( + appBase, + bootstrapped, + $, + sinon +){ + /*globals equal test module expect deepEqual strictEqual throws ok */ + "use strict"; + + module( "Galaxy client app tests" ); + + test( "App base construction/initializiation defaults", function() { + var app = new appBase.GalaxyApp({}); + ok( app.hasOwnProperty( 'options' ) && typeof app.options === 'object' ); + ok( app.hasOwnProperty( 'logger' ) && typeof app.logger === 'object' ); + ok( app.hasOwnProperty( 'localize' ) && typeof app.localize === 'function' ); + ok( app.hasOwnProperty( 'config' ) && typeof app.config === 'object' ); + ok( app.hasOwnProperty( 'user' ) && typeof app.config === 'object' ); + + equal( app.localize, window._l ); + }); + + test( "App base default options", function() { + var app = new appBase.GalaxyApp({}); + ok( app.hasOwnProperty( 'options' ) && typeof app.options === 'object' ); + equal( app.options.root, '/' ); + equal( app.options.patchExisting, true ); + }); + + test( "App base extends from Backbone.Events", function() { + var app = new appBase.GalaxyApp({}); + [ 'on', 'off', 'trigger', 'listenTo', 'stopListening' ].forEach( function( fn ){ + ok( app.hasOwnProperty( fn ) && typeof app[ fn ] === 'function' ); + }); + }); + + test( "App base has logging methods from utils/add-logging.js", function() { + var app = new appBase.GalaxyApp({}); + [ 'debug', 'info', 'warn', 'error', 'metric' ].forEach( function( fn ){ + ok( typeof app[ fn ] === 'function' ); + }); + ok( app._logNamespace === 'GalaxyApp' ); + }); + + test( 'App base will patch in attributes from existing Galaxy objects', function(){ + window.Galaxy = { + attribute : { + subattr : 1 + } + }; + var app = new appBase.GalaxyApp({}); + ok( typeof app.attribute === 'object' && app.attribute.subattr === 1 ); + }); + + test( "App base logger", function() { + var app = new appBase.GalaxyApp({}); + ok( app.hasOwnProperty( 'logger' ) && typeof app.config === 'object' ); + }); + + test( "App base config", function() { + var app = new appBase.GalaxyApp({}); + ok( app.hasOwnProperty( 'config' ) && typeof app.config === 'object' ); + equal( app.config.allow_user_deletion, false ); + equal( app.config.allow_user_creation, true ); + equal( app.config.wiki_url, "http://wiki.galaxyproject.org/" ); + equal( app.config.ftp_upload_site, null ); + //... + }); + + test( "App base user", function() { + var app = new appBase.GalaxyApp({}); + ok( app.hasOwnProperty( 'user' ) && typeof app.user === 'object' ); + ok( app.hasOwnProperty( 'currUser' ) && app.user === app.currUser ); + ok( app.user.isAdmin() === false ); + }); + +}); diff --git a/test/qunit/tests/metrics-logger.js b/test/qunit/tests/metrics-logger.js index 7a2a8480c63..0f3f73931a6 100644 --- a/test/qunit/tests/metrics-logger.js +++ b/test/qunit/tests/metrics-logger.js @@ -17,7 +17,7 @@ define([ test( "logger construction/initializiation defaults", function() { var logger = new metrics.MetricsLogger({}); equal( logger.consoleLogger, null ); - equal( logger.options.logLevel, metrics.MetricsLogger.INFO ); + equal( logger.options.logLevel, metrics.MetricsLogger.NONE ); equal( logger.options.consoleLevel, metrics.MetricsLogger.NONE ); equal( logger.options.defaultNamespace, 'Galaxy' ); equal( logger.options.clientPrefix, 'client.' );