/
galaxy_app_base_tests.js
96 lines (87 loc) · 3.78 KB
/
galaxy_app_base_tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* global define */
define(["qunit/test-app", "galaxy", "jquery"], function(testApp, appBase, $) {
"use strict";
appBase = appBase.default;
QUnit.module("Galaxy client app tests");
var options = {
config: {
allow_user_deletion: false,
allow_user_creation: true,
wiki_url: "https://galaxyproject.org/",
ftp_upload_site: null,
support_url: "https://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"
}
};
QUnit.test("App base construction/initializiation defaults", function(assert) {
var app = new appBase.GalaxyApp({});
assert.ok(app.hasOwnProperty("options") && typeof app.options === "object");
assert.ok(app.hasOwnProperty("logger") && typeof app.logger === "object");
assert.ok(app.hasOwnProperty("localize") && typeof app.localize === "function");
assert.ok(app.hasOwnProperty("config") && typeof app.config === "object");
assert.ok(app.hasOwnProperty("user") && typeof app.config === "object");
assert.equal(app.localize, window._l);
});
QUnit.test("App base default options", function(assert) {
var app = new appBase.GalaxyApp({});
assert.ok(app.hasOwnProperty("options") && typeof app.options === "object");
assert.equal(app.options.root, "/");
assert.equal(app.options.patchExisting, true);
});
QUnit.test("App base extends from Backbone.Events", function(assert) {
var app = new appBase.GalaxyApp({});
["on", "off", "trigger", "listenTo", "stopListening"].forEach(function(fn) {
assert.ok(app.hasOwnProperty(fn) && typeof app[fn] === "function");
});
});
QUnit.test("App base has logging methods from utils/add-logging.js", function(assert) {
var app = new appBase.GalaxyApp({});
["debug", "info", "warn", "error", "metric"].forEach(function(fn) {
assert.ok(typeof app[fn] === "function");
});
assert.ok(app._logNamespace === "GalaxyApp");
});
QUnit.test("App base will patch in attributes from existing Galaxy objects", function(assert) {
window.Galaxy = {
attribute: {
subattr: 1
}
};
var app = new appBase.GalaxyApp({});
assert.ok(typeof app.attribute === "object" && app.attribute.subattr === 1);
});
QUnit.test("App base logger", function(assert) {
var app = new appBase.GalaxyApp({});
assert.ok(app.hasOwnProperty("logger") && typeof app.config === "object");
});
QUnit.test("App base config", function(assert) {
var app = new appBase.GalaxyApp(options);
assert.ok(app.hasOwnProperty("config") && typeof app.config === "object");
assert.equal(app.config.allow_user_deletion, false);
assert.equal(app.config.allow_user_creation, true);
assert.equal(app.config.wiki_url, "https://galaxyproject.org/");
assert.equal(app.config.ftp_upload_site, null);
});
QUnit.test("App base user", function(assert) {
var app = new appBase.GalaxyApp({});
assert.ok(app.hasOwnProperty("user") && typeof app.user === "object");
assert.ok(app.user.isAdmin() === false);
});
});