Skip to content

Commit f788888

Browse files
committed
tech(systemjs): working on getting tests to work
1 parent dfd5413 commit f788888

File tree

3,143 files changed

+2510
-303400
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,143 files changed

+2510
-303400
lines changed

karma.conf.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ module.exports = function(config) {
44
config.set({
55
basePath: __dirname + '/public_gen',
66

7-
frameworks: ['mocha', 'requirejs', 'expect', 'sinon'],
7+
frameworks: ['mocha', 'expect', 'sinon'],
88

99
// list of files / patterns to load in the browser
1010
files: [
11+
'vendor/npm/es5-shim/es5-shim.js',
12+
'vendor/npm/es6-shim/es6-shim.js',
13+
'vendor/npm/es6-promise/dist/es6-promise.js',
14+
'vendor/npm/systemjs/dist/system.src.js',
1115
'test/test-main.js',
16+
1217
{pattern: 'app/**/*.js', included: false},
1318
{pattern: 'vendor/**/*.js', included: false},
1419
{pattern: 'test/**/*.js', included: false}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
},
7070
"license": "Apache-2.0",
7171
"dependencies": {
72+
"es5-shim": "^4.4.1",
7273
"grunt-jscs": "~1.5.x",
7374
"grunt-sync": "^0.4.1",
7475
"karma-sinon": "^1.0.3",
File renamed without changes.

public/test/.jshintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
"maxlen": 140,
2626

2727
"globals": {
28+
"Promise": true,
29+
"System": true,
2830
"expect": true,
2931
"it": true,
3032
"describe": true,

public/test/test-main.js

Lines changed: 86 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,100 @@
1-
require.config({
2-
baseUrl: 'http://localhost:9876/base/',
3-
4-
paths: {
5-
lodash: 'app/core/lodash_extended',
6-
'lodash-src': 'vendor/lodash',
7-
8-
moment: 'vendor/moment',
9-
chromath: 'vendor/chromath',
10-
filesaver: 'vendor/filesaver',
11-
12-
angular: 'vendor/angular/angular',
13-
'angular-route': 'vendor/angular-route/angular-route',
14-
'angular-sanitize': 'vendor/angular-sanitize/angular-sanitize',
15-
angularMocks: 'vendor/angular-mocks/angular-mocks',
16-
'angular-dragdrop': 'vendor/angular-native-dragdrop/draganddrop',
17-
'angular-ui': 'vendor/angular-ui/ui-bootstrap-tpls',
18-
'angular-strap': 'vendor/angular-other/angular-strap',
19-
timepicker: 'vendor/angular-other/timepicker',
20-
datepicker: 'vendor/angular-other/datepicker',
21-
bindonce: 'vendor/angular-bindonce/bindonce',
22-
crypto: 'vendor/crypto.min',
23-
spectrum: 'vendor/spectrum',
24-
jquery: 'vendor/jquery/dist/jquery',
25-
26-
bootstrap: 'vendor/bootstrap/bootstrap',
27-
'bootstrap-tagsinput': 'vendor/tagsinput/bootstrap-tagsinput',
28-
29-
'extend-jquery': 'app/components/extend-jquery',
30-
31-
'jquery.flot': 'vendor/flot/jquery.flot',
32-
'jquery.flot.pie': 'vendor/flot/jquery.flot.pie',
33-
'jquery.flot.events': 'vendor/flot/jquery.flot.events',
34-
'jquery.flot.selection': 'vendor/flot/jquery.flot.selection',
35-
'jquery.flot.stack': 'vendor/flot/jquery.flot.stack',
36-
'jquery.flot.stackpercent':'vendor/flot/jquery.flot.stackpercent',
37-
'jquery.flot.time': 'vendor/flot/jquery.flot.time',
38-
'jquery.flot.crosshair': 'vendor/flot/jquery.flot.crosshair',
39-
'jquery.flot.fillbelow': 'vendor/flot/jquery.flot.fillbelow',
40-
41-
modernizr: 'vendor/modernizr-2.6.1',
42-
},
43-
44-
shim: {
45-
bootstrap: {
46-
deps: ['jquery']
47-
},
48-
49-
modernizr: {
50-
exports: 'Modernizr'
51-
},
52-
53-
angular: {
54-
deps: ['jquery'],
55-
exports: 'angular'
1+
(function() {
2+
"use strict";
3+
4+
System.config({
5+
baseURL: '/base/',
6+
defaultJSExtensions: true,
7+
paths: {
8+
'moment': 'vendor/moment.js',
9+
"jquery": "vendor/jquery/dist/jquery.js",
10+
'lodash-src': 'vendor/lodash.js',
11+
"lodash": 'app/core/lodash_extended.js',
12+
"angular": 'vendor/angular/angular.js',
13+
'angular-mocks': 'vendor/angular-mocks/angular-mocks.js',
14+
"bootstrap": "vendor/bootstrap/bootstrap.js",
15+
'angular-route': 'vendor/angular-route/angular-route.js',
16+
'angular-sanitize': 'vendor/angular-sanitize/angular-sanitize.js',
17+
"angular-ui": "vendor/angular-ui/ui-bootstrap-tpls.js",
18+
"angular-strap": "vendor/angular-other/angular-strap.js",
19+
"angular-dragdrop": "vendor/angular-native-dragdrop/draganddrop.js",
20+
"angular-bindonce": "vendor/angular-bindonce/bindonce.js",
21+
"spectrum": "vendor/spectrum.js",
22+
"bootstrap-tagsinput": "vendor/tagsinput/bootstrap-tagsinput.js",
23+
"jquery.flot": "vendor/flot/jquery.flot",
24+
"jquery.flot.pie": "vendor/flot/jquery.flot.pie",
25+
"jquery.flot.events": "vendor/flot/jquery.flot.events",
26+
"jquery.flot.selection": "vendor/flot/jquery.flot.selection",
27+
"jquery.flot.stack": "vendor/flot/jquery.flot.stack",
28+
"jquery.flot.stackpercent": "vendor/flot/jquery.flot.stackpercent",
29+
"jquery.flot.time": "vendor/flot/jquery.flot.time",
30+
"jquery.flot.crosshair": "vendor/flot/jquery.flot.crosshair",
31+
"jquery.flot.fillbelow": "vendor/flot/jquery.flot.fillbelow"
5632
},
5733

58-
angularMocks: {
59-
deps: ['angular'],
34+
packages: {
35+
app: {
36+
defaultExtension: 'js',
37+
},
38+
vendor: {
39+
defaultExtension: 'js',
40+
},
6041
},
6142

62-
crypto: {
63-
exports: 'Crypto'
43+
map: {
6444
},
6545

66-
'jquery.flot': ['jquery'],
67-
'jquery.flot.pie': ['jquery', 'jquery.flot'],
68-
'jquery.flot.events': ['jquery', 'jquery.flot'],
69-
'jquery.flot.selection':['jquery', 'jquery.flot'],
70-
'jquery.flot.stack': ['jquery', 'jquery.flot'],
71-
'jquery.flot.stackpercent':['jquery', 'jquery.flot'],
72-
'jquery.flot.time': ['jquery', 'jquery.flot'],
73-
'jquery.flot.crosshair':['jquery', 'jquery.flot'],
74-
'jquery.flot.fillbelow':['jquery', 'jquery.flot'],
75-
76-
'angular-route': ['angular'],
77-
'angular-sanitize': ['angular'],
78-
'angular-ui': ['angular'],
79-
'angular-dragdrop': ['jquery', 'angular'],
80-
'angular-mocks': ['angular'],
81-
'angular-strap': ['angular', 'bootstrap','timepicker', 'datepicker'],
82-
'bindonce': ['angular'],
83-
84-
'bootstrap-tagsinput': ['jquery'],
85-
86-
timepicker: ['jquery', 'bootstrap'],
87-
datepicker: ['jquery', 'bootstrap'],
88-
}
89-
});
46+
meta: {
47+
'vendor/angular/angular.js': {
48+
format: 'global',
49+
deps: ['jquery'],
50+
exports: 'angular',
51+
},
52+
'vendor/angular/angular-mocks.js': {
53+
format: 'global',
54+
deps: ['angular'],
55+
}
56+
}
57+
});
9058

91-
function file2moduleName(filePath) {
92-
'use strict';
93-
return filePath.replace(/\\/g, '/')
59+
function file2moduleName(filePath) {
60+
return filePath.replace(/\\/g, '/')
9461
.replace(/^\/base\//, '')
95-
.replace(/\.\w*$/, '');
96-
}
97-
98-
window.grafanaBootData = {settings: {}};
99-
100-
require([
101-
'lodash',
102-
'angular',
103-
'angularMocks',
104-
'app/app',
105-
], function(_, angular) {
106-
'use strict';
107-
108-
var specs = [];
109-
110-
for (var file in window.__karma__.files) {
111-
if (/specs.*/.test(file)) {
112-
file = file2moduleName(file);
113-
specs.push(file);
114-
}
62+
.replace(/\.\w*$/, '');
11563
}
11664

117-
angular.module('grafana', ['ngRoute']);
118-
angular.module('grafana.services', ['ngRoute', '$strap.directives']);
119-
angular.module('grafana.panels', []);
120-
angular.module('grafana.filters', []);
121-
angular.module('grafana.routes', ['ngRoute']);
65+
function onlySpecFiles(path) {
66+
return /_specs\.js$/.test(path);
67+
}
12268

123-
require(specs, function() {
69+
window.grafanaBootData = {settings: {}};
70+
71+
var modules = ['lodash', 'angular', 'angular-mocks', 'app/app'];
72+
73+
Promise.all(
74+
modules.map(function(moduleName) {
75+
return System.import(moduleName);
76+
})
77+
).then(function(deps) {
78+
var angular = deps[1];
79+
80+
angular.module('grafana', ['ngRoute']);
81+
angular.module('grafana.services', ['ngRoute', '$strap.directives']);
82+
angular.module('grafana.panels', []);
83+
angular.module('grafana.filters', []);
84+
angular.module('grafana.routes', ['ngRoute']);
85+
86+
// load specs
87+
return Promise.all(
88+
Object.keys(window.__karma__.files) // All files served by Karma.
89+
.filter(onlySpecFiles)
90+
.map(file2moduleName)
91+
.map(function(path) {
92+
return System.import(path);
93+
}));
94+
}).then(function() {
12495
window.__karma__.start();
96+
}, function(error) {
97+
window.__karma__.error(error.stack || error);
12598
});
12699

127-
});
100+
})();

public/test/tests.html

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)