tests_main.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. require.config({
  2. paths: {
  3. "jquery": "components/jquery/jquery",
  4. "locales": "locale/locales",
  5. "jquery.tinysort": "components/tinysort/src/jquery.tinysort",
  6. "underscore": "components/underscore/underscore",
  7. "backbone": "components/backbone/backbone",
  8. "backbone.localStorage": "components/backbone.localStorage/backbone.localStorage",
  9. "strophe": "components/strophe/strophe",
  10. "strophe.muc": "components/strophe.muc/index",
  11. "strophe.roster": "components/strophe.roster/index",
  12. "strophe.vcard": "components/strophe.vcard/index",
  13. "strophe.disco": "components/strophe.disco/index",
  14. "otr": "components/otr/build/otr",
  15. "bigint": "components/otr/build/dep/bigint",
  16. "crypto": "components/otr/build/dep/crypto",
  17. "eventemitter": "components/otr/build/dep/eventemitter",
  18. "salsa20": "components/otr/build/dep/salsa20",
  19. "crypto.aes": "components/crypto-js/build/rollups/aes",
  20. // Extra test dependencies
  21. "mock": "tests/mock",
  22. "utils": "tests/utils",
  23. "jasmine": "components/jasmine/lib/jasmine-core/jasmine",
  24. "jasmine-html": "components/jasmine/lib/jasmine-core/jasmine-html",
  25. "jasmine-console-reporter": "node_modules/jasmine-reporters/src/jasmine.console_reporter",
  26. "jasmine-junit-reporter": "node_modules/jasmine-reporters/src/jasmine.junit_reporter"
  27. },
  28. // define module dependencies for modules not using define
  29. shim: {
  30. 'backbone': {
  31. //These script dependencies should be loaded before loading
  32. //backbone.js
  33. deps: [
  34. 'underscore',
  35. 'jquery'
  36. ],
  37. //Once loaded, use the global 'Backbone' as the
  38. //module value.
  39. exports: 'Backbone'
  40. },
  41. 'jquery.tinysort': { deps: ['jquery'] },
  42. 'strophe': { deps: ['jquery'] },
  43. 'underscore': { exports: '_' },
  44. 'strophe.muc': { deps: ['strophe', 'jquery'] },
  45. 'strophe.roster': { deps: ['strophe'] },
  46. 'strophe.vcard': { deps: ['strophe'] },
  47. 'strophe.disco': { deps: ['strophe'] },
  48. // Extra test dependencies
  49. 'jasmine-html': {
  50. deps: ['jasmine'],
  51. exports: 'jasmine'
  52. },
  53. 'jasmine-console-reporter': {
  54. deps: ['jasmine-html'],
  55. exports: 'jasmine'
  56. },
  57. 'jasmine-junit-reporter': {
  58. deps: ['jasmine-html'],
  59. exports: 'jasmine'
  60. }
  61. }
  62. });
  63. // Polyfill 'bind' which is not available in phantomjs < 2.0
  64. if (!Function.prototype.bind) {
  65. Function.prototype.bind = function (oThis) {
  66. if (typeof this !== "function") {
  67. // closest thing possible to the ECMAScript 5 internal IsCallable function
  68. throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
  69. }
  70. var aArgs = Array.prototype.slice.call(arguments, 1),
  71. fToBind = this,
  72. fNOP = function () {},
  73. fBound = function () {
  74. return fToBind.apply(this instanceof fNOP && oThis ? this : oThis,
  75. aArgs.concat(Array.prototype.slice.call(arguments)));
  76. };
  77. fNOP.prototype = this.prototype;
  78. fBound.prototype = new fNOP();
  79. return fBound;
  80. };
  81. }
  82. require([
  83. "jquery",
  84. "converse",
  85. "mock",
  86. "jasmine-html"
  87. ], function($, converse, mock, jasmine) {
  88. // Set up converse.js
  89. window.localStorage.clear();
  90. converse.initialize({
  91. prebind: false,
  92. xhr_user_search: false,
  93. auto_subscribe: false,
  94. animate: false,
  95. connection: mock.mock_connection,
  96. testing: true
  97. }, function (converse) {
  98. window.converse = converse;
  99. require([
  100. "jasmine-console-reporter",
  101. "jasmine-junit-reporter",
  102. "spec/ControlBoxSpec",
  103. "spec/ChatBoxSpec",
  104. "spec/ChatRoomSpec"
  105. ], function () {
  106. // Make sure this callback is only called once.
  107. delete converse.callback;
  108. // Jasmine stuff
  109. var jasmineEnv = jasmine.getEnv();
  110. if (/PhantomJS/.test(navigator.userAgent)) {
  111. jasmineEnv.addReporter(new jasmine.TrivialReporter());
  112. jasmineEnv.addReporter(new jasmine.JUnitXmlReporter('./test-reports/'));
  113. jasmineEnv.addReporter(new jasmine.ConsoleReporter());
  114. jasmineEnv.updateInterval = 0;
  115. } else {
  116. var htmlReporter = new jasmine.HtmlReporter();
  117. jasmineEnv.addReporter(htmlReporter);
  118. jasmineEnv.addReporter(new jasmine.ConsoleReporter());
  119. jasmineEnv.specFilter = function(spec) {
  120. return htmlReporter.specFilter(spec);
  121. };
  122. jasmineEnv.updateInterval = 100;
  123. }
  124. jasmineEnv.execute();
  125. });
  126. });
  127. }
  128. );