tests_main.js 5.7 KB

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