forked from webgme/webgme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-main.js
146 lines (125 loc) · 4.59 KB
/
test-main.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*globals require*/
/*jshint browser: true*/
function done() {
'use strict';
var allTestFiles = [],
TEST_REGEXP = /(spec|test)\.js$/i,
pathToModule = function (path) {
return path.replace(/^\/base\//, '').replace(/\.js$/, '');
};
Object.keys(window.__karma__.files).forEach(function (file) {
if (TEST_REGEXP.test(file)) {
// Normalize paths to RequireJS module names.
allTestFiles.push(pathToModule(file));
}
});
require.config({
// Karma serves files under /base, which is the basePath from your config file
baseUrl: '/base',
map: {
'*': {
css: './src/client/lib/require/require-css/css',
text: './src/client/lib/require/require-text/text'
}
},
paths: {
// plugin base classes
plugin: './src/plugin',
// plugins
// TODO: populate plugin list dynamically based on config.json
MinimalWorkingExample: './src/plugin/coreplugins/MinimalWorkingExample/MinimalWorkingExample',
PluginForked: './test/plugin/scenarios/plugins/PluginForked/PluginForked',
'js/Dialogs/PluginConfig/PluginConfigDialog': './utils/build/empty/empty',
// MAGIC ... from src/client/js/main.js
executor: './src/common/executor',
blob: './src/common/blob',
common: './src/common',
//'core': './src/common/core',
//'storage': './src/common/storage',
js: './src/client/js',
//'util': './src/common/util',
//'eventDispatcher': './src/common/EventDispatcher',
//'logManager': './src/common/LogManager',
//'coreclient': './src/common/core/users',
superagent: './src/client/lib/superagent/superagent',
jszip: './src/client/lib/jszip/jszip',
debug: './src/client/lib/debug/debug',
underscore: './src/client/lib/underscore/underscore',
Q: './src/client/lib/q/q', //FIXME: this should be removed
q: './src/client/lib/q/q',
karmatest: './test-karma',
aRtestCases: './test-karma/client/js/AutoRouter/testCases'
// external libraries used by plugins
//'ejs': './support/ejs/ejs.min',
//'xmljsonconverter': './lib/xmljsonconverter',
//'sax': './support/sax/sax',
// modules used by test cases
//'mocks': './test/mocks',
//'models': './test/models'
},
// dynamically load all test files
deps: allTestFiles,
// we have to kickoff jasmine, as it is asynchronous
callback: window.__karma__.start
});
}
//function httpGet(theUrl, callback) {
// 'use strict';
// var xhr = new XMLHttpRequest();
// console.log(theUrl);
// xhr.open('GET', theUrl, true);
// xhr.onreadystatechange = function () {
// console.log('ready state changed');
// if (xhr.readyState === 4) {
// if (xhr.status === 200) {
// console.log(xhr.responseText);
// callback(xhr.status);
// } else {
// console.error(xhr.statusText);
// callback(xhr.status);
// }
// }
// };
// xhr.onerror = function (/*e*/) {
// console.error(xhr.statusText);
// callback(xhr.status);
// };
// xhr.send(null);
// return xhr;
//}
// FIXME: we should try to load gmeConfig with HTTPXmlRequest, to see if the server is up and running
// wait for 5 seconds for server start up
setTimeout(function () {
'use strict';
done();
}, 5000);
// FIXME: this code does not behave as expected.
//var i = 20, // how many times to try to connect to the server
// ready = false,
// xhrPending,
// intervalId = setInterval(function () {
// xhrPending = httpGet('/base/gmeConfig.json', function (status) {
// xhrPending = null;
// console.log(status);
// if (status === 200) {
// if (ready === false) {
// clearInterval(intervalId);
// done();
// } else {
// ready = true;
// }
// }
// });
//
// if (xhrPending) {
// xhrPending.abort();
// }
//
// console.log('trying to connect');
//
// i -= 1;
// if (i < 0) {
// clearInterval(intervalId);
// throw new Error('Was not able to connect web server through karma proxy within 20 seconds');
// }
// }, 1000);