test-main.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. (function() {
  2. "use strict";
  3. // Tun on full stack traces in errors to help debugging
  4. Error.stackTraceLimit=Infinity;
  5. window.__karma__.loaded = function() {};
  6. System.config({
  7. baseURL: '/base/',
  8. defaultJSExtensions: true,
  9. paths: {
  10. 'eventemitter3': 'vendor/npm/eventemitter3/index.js',
  11. 'tether': 'vendor/npm/tether/dist/js/tether.js',
  12. 'tether-drop': 'vendor/npm/tether-drop/dist/js/drop.js',
  13. 'moment': 'vendor/moment.js',
  14. "jquery": "vendor/jquery/dist/jquery.js",
  15. 'lodash-src': 'vendor/lodash/dist/lodash.js',
  16. "lodash": 'app/core/lodash_extended.js',
  17. "angular": 'vendor/angular/angular.js',
  18. 'angular-mocks': 'vendor/angular-mocks/angular-mocks.js',
  19. "bootstrap": "vendor/bootstrap/bootstrap.js",
  20. 'angular-route': 'vendor/angular-route/angular-route.js',
  21. 'angular-sanitize': 'vendor/angular-sanitize/angular-sanitize.js',
  22. "angular-ui": "vendor/angular-ui/ui-bootstrap-tpls.js",
  23. "angular-strap": "vendor/angular-other/angular-strap.js",
  24. "angular-dragdrop": "vendor/angular-native-dragdrop/draganddrop.js",
  25. "angular-bindonce": "vendor/angular-bindonce/bindonce.js",
  26. "spectrum": "vendor/spectrum.js",
  27. "bootstrap-tagsinput": "vendor/tagsinput/bootstrap-tagsinput.js",
  28. "jquery.flot": "vendor/flot/jquery.flot",
  29. "jquery.flot.pie": "vendor/flot/jquery.flot.pie",
  30. "jquery.flot.selection": "vendor/flot/jquery.flot.selection",
  31. "jquery.flot.stack": "vendor/flot/jquery.flot.stack",
  32. "jquery.flot.stackpercent": "vendor/flot/jquery.flot.stackpercent",
  33. "jquery.flot.time": "vendor/flot/jquery.flot.time",
  34. "jquery.flot.crosshair": "vendor/flot/jquery.flot.crosshair",
  35. "jquery.flot.fillbelow": "vendor/flot/jquery.flot.fillbelow",
  36. "jquery.flot.gauge": "vendor/flot/jquery.flot.gauge"
  37. },
  38. packages: {
  39. app: {
  40. defaultExtension: 'js',
  41. },
  42. vendor: {
  43. defaultExtension: 'js',
  44. },
  45. },
  46. map: {
  47. },
  48. meta: {
  49. 'vendor/angular/angular.js': {
  50. format: 'global',
  51. deps: ['jquery'],
  52. exports: 'angular',
  53. },
  54. 'vendor/angular-mocks/angular-mocks.js': {
  55. format: 'global',
  56. deps: ['angular'],
  57. },
  58. 'vendor/npm/eventemitter3/index.js': {
  59. format: 'cjs',
  60. exports: 'EventEmitter'
  61. },
  62. }
  63. });
  64. function file2moduleName(filePath) {
  65. return filePath.replace(/\\/g, '/')
  66. .replace(/^\/base\//, '')
  67. .replace(/\.\w*$/, '');
  68. }
  69. function onlySpecFiles(path) {
  70. return /specs.*/.test(path);
  71. }
  72. window.grafanaBootData = {settings: {}};
  73. var modules = ['angular', 'angular-mocks', 'app/app'];
  74. var promises = modules.map(function(name) {
  75. return System.import(name);
  76. });
  77. Promise.all(promises).then(function(deps) {
  78. var angular = deps[0];
  79. angular.module('grafana', ['ngRoute']);
  80. angular.module('grafana.services', ['ngRoute', '$strap.directives']);
  81. angular.module('grafana.panels', []);
  82. angular.module('grafana.controllers', []);
  83. angular.module('grafana.directives', []);
  84. angular.module('grafana.filters', []);
  85. angular.module('grafana.routes', ['ngRoute']);
  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. // console.log(path);
  93. return System.import(path);
  94. }));
  95. }).then(function() {
  96. window.__karma__.start();
  97. }, function(error) {
  98. window.__karma__.error(error.stack || error);
  99. }).catch(function(error) {
  100. window.__karma__.error(error.stack || error);
  101. });
  102. })();