backbone.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Backbone Test Suite</title>
  6. <link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css">
  7. </head>
  8. <body>
  9. <script>
  10. // Avoid reporting tests to Sauce Labs when script errors occur.
  11. if (location.port == '9001') {
  12. window.onerror = function(message) {
  13. if (window.QUnit) {
  14. QUnit.config.done.length = 0;
  15. }
  16. global_test_results = { 'message': message };
  17. };
  18. }
  19. </script>
  20. <script src="../node_modules/qunitjs/qunit/qunit.js"></script>
  21. <script src="../node_modules/qunit-extras/qunit-extras.js"></script>
  22. <script src="../vendor/json-js/json2.js"></script>
  23. <script src="../node_modules/platform/platform.js"></script>
  24. <script src="./asset/test-ui.js"></script>
  25. <script src="../lodash.js"></script>
  26. <script>
  27. QUnit.config.asyncRetries = 10;
  28. QUnit.config.hidepassed = true;
  29. var mixinPrereqs = (function() {
  30. var aliasToReal = {
  31. 'indexBy': 'keyBy',
  32. 'invoke': 'invokeMap'
  33. };
  34. var keyMap = {
  35. 'rest': 'tail'
  36. };
  37. var lodash = _.noConflict();
  38. return function(_) {
  39. lodash.defaultsDeep(_, { 'templateSettings': lodash.templateSettings });
  40. lodash.mixin(_, lodash.pick(lodash, lodash.difference([
  41. 'countBy',
  42. 'debounce',
  43. 'difference',
  44. 'find',
  45. 'findIndex',
  46. 'findLastIndex',
  47. 'groupBy',
  48. 'includes',
  49. 'invert',
  50. 'invokeMap',
  51. 'keyBy',
  52. 'omit',
  53. 'partition',
  54. 'reduceRight',
  55. 'reject',
  56. 'sample',
  57. 'without'
  58. ], lodash.functions(_))));
  59. lodash.forOwn(keyMap, function(realName, otherName) {
  60. _[otherName] = lodash[realName];
  61. _.prototype[otherName] = lodash.prototype[realName];
  62. });
  63. lodash.forOwn(aliasToReal, function(realName, alias) {
  64. _[alias] = _[realName];
  65. _.prototype[alias] = _.prototype[realName];
  66. });
  67. };
  68. }());
  69. // Load prerequisite scripts.
  70. document.write(ui.urlParams.loader == 'none'
  71. ? '<script src="' + ui.buildPath + '"><\/script>'
  72. : '<script data-dojo-config="async:1" src="' + ui.loaderPath + '"><\/script>'
  73. );
  74. </script>
  75. <script>
  76. if (ui.urlParams.loader == 'none') {
  77. mixinPrereqs(_);
  78. document.write([
  79. '<script src="../node_modules/jquery/dist/jquery.js"><\/script>',
  80. '<script src="../vendor/backbone/backbone.js"><\/script>',
  81. '<script src="../vendor/backbone/test/setup/dom-setup.js"><\/script>',
  82. '<script src="../vendor/backbone/test/setup/environment.js"><\/script>',
  83. '<script src="../vendor/backbone/test/noconflict.js"><\/script>',
  84. '<script src="../vendor/backbone/test/events.js"><\/script>',
  85. '<script src="../vendor/backbone/test/model.js"><\/script>',
  86. '<script src="../vendor/backbone/test/collection.js"><\/script>',
  87. '<script src="../vendor/backbone/test/router.js"><\/script>',
  88. '<script src="../vendor/backbone/test/view.js"><\/script>',
  89. '<script src="../vendor/backbone/test/sync.js"><\/script>'
  90. ].join('\n'));
  91. }
  92. </script>
  93. <script>
  94. (function() {
  95. if (window.curl) {
  96. curl.config({ 'apiName': 'require' });
  97. }
  98. if (!window.require) {
  99. return;
  100. }
  101. var reBasename = /[\w.-]+$/,
  102. basePath = ('//' + location.host + location.pathname.replace(reBasename, '')).replace(/\btest\/$/, ''),
  103. modulePath = ui.buildPath.replace(/\.js$/, ''),
  104. locationPath = modulePath.replace(reBasename, '').replace(/^\/|\/$/g, ''),
  105. moduleMain = modulePath.match(reBasename)[0],
  106. uid = +new Date;
  107. function getConfig() {
  108. var result = {
  109. 'baseUrl': './',
  110. 'urlArgs': 't=' + uid++,
  111. 'waitSeconds': 0,
  112. 'paths': {
  113. 'backbone': '../vendor/backbone/backbone',
  114. 'jquery': '../node_modules/jquery/dist/jquery'
  115. },
  116. 'packages': [{
  117. 'name': 'test',
  118. 'location': '../vendor/backbone/test',
  119. 'config': {
  120. // Work around no global being exported.
  121. 'exports': 'QUnit',
  122. 'loader': 'curl/loader/legacy'
  123. }
  124. }]
  125. };
  126. if (ui.isModularize) {
  127. result.packages.push({
  128. 'name': 'underscore',
  129. 'location': locationPath,
  130. 'main': moduleMain
  131. });
  132. } else {
  133. result.paths.underscore = modulePath;
  134. }
  135. return result;
  136. }
  137. QUnit.config.autostart = false;
  138. require(getConfig(), ['underscore'], function(lodash) {
  139. mixinPrereqs(lodash);
  140. require(getConfig(), ['backbone'], function() {
  141. require(getConfig(), [
  142. 'test/setup/dom-setup',
  143. 'test/setup/environment',
  144. 'test/noconflict',
  145. 'test/events',
  146. 'test/model',
  147. 'test/collection',
  148. 'test/router',
  149. 'test/view',
  150. 'test/sync'
  151. ], function() {
  152. QUnit.start();
  153. });
  154. });
  155. });
  156. }());
  157. </script>
  158. </body>
  159. </html>