runner.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*global config */
  2. // Extra test dependencies
  3. config.paths.mock = "tests/mock";
  4. config.paths['wait-until-promise'] = "node_modules/wait-until-promise/index";
  5. config.paths['test-utils'] = "tests/utils";
  6. config.paths.sinon = "node_modules/sinon/lib/sinon";
  7. config.paths.transcripts = "converse-logs/converse-logs";
  8. config.paths.jasmine = "node_modules/jasmine-core/lib/jasmine-core/jasmine";
  9. config.paths.boot = "node_modules/jasmine-core/lib/jasmine-core/boot";
  10. config.paths["jasmine-html"] = "node_modules/jasmine-core/lib/jasmine-core/jasmine-html";
  11. // config.paths["console-runner"] = "node_modules/phantom-jasmine/lib/console-runner";
  12. config.shim.jasmine = {
  13. exports: 'window.jasmineRequire'
  14. };
  15. config.shim['jasmine-html'] = {
  16. deps: ['jasmine'],
  17. exports: 'window.jasmineRequire'
  18. };
  19. config.shim.boot = {
  20. deps: ['jasmine', 'jasmine-html'],
  21. exports: 'window.jasmineRequire'
  22. };
  23. /*
  24. config.shim['console-runner'] = {
  25. deps: ['jasmine']
  26. };
  27. */
  28. require.config(config);
  29. // Polyfill 'bind' which is not available in phantomjs < 2.0
  30. if (!Function.prototype.bind) {
  31. Function.prototype.bind = function (oThis) {
  32. if (typeof this !== "function") {
  33. // closest thing possible to the ECMAScript 5 internal IsCallable function
  34. throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
  35. }
  36. var aArgs = Array.prototype.slice.call(arguments, 1),
  37. fToBind = this,
  38. fNOP = function () {},
  39. fBound = function () {
  40. return fToBind.apply(this instanceof fNOP && oThis ? this : oThis,
  41. aArgs.concat(Array.prototype.slice.call(arguments)));
  42. };
  43. fNOP.prototype = this.prototype;
  44. fBound.prototype = new fNOP();
  45. return fBound;
  46. };
  47. }
  48. var specs = [
  49. //"spec/transcripts",
  50. // "spec/profiling",
  51. "spec/utils",
  52. "spec/converse",
  53. "spec/bookmarks",
  54. "spec/headline",
  55. "spec/disco",
  56. "spec/protocol",
  57. "spec/presence",
  58. "spec/eventemitter",
  59. "spec/ping",
  60. "spec/xmppstatus",
  61. "spec/mam",
  62. "spec/otr",
  63. "spec/controlbox",
  64. "spec/chatbox",
  65. "spec/chatroom",
  66. "spec/minchats",
  67. "spec/notification",
  68. "spec/register"
  69. ];
  70. require(['jquery', 'mock', 'boot', 'sinon', 'wait-until-promise'],
  71. function($, mock, jasmine, sinon, waitUntilPromise) {
  72. window.sinon = sinon;
  73. window.waitUntilPromise = waitUntilPromise['default'];
  74. window.localStorage.clear();
  75. window.sessionStorage.clear();
  76. // Load the specs
  77. require(specs, function () {
  78. // Initialize the HTML Reporter and execute the environment (setup by `boot.js`)
  79. // http://stackoverflow.com/questions/19240302/does-jasmine-2-0-really-not-work-with-require-js
  80. window.onload();
  81. });
  82. }
  83. );