test-main.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. 'tether': 'vendor/npm/tether/dist/js/tether.js',
  11. 'tether-drop': 'vendor/npm/tether-drop/dist/js/drop.js',
  12. 'moment': 'vendor/moment.js',
  13. "jquery": "vendor/jquery/dist/jquery.js",
  14. 'lodash-src': 'vendor/lodash.js',
  15. "lodash": 'app/core/lodash_extended.js',
  16. "angular": 'vendor/angular/angular.js',
  17. 'angular-mocks': 'vendor/angular-mocks/angular-mocks.js',
  18. "bootstrap": "vendor/bootstrap/bootstrap.js",
  19. 'angular-route': 'vendor/angular-route/angular-route.js',
  20. 'angular-sanitize': 'vendor/angular-sanitize/angular-sanitize.js',
  21. "angular-ui": "vendor/angular-ui/ui-bootstrap-tpls.js",
  22. "angular-strap": "vendor/angular-other/angular-strap.js",
  23. "angular-dragdrop": "vendor/angular-native-dragdrop/draganddrop.js",
  24. "angular-bindonce": "vendor/angular-bindonce/bindonce.js",
  25. "spectrum": "vendor/spectrum.js",
  26. "bootstrap-tagsinput": "vendor/tagsinput/bootstrap-tagsinput.js",
  27. "jquery.flot": "vendor/flot/jquery.flot",
  28. "jquery.flot.pie": "vendor/flot/jquery.flot.pie",
  29. "jquery.flot.events": "vendor/flot/jquery.flot.events",
  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. },
  37. packages: {
  38. app: {
  39. defaultExtension: 'js',
  40. },
  41. vendor: {
  42. defaultExtension: 'js',
  43. },
  44. },
  45. map: {
  46. },
  47. meta: {
  48. 'vendor/angular/angular.js': {
  49. format: 'global',
  50. deps: ['jquery'],
  51. exports: 'angular',
  52. },
  53. 'vendor/angular-mocks/angular-mocks.js': {
  54. format: 'global',
  55. deps: ['angular'],
  56. }
  57. }
  58. });
  59. function file2moduleName(filePath) {
  60. return filePath.replace(/\\/g, '/')
  61. .replace(/^\/base\//, '')
  62. .replace(/\.\w*$/, '');
  63. }
  64. function onlySpecFiles(path) {
  65. return /specs.*/.test(path);
  66. }
  67. window.grafanaBootData = {settings: {}};
  68. var modules = ['angular', 'angular-mocks', 'app/app'];
  69. var promises = modules.map(function(name) {
  70. return System.import(name);
  71. });
  72. Promise.all(promises).then(function(deps) {
  73. var angular = deps[0];
  74. angular.module('grafana', ['ngRoute']);
  75. angular.module('grafana.services', ['ngRoute', '$strap.directives']);
  76. angular.module('grafana.panels', []);
  77. angular.module('grafana.controllers', []);
  78. angular.module('grafana.directives', []);
  79. angular.module('grafana.filters', []);
  80. angular.module('grafana.routes', ['ngRoute']);
  81. // load specs
  82. return Promise.all(
  83. Object.keys(window.__karma__.files) // All files served by Karma.
  84. .filter(onlySpecFiles)
  85. .map(file2moduleName)
  86. .map(function(path) {
  87. // console.log(path);
  88. return System.import(path);
  89. }));
  90. }).then(function() {
  91. window.__karma__.start();
  92. }, function(error) {
  93. window.__karma__.error(error.stack || error);
  94. }).catch(function(error) {
  95. window.__karma__.error(error.stack || error);
  96. });
  97. })();