teabag 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. data/README.md +59 -59
  2. data/app/assets/javascripts/teabag-jasmine.js +229 -190
  3. data/app/assets/javascripts/teabag-mocha.js +217 -192
  4. data/app/assets/javascripts/teabag-qunit.js +3023 -0
  5. data/app/assets/javascripts/teabag/base/reporters/console.coffee +42 -26
  6. data/app/assets/javascripts/teabag/base/reporters/html.coffee +4 -3
  7. data/app/assets/javascripts/teabag/base/reporters/html/base_view.coffee +49 -0
  8. data/app/assets/javascripts/teabag/base/reporters/html/suite_view.coffee +1 -1
  9. data/app/assets/javascripts/teabag/base/runner.coffee +10 -0
  10. data/app/assets/javascripts/teabag/base/teabag.coffee +15 -1
  11. data/app/assets/javascripts/teabag/jasmine.coffee +53 -5
  12. data/app/assets/javascripts/teabag/mocha.coffee +51 -5
  13. data/app/assets/javascripts/teabag/mocha/reporters/console.coffee +3 -2
  14. data/app/assets/javascripts/teabag/qunit.coffee +61 -0
  15. data/app/assets/javascripts/teabag/qunit/reporters/console.coffee +25 -0
  16. data/app/assets/javascripts/teabag/qunit/reporters/html.coffee +80 -0
  17. data/app/helpers/teabag/spec_helper.rb +6 -14
  18. data/lib/generators/teabag/install/templates/initializer.rb +2 -1
  19. data/lib/teabag/configuration.rb +15 -4
  20. data/lib/teabag/console.rb +5 -11
  21. data/lib/teabag/drivers/base_driver.rb +10 -0
  22. data/lib/teabag/{phantomjs → drivers/phantomjs}/runner.coffee +0 -0
  23. data/lib/teabag/drivers/phantomjs_driver.rb +25 -0
  24. data/lib/teabag/drivers/selenium_driver.rb +29 -0
  25. data/lib/teabag/formatters/base_formatter.rb +4 -2
  26. data/lib/teabag/formatters/{progress_formatter.rb → dot_formatter.rb} +5 -5
  27. data/lib/teabag/formatters/swayze_or_oprah_formatter.rb +1 -1
  28. data/lib/teabag/formatters/tap_y_formatter.rb +85 -0
  29. data/lib/teabag/result.rb +18 -29
  30. data/lib/teabag/runner.rb +2 -2
  31. data/lib/teabag/version.rb +1 -1
  32. data/spec/dummy/config/initializers/teabag.rb +6 -0
  33. data/spec/dummy/log/development.log +87684 -0
  34. data/spec/dummy/log/test.log +556 -0
  35. data/spec/dummy/tmp/cache/assets/C13/B50/sprockets%2F431452d41e5087d2211162d23c63789b +0 -0
  36. data/spec/dummy/tmp/cache/assets/C18/F90/sprockets%2F369a3f720404378b4162541fd432742d +0 -0
  37. data/spec/dummy/tmp/cache/assets/C2B/5D0/sprockets%2F98606f6051a5fc71379af24236793353 +0 -0
  38. data/spec/dummy/tmp/cache/assets/C4E/9B0/sprockets%2Fa807397434c9262c3d62da3e91152184 +0 -0
  39. data/spec/dummy/tmp/cache/assets/C59/250/sprockets%2Fa80d3fe493d2476e58c4323996064512 +0 -0
  40. data/spec/dummy/tmp/cache/assets/C72/150/sprockets%2F4194031b4b51b6422c14ac697e3455e5 +0 -0
  41. data/spec/dummy/tmp/cache/assets/C75/D50/sprockets%2F5302968a40e08d2c011aa38666d273f6 +0 -0
  42. data/spec/dummy/tmp/cache/assets/C78/6B0/sprockets%2F173640f631a07f48c900a9c2923c825b +0 -0
  43. data/spec/dummy/tmp/cache/assets/C78/EF0/sprockets%2F65f827a4a5337d05d037845161b41ab8 +0 -0
  44. data/spec/dummy/tmp/cache/assets/C78/F80/sprockets%2F9161622ddd251097a4ab816b8220984c +0 -0
  45. data/spec/dummy/tmp/cache/assets/C7A/EC0/sprockets%2F5c16e4214f5662e1b27932a57c43491b +0 -0
  46. data/spec/dummy/tmp/cache/assets/C7C/AC0/sprockets%2F29124be1160817c61bb4878894b2ba55 +0 -0
  47. data/spec/dummy/tmp/cache/assets/C80/F70/sprockets%2Fe5c9811902c221828ea647978f000be3 +0 -0
  48. data/spec/dummy/tmp/cache/assets/C87/2C0/sprockets%2F60f61c07481249fc7922664609fcae52 +0 -0
  49. data/spec/dummy/tmp/cache/assets/C89/700/sprockets%2F259935a7704fef0069303ea63fa89408 +0 -0
  50. data/spec/dummy/tmp/cache/assets/C8A/460/sprockets%2F77bffd9959420103906722b404ae8d59 +0 -0
  51. data/spec/dummy/tmp/cache/assets/C91/FA0/sprockets%2F2eb81283f5789ae91a69344552db3856 +0 -0
  52. data/spec/dummy/tmp/cache/assets/C97/430/sprockets%2Fc049582fd1c9178ff983323f75326f64 +0 -0
  53. data/spec/dummy/tmp/cache/assets/CA2/F50/sprockets%2F86094c5d1b6399d614b0771a3a0a45b0 +0 -0
  54. data/spec/dummy/tmp/cache/assets/CA6/2F0/sprockets%2F20040c18b672e4c4d2731a2a929d8b97 +0 -0
  55. data/spec/dummy/tmp/cache/assets/CA9/C40/sprockets%2F932b7e2cd1e067289ab51190800814df +0 -0
  56. data/spec/dummy/tmp/cache/assets/CAA/0C0/sprockets%2F057b0ce384f16d9202ae84473436cc35 +0 -0
  57. data/spec/dummy/tmp/cache/assets/CAD/410/sprockets%2F651414e5c7e86f05c5108dc71626b25c +0 -0
  58. data/spec/dummy/tmp/cache/assets/CB4/6A0/sprockets%2F7373c9de844b711519cb49c4f1b16822 +0 -0
  59. data/spec/dummy/tmp/cache/assets/CBB/FA0/sprockets%2F74922109263bdc965b2e9567eec6d154 +0 -0
  60. data/spec/dummy/tmp/cache/assets/CBF/630/sprockets%2F707d2db81468088470d476abff35388d +0 -0
  61. data/spec/dummy/tmp/cache/assets/CCE/C50/sprockets%2Fe12774c2fea852112414bb379a71f31a +0 -0
  62. data/spec/dummy/tmp/cache/assets/CD3/460/sprockets%2F7f3f6802b0b309ed142d0b671c9640c4 +0 -0
  63. data/spec/dummy/tmp/cache/assets/CD9/DD0/sprockets%2Fe5774759168a731da1c1149ecf0e1b03 +0 -0
  64. data/spec/dummy/tmp/cache/assets/CDB/630/sprockets%2Ffd1626fe1016c81d57217f7f80c4370a +0 -0
  65. data/spec/dummy/tmp/cache/assets/CE0/090/sprockets%2F48d5d35ae87d0723318b8bc257fa2237 +0 -0
  66. data/spec/dummy/tmp/cache/assets/CE1/250/sprockets%2Ffdc680a0d4383d37910e549ca96f5303 +0 -0
  67. data/spec/dummy/tmp/cache/assets/CE1/730/sprockets%2Fa1678837061e18d7aca0286c07acf676 +0 -0
  68. data/spec/dummy/tmp/cache/assets/CE2/190/sprockets%2F0183b0f4e9f302b8677a5e31c45c89c5 +0 -0
  69. data/spec/dummy/tmp/cache/assets/CE3/1F0/sprockets%2Fe69a515d3a9d14c669be8871012a7d07 +0 -0
  70. data/spec/dummy/tmp/cache/assets/CE6/270/sprockets%2F2c98152560d18470fec8cf4c6829b4d0 +0 -0
  71. data/spec/dummy/tmp/cache/assets/CE6/7C0/sprockets%2Fa03a2c86ce6724be8542295e1cf24798 +0 -0
  72. data/spec/dummy/tmp/cache/assets/CE7/600/sprockets%2F7656791c172a6037cfffe2a226291c9e +0 -0
  73. data/spec/dummy/tmp/cache/assets/CE7/A60/sprockets%2Ff58eee249aa167d23f8220087bb46684 +0 -0
  74. data/spec/dummy/tmp/cache/assets/CE9/9E0/sprockets%2F135480d497ed7e4884462dc0ef0b80d7 +0 -0
  75. data/spec/dummy/tmp/cache/assets/CEB/090/sprockets%2F55dcd7ace406b77208c380d496e37864 +0 -0
  76. data/spec/dummy/tmp/cache/assets/CEB/680/sprockets%2F67f0794ef8c0576d5c7da34f4437305a +0 -0
  77. data/spec/dummy/tmp/cache/assets/CEB/B40/sprockets%2F1150bf8d912aa100a132251eefaf6045 +0 -0
  78. data/spec/dummy/tmp/cache/assets/CEC/360/sprockets%2F264b79dde726b36d63fee272a0609469 +0 -0
  79. data/spec/dummy/tmp/cache/assets/CF4/6F0/sprockets%2Fed96f92571224b862b84d7078b86ded3 +0 -0
  80. data/spec/dummy/tmp/cache/assets/CF7/F10/sprockets%2F8c45854ebd195b52cc42bf3f99996336 +0 -0
  81. data/spec/dummy/tmp/cache/assets/CF8/780/sprockets%2F8845b81ff27cdb57c835836c9f91a265 +0 -0
  82. data/spec/dummy/tmp/cache/assets/CFB/210/sprockets%2F9104695bfbf9a9d4b94382e6e90487a9 +0 -0
  83. data/spec/dummy/tmp/cache/assets/CFC/380/sprockets%2Fa7443cbd671446a589867dd5f4a4f989 +0 -0
  84. data/spec/dummy/tmp/cache/assets/D00/110/sprockets%2F6a6353b7723a8b21708e0fbfe04bd422 +0 -0
  85. data/spec/dummy/tmp/cache/assets/D00/F60/sprockets%2F42e279b52511c47d26c0adb125fd04e8 +0 -0
  86. data/spec/dummy/tmp/cache/assets/D03/630/sprockets%2F5d8da32dba6a7be70426a1d554773701 +0 -0
  87. data/spec/dummy/tmp/cache/assets/D04/170/sprockets%2F76ab1dc02e6c7618852708a1e05a2df3 +0 -0
  88. data/spec/dummy/tmp/cache/assets/D04/480/sprockets%2F8bd8f10500b21d2f9d94e4cd1401c936 +0 -0
  89. data/spec/dummy/tmp/cache/assets/D05/8D0/sprockets%2F319f8f235f452343f1ebf03cb262d23d +0 -0
  90. data/spec/dummy/tmp/cache/assets/D09/BF0/sprockets%2F9e6bca5d26f50d9484385d51ba04312c +0 -0
  91. data/spec/dummy/tmp/cache/assets/D0B/740/sprockets%2F781d3a2f0449451e9f35c5b0e3e2df41 +0 -0
  92. data/spec/dummy/tmp/cache/assets/D0E/570/sprockets%2F90fe371bf8091e88a712124d9cdae260 +0 -0
  93. data/spec/dummy/tmp/cache/assets/D11/D60/sprockets%2F06d6413e059dbac9a62155639ce88d2c +0 -0
  94. data/spec/dummy/tmp/cache/assets/D11/F80/sprockets%2F48961522f6cd1a15f2fe6e25f1b37a75 +0 -0
  95. data/spec/dummy/tmp/cache/assets/D12/F40/sprockets%2Fb6f95541e256c15909e0a5a5fbf2a359 +0 -0
  96. data/spec/dummy/tmp/cache/assets/D15/750/sprockets%2F8effdd3e668a4036260a3e370f3b6657 +0 -0
  97. data/spec/dummy/tmp/cache/assets/D17/710/sprockets%2Ffa49fb6823d466e79a195e0cd71340c5 +0 -0
  98. data/spec/dummy/tmp/cache/assets/D18/AF0/sprockets%2F8f572049bd1b0a6f1eb3d27979c9544c +0 -0
  99. data/spec/dummy/tmp/cache/assets/D1A/D30/sprockets%2F815a5177e9edba0c5c996182ef1b3675 +0 -0
  100. data/spec/dummy/tmp/cache/assets/D1B/730/sprockets%2Fcf6ce779d043d29aae915f599a413380 +0 -0
  101. data/spec/dummy/tmp/cache/assets/D1D/560/sprockets%2F1ca784ee7ba1922465147e7f8963eae5 +0 -0
  102. data/spec/dummy/tmp/cache/assets/D21/AD0/sprockets%2Fd471d7f687f61341d8b19efc41f39e44 +0 -0
  103. data/spec/dummy/tmp/cache/assets/D22/D70/sprockets%2Fe86ae12aa97067ed78aa94489484ec16 +0 -0
  104. data/spec/dummy/tmp/cache/assets/D2F/810/sprockets%2F1a2674b7dac8ff403c23a570475ace04 +0 -0
  105. data/spec/dummy/tmp/cache/assets/D30/480/sprockets%2Feb011f46c64dbefb1f7e21329644c240 +0 -0
  106. data/spec/dummy/tmp/cache/assets/D31/9C0/sprockets%2Fbd102a4f5a4985c3519dd6ab0295a1c6 +0 -0
  107. data/spec/dummy/tmp/cache/assets/D34/920/sprockets%2Ff234dd736ae50902ba074c526ca8f0c8 +0 -0
  108. data/spec/dummy/tmp/cache/assets/D35/7C0/sprockets%2Ff536a2606eaf7d542c0985104cb62baf +0 -0
  109. data/spec/dummy/tmp/cache/assets/D35/F00/sprockets%2F8e7f22358123b7eb5e21d17f442ce0ac +0 -0
  110. data/spec/dummy/tmp/cache/assets/D37/810/sprockets%2F99de576ce6ad42b5c0843fc21c2025b2 +0 -0
  111. data/spec/dummy/tmp/cache/assets/D37/FF0/sprockets%2F96841ca4cfae32c515077f3f5fc303b2 +0 -0
  112. data/spec/dummy/tmp/cache/assets/D39/BE0/sprockets%2Fdb727091cf3e4b4f6126c48b6063ef0b +0 -0
  113. data/spec/dummy/tmp/cache/assets/D3C/840/sprockets%2Fc6202ec91d567a85bd3d46dc43ea9108 +0 -0
  114. data/spec/dummy/tmp/cache/assets/D3D/EC0/sprockets%2F1aa82cb99ef076aea10d472b30a58979 +0 -0
  115. data/spec/dummy/tmp/cache/assets/D3F/3A0/sprockets%2F1b3734b358a405ca6f92455db8e4b5ff +0 -0
  116. data/spec/dummy/tmp/cache/assets/D45/C30/sprockets%2Fcc744877558178a3adb77c441cadce70 +0 -0
  117. data/spec/dummy/tmp/cache/assets/D48/160/sprockets%2F32bae66fd65ce3643efb543182f2e885 +0 -0
  118. data/spec/dummy/tmp/cache/assets/D49/1F0/sprockets%2F773b56f87127c6605e7d1d3faf2b6af6 +0 -0
  119. data/spec/dummy/tmp/cache/assets/D49/A10/sprockets%2Fc4656bd995a6f297c26d19b13aadb963 +0 -0
  120. data/spec/dummy/tmp/cache/assets/D4A/A50/sprockets%2Fb95795be8b937dab770541e27ddb2e70 +0 -0
  121. data/spec/dummy/tmp/cache/assets/D4C/840/sprockets%2F7732c94884c24e764f109ce2deb2a9ed +0 -0
  122. data/spec/dummy/tmp/cache/assets/D50/D70/sprockets%2Fe2a3e6c95b11e0801a4eebae3a026026 +0 -0
  123. data/spec/dummy/tmp/cache/assets/D51/400/sprockets%2Ff5e433d8a31e80985b75ce598de236be +0 -0
  124. data/spec/dummy/tmp/cache/assets/D58/870/sprockets%2F3cef1ff075a050004b74ffa13c8c4f02 +0 -0
  125. data/spec/dummy/tmp/cache/assets/D5B/9D0/sprockets%2F9c18c0aa5bbe1b323c5022c98aa09f29 +0 -0
  126. data/spec/dummy/tmp/cache/assets/D5B/E60/sprockets%2F167c229432f74a17b4c6a07bbb19aacb +0 -0
  127. data/spec/dummy/tmp/cache/assets/D5C/710/sprockets%2F9427d05cee2caa721241a25a9af1d08f +0 -0
  128. data/spec/dummy/tmp/cache/assets/D5C/CC0/sprockets%2Faa8bf6de211f2765b0a26f112b971f0c +0 -0
  129. data/spec/dummy/tmp/cache/assets/D5E/FA0/sprockets%2Fc81c371ae2d61a6aa1708262fba79e0d +0 -0
  130. data/spec/dummy/tmp/cache/assets/D60/060/sprockets%2Fe8a6ac51dd42491eaa2f9130c1629eb2 +0 -0
  131. data/spec/dummy/tmp/cache/assets/D61/1F0/sprockets%2F0c7a6176d2fc4db00bb9a74d36380fe1 +0 -0
  132. data/spec/dummy/tmp/cache/assets/D61/BD0/sprockets%2Ff96fcad988ca7fea975e538c27188605 +0 -0
  133. data/spec/dummy/tmp/cache/assets/D65/AD0/sprockets%2Fcc53fff930eaf306c15c4568cb265c00 +0 -0
  134. data/spec/dummy/tmp/cache/assets/D67/030/sprockets%2Fb8b36ba6104c8dbe6297b4e61e6d33b1 +0 -0
  135. data/spec/dummy/tmp/cache/assets/D67/BC0/sprockets%2F35d2c2b45981ade5a2db2a9c7f37a615 +0 -0
  136. data/spec/dummy/tmp/cache/assets/D69/F90/sprockets%2F6a0795b7b38bd7e6142cd1b88211dade +0 -0
  137. data/spec/dummy/tmp/cache/assets/D6A/950/sprockets%2F429b1806cb7580ebf29f9a12c33cbea6 +0 -0
  138. data/spec/dummy/tmp/cache/assets/D6C/9C0/sprockets%2Fd66bdf546164ba223e20f56b5591ddfd +0 -0
  139. data/spec/dummy/tmp/cache/assets/D6D/530/sprockets%2F8d52dee91bff01a8a2306d8a7c9152a9 +0 -0
  140. data/spec/dummy/tmp/cache/assets/D6D/DA0/sprockets%2Fac936bf40b42227a2bf9d474ae9ec149 +0 -0
  141. data/spec/dummy/tmp/cache/assets/D6F/310/sprockets%2F624b651d37f7ec0c563c446fbf8afb32 +0 -0
  142. data/spec/dummy/tmp/cache/assets/D71/A70/sprockets%2F4f10f5dd56c8a3ff78c460bbe3723a39 +0 -0
  143. data/spec/dummy/tmp/cache/assets/D72/C10/sprockets%2Ffbdb5250837c5cb856f464eb2cb3388b +0 -0
  144. data/spec/dummy/tmp/cache/assets/D73/5D0/sprockets%2F5c8608f3e25d077fa3df8cd32b50c37f +0 -0
  145. data/spec/dummy/tmp/cache/assets/D73/C00/sprockets%2F9cf4bfb486e4ab461e3f275a3d974c30 +0 -0
  146. data/spec/dummy/tmp/cache/assets/D77/B30/sprockets%2F946cf2f17c7eb41037f9ee08ad67ec40 +0 -0
  147. data/spec/dummy/tmp/cache/assets/D78/2F0/sprockets%2F3c61f8915b8f717b1de788e6ecad122c +0 -0
  148. data/spec/dummy/tmp/cache/assets/D78/870/sprockets%2F8f3a7d4fcd104fa8e47f552f6630a49e +0 -0
  149. data/spec/dummy/tmp/cache/assets/D7E/C10/sprockets%2F747c98c3cc7494a62dd882752adffb2b +0 -0
  150. data/spec/dummy/tmp/cache/assets/D7F/6C0/sprockets%2F77fe714bfff7e409a9d838cdf126700c +0 -0
  151. data/spec/dummy/tmp/cache/assets/D84/560/sprockets%2Ff09b671d3f5f8a48d7fa28e2c59ca389 +0 -0
  152. data/spec/dummy/tmp/cache/assets/D85/5D0/sprockets%2Fde362e334a475cfca1a30fa5b713b43a +0 -0
  153. data/spec/dummy/tmp/cache/assets/D8C/520/sprockets%2F221cd58a042baac534d27e4cfedc1188 +0 -0
  154. data/spec/dummy/tmp/cache/assets/D92/C00/sprockets%2F63c8bb5e2b2d9db4a2ed16f056a234c6 +0 -0
  155. data/spec/dummy/tmp/cache/assets/D97/520/sprockets%2Fea2442ae4caddb758dfb1964c601b476 +0 -0
  156. data/spec/dummy/tmp/cache/assets/D9C/510/sprockets%2Fab9bab3574dac2d1681189debb7d8255 +0 -0
  157. data/spec/dummy/tmp/cache/assets/D9D/440/sprockets%2F869f9acc13b88cf15a31d24a0ac3f6f6 +0 -0
  158. data/spec/dummy/tmp/cache/assets/D9E/CB0/sprockets%2Ff0efe0ab6bd753a8bb4481e46243d77f +0 -0
  159. data/spec/dummy/tmp/cache/assets/DA0/330/sprockets%2Fcbbb4de706387d50f48a72ee6c9c1b80 +0 -0
  160. data/spec/dummy/tmp/cache/assets/DA5/0A0/sprockets%2F7a4b5928cec69ab65afff309a04d6b47 +0 -0
  161. data/spec/dummy/tmp/cache/assets/DA6/D80/sprockets%2F8702dce2e6b9879a6add309e92ace2f0 +0 -0
  162. data/spec/dummy/tmp/cache/assets/DA8/C50/sprockets%2F0810627fddce930a399fc60d3be97fed +0 -0
  163. data/spec/dummy/tmp/cache/assets/DAA/1E0/sprockets%2F412dd3bd3026759a3f6ffe8cf9e7b93a +0 -0
  164. data/spec/dummy/tmp/cache/assets/DAA/2B0/sprockets%2Fe0c5d93fa08d139e198bfe47cd42b99a +0 -0
  165. data/spec/dummy/tmp/cache/assets/DAE/4E0/sprockets%2F88cc3ab99c608879dd56164dbcc2ccb7 +0 -0
  166. data/spec/dummy/tmp/cache/assets/DAE/6C0/sprockets%2F77c7a8676aeefa73156c55dfcf51cc46 +0 -0
  167. data/spec/dummy/tmp/cache/assets/DAF/5B0/sprockets%2F780e81d97e4eefcce73e0b82a5b1859d +0 -0
  168. data/spec/dummy/tmp/cache/assets/DB3/5D0/sprockets%2Fce1d4d75832c9bdeafd869f6f7b61725 +0 -0
  169. data/spec/dummy/tmp/cache/assets/DB5/040/sprockets%2F9a9da5df88713663b9fbc945facca891 +0 -0
  170. data/spec/dummy/tmp/cache/assets/DB5/860/sprockets%2Facf25fab3016425a0e03c9d190fd4eac +0 -0
  171. data/spec/dummy/tmp/cache/assets/DB9/220/sprockets%2Fd2dc4f59e70e73984997ffca8ad7f4a0 +0 -0
  172. data/spec/dummy/tmp/cache/assets/DC3/230/sprockets%2Fdf52e72eb73be91eccc60182191aed0b +0 -0
  173. data/spec/dummy/tmp/cache/assets/DC3/AC0/sprockets%2Fe29911eb34fdf4b710dd0d2c2cf24bc9 +0 -0
  174. data/spec/dummy/tmp/cache/assets/DC4/860/sprockets%2Fa01a3cf460ff15daae0f928d0f85f52e +0 -0
  175. data/spec/dummy/tmp/cache/assets/DC7/A10/sprockets%2F84a8af0fcbf401864e1ae5bf092cba94 +0 -0
  176. data/spec/dummy/tmp/cache/assets/DCB/620/sprockets%2F27a68cf9fe11fb1b6326d11eba7e76cb +0 -0
  177. data/spec/dummy/tmp/cache/assets/DCD/EB0/sprockets%2F4f77f509126ecbced7ea2a5ab290c8d4 +0 -0
  178. data/spec/dummy/tmp/cache/assets/DE3/6C0/sprockets%2F51c550cc1b3b021aa9aede66a5a36aff +0 -0
  179. data/spec/dummy/tmp/cache/assets/DE4/140/sprockets%2F139e4ab85d1aacb22c115fa136afdc8a +0 -0
  180. data/spec/dummy/tmp/cache/assets/DEB/110/sprockets%2F2dbdab0ce5babca645cdb5780004f875 +0 -0
  181. data/spec/dummy/tmp/cache/assets/DF1/1B0/sprockets%2F2b1bc202f9a338942edbccb2cfef0d67 +0 -0
  182. data/spec/dummy/tmp/cache/assets/DF6/0E0/sprockets%2F85b10db6e1afe643aba6d396abdd77f0 +0 -0
  183. data/spec/dummy/tmp/cache/assets/DF7/E10/sprockets%2F25e4253aba9a9adcefb72552fb1ff0c8 +0 -0
  184. data/spec/dummy/tmp/cache/assets/DF9/AD0/sprockets%2Fc700afd7cee3fe9d7ff8352b213b2c4a +0 -0
  185. data/spec/dummy/tmp/cache/assets/DFC/C20/sprockets%2Fd9178ad7e3b401c9fceafd64ea2b50d6 +0 -0
  186. data/spec/dummy/tmp/cache/assets/DFC/C30/sprockets%2Fb50a07cb30b0bd0eec8e98e5de79d65d +0 -0
  187. data/spec/dummy/tmp/cache/assets/E02/6E0/sprockets%2F63d6a5cdb8cefa64ef76b5c6e0fd3720 +0 -0
  188. data/spec/dummy/tmp/cache/assets/E08/5A0/sprockets%2Fe7148db8eea925c3c9f1ee340d53ceff +0 -0
  189. data/spec/dummy/tmp/cache/assets/E08/BB0/sprockets%2Fefac99af1af28543aef6fb607faa4973 +0 -0
  190. data/spec/dummy/tmp/cache/assets/E08/F20/sprockets%2F4fc5cdcd6974efe7adfe809b30bd6513 +0 -0
  191. data/spec/dummy/tmp/cache/assets/E16/D30/sprockets%2Fd69469e6e7439baacd8df989c0fdacc2 +0 -0
  192. data/spec/dummy/tmp/cache/assets/E17/EF0/sprockets%2Fa291ad64a26afd055dfadabbdf03f154 +0 -0
  193. data/spec/dummy/tmp/cache/assets/E41/250/sprockets%2F97cf8fe3d7ffaff076f655aefb36da03 +0 -0
  194. data/spec/dummy/tmp/cache/assets/E6E/260/sprockets%2Fd9f8ab8b91ef582cc6c99a3ba0dedfe6 +0 -0
  195. data/spec/dummy/tmp/cache/assets/F79/360/sprockets%2F0ce035fefee5ebdabc8efabfbdbd6ee4 +0 -0
  196. data/spec/javascripts/teabag/base/reporters/console_spec.coffee +69 -42
  197. data/spec/javascripts/teabag/base/reporters/html/base_view_spec.coffee +88 -0
  198. data/spec/javascripts/teabag/base/reporters/html_spec.coffee +218 -218
  199. data/spec/javascripts/teabag/base/runner_spec.coffee +22 -0
  200. data/spec/javascripts/teabag/base/teabag_spec.coffee +1 -1
  201. data/spec/javascripts/teabag/jasmine/models_jspec.coffee +101 -0
  202. data/spec/javascripts/teabag/jasmine/runner_jspec.coffee +1 -1
  203. data/spec/javascripts/teabag/mocha/models_mspec.coffee +95 -0
  204. data/spec/javascripts/teabag/mocha/reporters/console_mspec.coffee +4 -0
  205. data/spec/javascripts/teabag/mocha/runner_mspec.coffee +7 -7
  206. data/spec/javascripts/teabag/phantomjs/runner_spec.coffee +5 -5
  207. data/spec/teabag/configuration_spec.rb +2 -2
  208. data/spec/teabag/console_spec.rb +5 -17
  209. data/spec/teabag/drivers/phantomjs_driver_spec.rb +29 -0
  210. data/spec/teabag/drivers/selenium_driver_spec.rb +60 -0
  211. data/spec/teabag/formatters/{progress_formatter_spec.rb → dot_formatter_spec.rb} +14 -14
  212. data/spec/teabag/formatters/tap_y_formatter_spec.rb +190 -0
  213. data/spec/teabag/result_spec.rb +12 -42
  214. data/spec/teabag/runner_spec.rb +12 -6
  215. data/vendor/assets/javascripts/qunit-1.10.0.MIT.LICENSE +1 -0
  216. data/vendor/assets/javascripts/qunit-1.10.0.js +1977 -0
  217. metadata +161 -11
  218. data/app/assets/javascripts/teabag/base/reporters.coffee +0 -105
  219. data/spec/javascripts/teabag/base/reporters_spec.coffee +0 -267
@@ -1,8 +1,8 @@
1
1
  require "spec_helper"
2
- require "teabag/formatters/progress_formatter"
2
+ require "teabag/formatters/dot_formatter"
3
3
  require "teabag/result"
4
4
 
5
- describe Teabag::Formatters::ProgressFormatter do
5
+ describe Teabag::Formatters::DotFormatter do
6
6
 
7
7
  before do
8
8
  @log = ""
@@ -14,23 +14,23 @@ describe Teabag::Formatters::ProgressFormatter do
14
14
  it "tracks totals" do
15
15
  subject.total = 41
16
16
  subject.should_receive(:log).with(".", 32)
17
- subject.spec(Teabag::Result.build_from_json("default", "status" => "passed"))
17
+ subject.spec(Teabag::Result.build_from_json("status" => "passed"))
18
18
  expect(subject.total).to be(42)
19
19
  end
20
20
 
21
21
  it "logs a green . on pass" do
22
22
  subject.should_receive(:log).with(".", 32)
23
- subject.spec(Teabag::Result.build_from_json("default", "status" => "passed"))
23
+ subject.spec(Teabag::Result.build_from_json("status" => "passed"))
24
24
  end
25
25
 
26
26
  it "logs a yellow * on pending" do
27
27
  subject.should_receive(:log).with("*", 33)
28
- subject.spec(Teabag::Result.build_from_json("default", "status" => "pending"))
28
+ subject.spec(Teabag::Result.build_from_json("status" => "pending"))
29
29
  end
30
30
 
31
31
  it "logs a red F on anything else" do
32
32
  subject.should_receive(:log).with("F", 31)
33
- subject.spec(Teabag::Result.build_from_json("default", "status" => "foo"))
33
+ subject.spec(Teabag::Result.build_from_json("status" => "foo"))
34
34
  end
35
35
 
36
36
  end
@@ -45,7 +45,7 @@ describe Teabag::Formatters::ProgressFormatter do
45
45
 
46
46
  end
47
47
 
48
- describe "#results" do
48
+ describe "#result" do
49
49
 
50
50
  before do
51
51
  subject.total = 666
@@ -54,7 +54,7 @@ describe Teabag::Formatters::ProgressFormatter do
54
54
  describe "with no failures" do
55
55
 
56
56
  it "logs the details" do
57
- subject.results("elapsed" => 0.31337)
57
+ subject.result("elapsed" => 0.31337)
58
58
  expect(@log).to eq("\n\nFinished in 0.31337 seconds\n\e[32m666 examples, 0 failures\n\e[0m")
59
59
  end
60
60
 
@@ -63,9 +63,9 @@ describe Teabag::Formatters::ProgressFormatter do
63
63
  describe "with failures" do
64
64
 
65
65
  it "logs the details and raises an exception" do
66
- subject.failures << Teabag::Result.build_from_json("default", "spec" => "some spec", "full_description" => "full description some spec", "message" => "some message", "link" => "?grep=some%20spec")
66
+ subject.failures << Teabag::Result.build_from_json("label" => "some spec", "suite" => "full description", "message" => "some message", "link" => "?grep=some%20spec")
67
67
  expect {
68
- subject.results("elapsed" => 0.31337)
68
+ subject.result("elapsed" => 0.31337)
69
69
  }.to raise_error(Teabag::Failure)
70
70
  expect(@log).to eq("\n\nFailures:\n\n 1) full description some spec\n\e[31m Failure/Error: some message\n\e[0m\nFinished in 0.31337 seconds\n\e[31m666 examples, 1 failure\n\e[0m\nFailed examples:\n\e[31m\n/teabag/default?grep=some%20spec\e[0m\n\n")
71
71
  expect(subject.failures.length).to be(1)
@@ -79,8 +79,8 @@ describe Teabag::Formatters::ProgressFormatter do
79
79
 
80
80
  it "doesn't raise the exception" do
81
81
  Teabag.configuration.fail_fast = false
82
- subject.failures << Teabag::Result.build_from_json("default", "spec" => "some spec", "message" => "some message", "link" => "?grep=some%20spec")
83
- subject.results("elapsed" => 0.31337, "failures" => 1, "pending" => 0, "total" => 666)
82
+ subject.failures << Teabag::Result.build_from_json("message" => "some message")
83
+ subject.result("elapsed" => 0.31337)
84
84
  expect(subject.failures.length).to be(1)
85
85
  end
86
86
 
@@ -91,8 +91,8 @@ describe Teabag::Formatters::ProgressFormatter do
91
91
  describe "with pending" do
92
92
 
93
93
  it "logs the details" do
94
- subject.pendings << Teabag::Result.build_from_json("default", "spec" => "some spec", "full_description" => "full description some spec")
95
- subject.results("elapsed" => 0.31337)
94
+ subject.pendings << Teabag::Result.build_from_json("label" => "some spec", "suite" => "full description")
95
+ subject.result("elapsed" => 0.31337)
96
96
  expect(@log).to eq("\n\nPending:\e[33m\n full description some spec\n\e[0m\e[36m # Not yet implemented\n\e[0m\nFinished in 0.31337 seconds\n\e[33m666 examples, 0 failures, 1 pending\n\e[0m")
97
97
  end
98
98
 
@@ -0,0 +1,190 @@
1
+ require "spec_helper"
2
+ require "teabag/formatters/tap_y_formatter"
3
+ require "teabag/result"
4
+
5
+ describe Teabag::Formatters::TapYFormatter do
6
+
7
+ before do
8
+ @log = ""
9
+ STDOUT.stub(:print) { |s| @log << s }
10
+ end
11
+
12
+ describe "#runner" do
13
+
14
+ let(:json) { {"start" => "_start_", "total" => 20} }
15
+
16
+ it "logs the information" do
17
+ result = Teabag::Result.build_from_json(json)
18
+ subject.should_receive(:log).with(
19
+ "type" => "suite",
20
+ "start" => "_start_",
21
+ "count" => 20,
22
+ "seed" => 0,
23
+ "rev" => 4
24
+ )
25
+ subject.runner(result)
26
+ end
27
+
28
+ end
29
+
30
+ describe "#suite" do
31
+
32
+ let(:json) { {"label" => "_label_", "level" => 1} }
33
+
34
+ it "logs the information" do
35
+ result = Teabag::Result.build_from_json(json)
36
+ subject.should_receive(:log).with(
37
+ "type" => "case",
38
+ "label" => "_label_",
39
+ "level" => 1
40
+ )
41
+ subject.suite(result)
42
+ end
43
+
44
+ end
45
+
46
+ describe "#spec" do
47
+
48
+ describe "passing spec" do
49
+
50
+ let(:json) { {"status" => "passed"} }
51
+
52
+ it "calls passing_spec" do
53
+ result = Teabag::Result.build_from_json(json)
54
+ subject.should_receive(:passing_spec)
55
+ subject.spec(result)
56
+ end
57
+
58
+ end
59
+
60
+ describe "pending spec" do
61
+
62
+ let(:json) { {"status" => "pending"} }
63
+
64
+ it "calls pending_spec" do
65
+ result = Teabag::Result.build_from_json(json)
66
+ subject.should_receive(:pending_spec)
67
+ subject.spec(result)
68
+ end
69
+
70
+ end
71
+
72
+ describe "failing spec" do
73
+
74
+ let(:json) { {"status" => "fail"} }
75
+
76
+ it "calls failing_spec" do
77
+ result = Teabag::Result.build_from_json(json)
78
+ subject.should_receive(:failing_spec)
79
+ subject.spec(result)
80
+ end
81
+
82
+ end
83
+
84
+ end
85
+
86
+ describe "#result" do
87
+
88
+ let(:json) { {"elapsed" => "0.00666"} }
89
+
90
+ it "logs the information" do
91
+ result = Teabag::Result.build_from_json(json)
92
+ subject.should_receive(:log).with(
93
+ "type" => "final",
94
+ "time" => "0.00666",
95
+ "counts" => {
96
+ "total" => 0,
97
+ "pass" => 0,
98
+ "fail" => 0,
99
+ "error" => 0,
100
+ "omit" => 0,
101
+ "todo" => 0
102
+ }
103
+ )
104
+ subject.result(result)
105
+ end
106
+
107
+ end
108
+
109
+ describe "#error" do
110
+
111
+ it "keeps count" do
112
+ expect(subject.errors.size).to be(0)
113
+ subject.error("foo")
114
+ expect(subject.errors.size).to be(1)
115
+ end
116
+
117
+ end
118
+
119
+ describe "#passing_spec" do
120
+
121
+ let(:json) { {"label" => "_label_"} }
122
+
123
+ it "logs the information" do
124
+ result = Teabag::Result.build_from_json(json)
125
+ subject.should_receive(:log).with(
126
+ "type" => "test",
127
+ "status" => "pass",
128
+ "label" => "_label_"
129
+ )
130
+ subject.instance_variable_set(:@result, result)
131
+ subject.send(:passing_spec)
132
+ end
133
+
134
+ end
135
+
136
+ describe "#pending_spec" do
137
+
138
+ let(:json) { {"label" => "_label_", "message" => "_message_"} }
139
+
140
+ it "logs the information" do
141
+ result = Teabag::Result.build_from_json(json)
142
+ subject.should_receive(:log).with(
143
+ "type" => "test",
144
+ "status" => "pending",
145
+ "label" => "_label_",
146
+ "exception" => {
147
+ "message" => "_message_"
148
+ }
149
+ )
150
+ subject.instance_variable_set(:@result, result)
151
+ subject.send(:pending_spec)
152
+ end
153
+
154
+ end
155
+
156
+ describe "#failing_spec" do
157
+
158
+ let(:json) { {"label" => "_label_", "link" => "_link_", "message" => "_message_"} }
159
+
160
+ it "logs the information" do
161
+ result = Teabag::Result.build_from_json(json)
162
+ subject.should_receive(:log).with(
163
+ "type" => "test",
164
+ "status" => "fail",
165
+ "label" => "_label_",
166
+ "exception" => {
167
+ "message" => "_message_",
168
+ "backtrace" => ["_link_#:0"],
169
+ "file" => "unknown",
170
+ "line" => "unknown",
171
+ "source" => "unknown",
172
+ "snippet" => {"0" => "_link_"},
173
+ "class" => "Unknown"
174
+ }
175
+ )
176
+ subject.instance_variable_set(:@result, result)
177
+ subject.send(:failing_spec)
178
+ end
179
+
180
+ end
181
+
182
+ describe "#log" do
183
+
184
+ it "calls STDOUT.print" do
185
+ STDOUT.should_receive(:print).with(%{---\nfoo: bar\n})
186
+ subject.send(:log, "foo" => "bar")
187
+ end
188
+ end
189
+
190
+ end
@@ -1,4 +1,5 @@
1
1
  require "spec_helper"
2
+ require "teabag/result"
2
3
 
3
4
  describe Teabag::Result do
4
5
 
@@ -6,19 +7,19 @@ describe Teabag::Result do
6
7
  let(:json) do
7
8
  { "type" => "spec",
8
9
  "suite" => "_suite_name_",
9
- "spec" => "_spec_name_",
10
+ "label" => "_spec_name_",
10
11
  "status" => "failed",
11
12
  "skipped" => false,
12
13
  "link" => "?grep=_spec_description_",
13
14
  "message" => "_message_",
14
- "trace" => "_trace_",
15
- "full_description" => "_spec_description_" }
15
+ "trace" => "_trace_" }
16
16
  end
17
- let(:result) { Teabag::Result.build_from_json(suite_name, json) }
17
+ let(:result) { Teabag::Result.build_from_json(json) }
18
18
 
19
19
  describe ".build_from_json" do
20
20
 
21
21
  describe "with a results object" do
22
+
22
23
  let(:json) do
23
24
  { "elapsed" => 0.01,
24
25
  "failures" => 10,
@@ -26,60 +27,29 @@ describe Teabag::Result do
26
27
  "total" => 25 }
27
28
  end
28
29
 
29
- it 'should assign a suite name from the first parameter' do
30
- expect(result.teabag_suite).to eq('My Suite')
31
- end
32
-
33
- it 'should assign a elapsed from the JSON hash' do
30
+ it "assigns from the JSON hash" do
34
31
  expect(result.elapsed).to eq(0.01)
35
- end
36
-
37
- it 'should assign failures from the JSON hash' do
38
- expect(result.failures).to eq(10)
39
- end
40
-
41
- it 'should assign pending from the JSON hash' do
42
- expect(result.pending).to eq(1)
43
- end
44
-
45
- it 'should assign total from the JSON hash' do
46
32
  expect(result.total).to eq(25)
47
33
  end
48
34
 
49
35
  end
50
36
 
51
37
  describe "with a spec" do
52
- it 'should assign a suite name from the first parameter' do
53
- expect(result.teabag_suite).to eq('My Suite')
54
- end
55
- it 'should assign a type from the JSON hash' do
38
+
39
+ it "assigns from the JSON hash" do
56
40
  expect(result.type).to eq('spec')
57
- end
58
- it 'should assign a suite from the JSON hash' do
59
41
  expect(result.suite).to eq('_suite_name_')
60
- end
61
- it 'should assign a spec from the JSON hash' do
62
- expect(result.spec).to eq('_spec_name_')
63
- end
64
- it 'should assign a full description from the JSON hash' do
65
- expect(result.full_description).to eq('_spec_description_')
66
- end
67
- it 'should assign a status from the JSON hash' do
42
+ expect(result.label).to eq('_spec_name_')
43
+ expect(result.description).to eq('_suite_name_ _spec_name_')
68
44
  expect(result.status).to eq('failed')
69
- end
70
- it 'should assign skipped from the JSON hash' do
71
45
  expect(result.skipped).to be_false
72
- end
73
- it 'should assign a link from the JSON hash' do
74
46
  expect(result.link).to eq('?grep=_spec_description_')
75
- end
76
- it 'should assign a message from the JSON hash' do
77
47
  expect(result.message).to eq('_message_')
78
- end
79
- it 'should assign a trace from the JSON hash' do
80
48
  expect(result.trace).to eq('_trace_')
81
49
  end
50
+
82
51
  end
52
+
83
53
  end
84
54
 
85
55
  end
@@ -9,14 +9,20 @@ describe Teabag::Runner do
9
9
  STDOUT.stub(:print) { |s| @log << s }
10
10
  end
11
11
 
12
- describe "its constructor" do
12
+ describe "constructor" do
13
13
 
14
- it "creates a progress formatter if no other formatter is provided" do
15
- Teabag::Formatters::XmlFormatter = Class.new
16
- Teabag.configuration.formatters = "progress, xml"
17
- expect(subject.formatters[0]).to be_a(Teabag::Formatters::ProgressFormatter)
14
+ after do
15
+ Teabag.configuration.formatters = "dot"
16
+ end
17
+
18
+ it "instantiates formatters based on configuration" do
19
+ Teabag::Formatters::XmlFormatter = Class.new do
20
+ def initialize(suite_name = :default)
21
+ end
22
+ end
23
+ Teabag.configuration.formatters = "dot, xml"
24
+ expect(subject.formatters[0]).to be_a(Teabag::Formatters::DotFormatter)
18
25
  expect(subject.formatters[1]).to be_a(Teabag::Formatters::XmlFormatter)
19
- Teabag.configuration.formatters = "progress"
20
26
  end
21
27
 
22
28
  end
@@ -0,0 +1 @@
1
+ http://www.opensource.org/licenses/mit-license.php
@@ -0,0 +1,1977 @@
1
+ /**
2
+ * QUnit v1.10.0 - A JavaScript Unit Testing Framework
3
+ *
4
+ * http://qunitjs.com
5
+ *
6
+ * Copyright 2012 jQuery Foundation and other contributors
7
+ * Released under the MIT license.
8
+ * http://jquery.org/license
9
+ */
10
+
11
+ (function( window ) {
12
+
13
+ var QUnit,
14
+ config,
15
+ onErrorFnPrev,
16
+ testId = 0,
17
+ fileName = (sourceFromStacktrace( 0 ) || "" ).replace(/(:\d+)+\)?/, "").replace(/.+\//, ""),
18
+ toString = Object.prototype.toString,
19
+ hasOwn = Object.prototype.hasOwnProperty,
20
+ // Keep a local reference to Date (GH-283)
21
+ Date = window.Date,
22
+ defined = {
23
+ setTimeout: typeof window.setTimeout !== "undefined",
24
+ sessionStorage: (function() {
25
+ var x = "qunit-test-string";
26
+ try {
27
+ sessionStorage.setItem( x, x );
28
+ sessionStorage.removeItem( x );
29
+ return true;
30
+ } catch( e ) {
31
+ return false;
32
+ }
33
+ }())
34
+ };
35
+
36
+ function Test( settings ) {
37
+ extend( this, settings );
38
+ this.assertions = [];
39
+ this.testNumber = ++Test.count;
40
+ }
41
+
42
+ Test.count = 0;
43
+
44
+ Test.prototype = {
45
+ init: function() {
46
+ var a, b, li,
47
+ tests = id( "qunit-tests" );
48
+
49
+ if ( tests ) {
50
+ b = document.createElement( "strong" );
51
+ b.innerHTML = this.name;
52
+
53
+ // `a` initialized at top of scope
54
+ a = document.createElement( "a" );
55
+ a.innerHTML = "Rerun";
56
+ a.href = QUnit.url({ testNumber: this.testNumber });
57
+
58
+ li = document.createElement( "li" );
59
+ li.appendChild( b );
60
+ li.appendChild( a );
61
+ li.className = "running";
62
+ li.id = this.id = "qunit-test-output" + testId++;
63
+
64
+ tests.appendChild( li );
65
+ }
66
+ },
67
+ setup: function() {
68
+ if ( this.module !== config.previousModule ) {
69
+ if ( config.previousModule ) {
70
+ runLoggingCallbacks( "moduleDone", QUnit, {
71
+ name: config.previousModule,
72
+ failed: config.moduleStats.bad,
73
+ passed: config.moduleStats.all - config.moduleStats.bad,
74
+ total: config.moduleStats.all
75
+ });
76
+ }
77
+ config.previousModule = this.module;
78
+ config.moduleStats = { all: 0, bad: 0 };
79
+ runLoggingCallbacks( "moduleStart", QUnit, {
80
+ name: this.module
81
+ });
82
+ } else if ( config.autorun ) {
83
+ runLoggingCallbacks( "moduleStart", QUnit, {
84
+ name: this.module
85
+ });
86
+ }
87
+
88
+ config.current = this;
89
+
90
+ this.testEnvironment = extend({
91
+ setup: function() {},
92
+ teardown: function() {}
93
+ }, this.moduleTestEnvironment );
94
+
95
+ runLoggingCallbacks( "testStart", QUnit, {
96
+ name: this.testName,
97
+ module: this.module
98
+ });
99
+
100
+ // allow utility functions to access the current test environment
101
+ // TODO why??
102
+ QUnit.current_testEnvironment = this.testEnvironment;
103
+
104
+ if ( !config.pollution ) {
105
+ saveGlobal();
106
+ }
107
+ if ( config.notrycatch ) {
108
+ this.testEnvironment.setup.call( this.testEnvironment );
109
+ return;
110
+ }
111
+ try {
112
+ this.testEnvironment.setup.call( this.testEnvironment );
113
+ } catch( e ) {
114
+ QUnit.pushFailure( "Setup failed on " + this.testName + ": " + e.message, extractStacktrace( e, 1 ) );
115
+ }
116
+ },
117
+ run: function() {
118
+ config.current = this;
119
+
120
+ var running = id( "qunit-testresult" );
121
+
122
+ if ( running ) {
123
+ running.innerHTML = "Running: <br/>" + this.name;
124
+ }
125
+
126
+ if ( this.async ) {
127
+ QUnit.stop();
128
+ }
129
+
130
+ if ( config.notrycatch ) {
131
+ this.callback.call( this.testEnvironment, QUnit.assert );
132
+ return;
133
+ }
134
+
135
+ try {
136
+ this.callback.call( this.testEnvironment, QUnit.assert );
137
+ } catch( e ) {
138
+ QUnit.pushFailure( "Died on test #" + (this.assertions.length + 1) + " " + this.stack + ": " + e.message, extractStacktrace( e, 0 ) );
139
+ // else next test will carry the responsibility
140
+ saveGlobal();
141
+
142
+ // Restart the tests if they're blocking
143
+ if ( config.blocking ) {
144
+ QUnit.start();
145
+ }
146
+ }
147
+ },
148
+ teardown: function() {
149
+ config.current = this;
150
+ if ( config.notrycatch ) {
151
+ this.testEnvironment.teardown.call( this.testEnvironment );
152
+ return;
153
+ } else {
154
+ try {
155
+ this.testEnvironment.teardown.call( this.testEnvironment );
156
+ } catch( e ) {
157
+ QUnit.pushFailure( "Teardown failed on " + this.testName + ": " + e.message, extractStacktrace( e, 1 ) );
158
+ }
159
+ }
160
+ checkPollution();
161
+ },
162
+ finish: function() {
163
+ config.current = this;
164
+ if ( config.requireExpects && this.expected == null ) {
165
+ QUnit.pushFailure( "Expected number of assertions to be defined, but expect() was not called.", this.stack );
166
+ } else if ( this.expected != null && this.expected != this.assertions.length ) {
167
+ QUnit.pushFailure( "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run", this.stack );
168
+ } else if ( this.expected == null && !this.assertions.length ) {
169
+ QUnit.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.", this.stack );
170
+ }
171
+
172
+ var assertion, a, b, i, li, ol,
173
+ test = this,
174
+ good = 0,
175
+ bad = 0,
176
+ tests = id( "qunit-tests" );
177
+
178
+ config.stats.all += this.assertions.length;
179
+ config.moduleStats.all += this.assertions.length;
180
+
181
+ if ( tests ) {
182
+ ol = document.createElement( "ol" );
183
+
184
+ for ( i = 0; i < this.assertions.length; i++ ) {
185
+ assertion = this.assertions[i];
186
+
187
+ li = document.createElement( "li" );
188
+ li.className = assertion.result ? "pass" : "fail";
189
+ li.innerHTML = assertion.message || ( assertion.result ? "okay" : "failed" );
190
+ ol.appendChild( li );
191
+
192
+ if ( assertion.result ) {
193
+ good++;
194
+ } else {
195
+ bad++;
196
+ config.stats.bad++;
197
+ config.moduleStats.bad++;
198
+ }
199
+ }
200
+
201
+ // store result when possible
202
+ if ( QUnit.config.reorder && defined.sessionStorage ) {
203
+ if ( bad ) {
204
+ sessionStorage.setItem( "qunit-test-" + this.module + "-" + this.testName, bad );
205
+ } else {
206
+ sessionStorage.removeItem( "qunit-test-" + this.module + "-" + this.testName );
207
+ }
208
+ }
209
+
210
+ if ( bad === 0 ) {
211
+ ol.style.display = "none";
212
+ }
213
+
214
+ // `b` initialized at top of scope
215
+ b = document.createElement( "strong" );
216
+ b.innerHTML = this.name + " <b class='counts'>(<b class='failed'>" + bad + "</b>, <b class='passed'>" + good + "</b>, " + this.assertions.length + ")</b>";
217
+
218
+ addEvent(b, "click", function() {
219
+ var next = b.nextSibling.nextSibling,
220
+ display = next.style.display;
221
+ next.style.display = display === "none" ? "block" : "none";
222
+ });
223
+
224
+ addEvent(b, "dblclick", function( e ) {
225
+ var target = e && e.target ? e.target : window.event.srcElement;
226
+ if ( target.nodeName.toLowerCase() == "span" || target.nodeName.toLowerCase() == "b" ) {
227
+ target = target.parentNode;
228
+ }
229
+ if ( window.location && target.nodeName.toLowerCase() === "strong" ) {
230
+ window.location = QUnit.url({ testNumber: test.testNumber });
231
+ }
232
+ });
233
+
234
+ // `li` initialized at top of scope
235
+ li = id( this.id );
236
+ li.className = bad ? "fail" : "pass";
237
+ li.removeChild( li.firstChild );
238
+ a = li.firstChild;
239
+ li.appendChild( b );
240
+ li.appendChild ( a );
241
+ li.appendChild( ol );
242
+
243
+ } else {
244
+ for ( i = 0; i < this.assertions.length; i++ ) {
245
+ if ( !this.assertions[i].result ) {
246
+ bad++;
247
+ config.stats.bad++;
248
+ config.moduleStats.bad++;
249
+ }
250
+ }
251
+ }
252
+
253
+ runLoggingCallbacks( "testDone", QUnit, {
254
+ name: this.testName,
255
+ module: this.module,
256
+ failed: bad,
257
+ passed: this.assertions.length - bad,
258
+ total: this.assertions.length
259
+ });
260
+
261
+ QUnit.reset();
262
+
263
+ config.current = undefined;
264
+ },
265
+
266
+ queue: function() {
267
+ var bad,
268
+ test = this;
269
+
270
+ synchronize(function() {
271
+ test.init();
272
+ });
273
+ function run() {
274
+ // each of these can by async
275
+ synchronize(function() {
276
+ test.setup();
277
+ });
278
+ synchronize(function() {
279
+ test.run();
280
+ });
281
+ synchronize(function() {
282
+ test.teardown();
283
+ });
284
+ synchronize(function() {
285
+ test.finish();
286
+ });
287
+ }
288
+
289
+ // `bad` initialized at top of scope
290
+ // defer when previous test run passed, if storage is available
291
+ bad = QUnit.config.reorder && defined.sessionStorage &&
292
+ +sessionStorage.getItem( "qunit-test-" + this.module + "-" + this.testName );
293
+
294
+ if ( bad ) {
295
+ run();
296
+ } else {
297
+ synchronize( run, true );
298
+ }
299
+ }
300
+ };
301
+
302
+ // Root QUnit object.
303
+ // `QUnit` initialized at top of scope
304
+ QUnit = {
305
+
306
+ // call on start of module test to prepend name to all tests
307
+ module: function( name, testEnvironment ) {
308
+ config.currentModule = name;
309
+ config.currentModuleTestEnvironment = testEnvironment;
310
+ config.modules[name] = true;
311
+ },
312
+
313
+ asyncTest: function( testName, expected, callback ) {
314
+ if ( arguments.length === 2 ) {
315
+ callback = expected;
316
+ expected = null;
317
+ }
318
+
319
+ QUnit.test( testName, expected, callback, true );
320
+ },
321
+
322
+ test: function( testName, expected, callback, async ) {
323
+ var test,
324
+ name = "<span class='test-name'>" + escapeInnerText( testName ) + "</span>";
325
+
326
+ if ( arguments.length === 2 ) {
327
+ callback = expected;
328
+ expected = null;
329
+ }
330
+
331
+ if ( config.currentModule ) {
332
+ name = "<span class='module-name'>" + config.currentModule + "</span>: " + name;
333
+ }
334
+
335
+ test = new Test({
336
+ name: name,
337
+ testName: testName,
338
+ expected: expected,
339
+ async: async,
340
+ callback: callback,
341
+ module: config.currentModule,
342
+ moduleTestEnvironment: config.currentModuleTestEnvironment,
343
+ stack: sourceFromStacktrace( 2 )
344
+ });
345
+
346
+ if ( !validTest( test ) ) {
347
+ return;
348
+ }
349
+
350
+ test.queue();
351
+ },
352
+
353
+ // Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.
354
+ expect: function( asserts ) {
355
+ if (arguments.length === 1) {
356
+ config.current.expected = asserts;
357
+ } else {
358
+ return config.current.expected;
359
+ }
360
+ },
361
+
362
+ start: function( count ) {
363
+ config.semaphore -= count || 1;
364
+ // don't start until equal number of stop-calls
365
+ if ( config.semaphore > 0 ) {
366
+ return;
367
+ }
368
+ // ignore if start is called more often then stop
369
+ if ( config.semaphore < 0 ) {
370
+ config.semaphore = 0;
371
+ }
372
+ // A slight delay, to avoid any current callbacks
373
+ if ( defined.setTimeout ) {
374
+ window.setTimeout(function() {
375
+ if ( config.semaphore > 0 ) {
376
+ return;
377
+ }
378
+ if ( config.timeout ) {
379
+ clearTimeout( config.timeout );
380
+ }
381
+
382
+ config.blocking = false;
383
+ process( true );
384
+ }, 13);
385
+ } else {
386
+ config.blocking = false;
387
+ process( true );
388
+ }
389
+ },
390
+
391
+ stop: function( count ) {
392
+ config.semaphore += count || 1;
393
+ config.blocking = true;
394
+
395
+ if ( config.testTimeout && defined.setTimeout ) {
396
+ clearTimeout( config.timeout );
397
+ config.timeout = window.setTimeout(function() {
398
+ QUnit.ok( false, "Test timed out" );
399
+ config.semaphore = 1;
400
+ QUnit.start();
401
+ }, config.testTimeout );
402
+ }
403
+ }
404
+ };
405
+
406
+ // Asssert helpers
407
+ // All of these must call either QUnit.push() or manually do:
408
+ // - runLoggingCallbacks( "log", .. );
409
+ // - config.current.assertions.push({ .. });
410
+ QUnit.assert = {
411
+ /**
412
+ * Asserts rough true-ish result.
413
+ * @name ok
414
+ * @function
415
+ * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
416
+ */
417
+ ok: function( result, msg ) {
418
+ if ( !config.current ) {
419
+ throw new Error( "ok() assertion outside test context, was " + sourceFromStacktrace(2) );
420
+ }
421
+ result = !!result;
422
+
423
+ var source,
424
+ details = {
425
+ module: config.current.module,
426
+ name: config.current.testName,
427
+ result: result,
428
+ message: msg
429
+ };
430
+
431
+ msg = escapeInnerText( msg || (result ? "okay" : "failed" ) );
432
+ msg = "<span class='test-message'>" + msg + "</span>";
433
+
434
+ if ( !result ) {
435
+ source = sourceFromStacktrace( 2 );
436
+ if ( source ) {
437
+ details.source = source;
438
+ msg += "<table><tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source ) + "</pre></td></tr></table>";
439
+ }
440
+ }
441
+ runLoggingCallbacks( "log", QUnit, details );
442
+ config.current.assertions.push({
443
+ result: result,
444
+ message: msg
445
+ });
446
+ },
447
+
448
+ /**
449
+ * Assert that the first two arguments are equal, with an optional message.
450
+ * Prints out both actual and expected values.
451
+ * @name equal
452
+ * @function
453
+ * @example equal( format( "Received {0} bytes.", 2), "Received 2 bytes.", "format() replaces {0} with next argument" );
454
+ */
455
+ equal: function( actual, expected, message ) {
456
+ QUnit.push( expected == actual, actual, expected, message );
457
+ },
458
+
459
+ /**
460
+ * @name notEqual
461
+ * @function
462
+ */
463
+ notEqual: function( actual, expected, message ) {
464
+ QUnit.push( expected != actual, actual, expected, message );
465
+ },
466
+
467
+ /**
468
+ * @name deepEqual
469
+ * @function
470
+ */
471
+ deepEqual: function( actual, expected, message ) {
472
+ QUnit.push( QUnit.equiv(actual, expected), actual, expected, message );
473
+ },
474
+
475
+ /**
476
+ * @name notDeepEqual
477
+ * @function
478
+ */
479
+ notDeepEqual: function( actual, expected, message ) {
480
+ QUnit.push( !QUnit.equiv(actual, expected), actual, expected, message );
481
+ },
482
+
483
+ /**
484
+ * @name strictEqual
485
+ * @function
486
+ */
487
+ strictEqual: function( actual, expected, message ) {
488
+ QUnit.push( expected === actual, actual, expected, message );
489
+ },
490
+
491
+ /**
492
+ * @name notStrictEqual
493
+ * @function
494
+ */
495
+ notStrictEqual: function( actual, expected, message ) {
496
+ QUnit.push( expected !== actual, actual, expected, message );
497
+ },
498
+
499
+ throws: function( block, expected, message ) {
500
+ var actual,
501
+ ok = false;
502
+
503
+ // 'expected' is optional
504
+ if ( typeof expected === "string" ) {
505
+ message = expected;
506
+ expected = null;
507
+ }
508
+
509
+ config.current.ignoreGlobalErrors = true;
510
+ try {
511
+ block.call( config.current.testEnvironment );
512
+ } catch (e) {
513
+ actual = e;
514
+ }
515
+ config.current.ignoreGlobalErrors = false;
516
+
517
+ if ( actual ) {
518
+ // we don't want to validate thrown error
519
+ if ( !expected ) {
520
+ ok = true;
521
+ // expected is a regexp
522
+ } else if ( QUnit.objectType( expected ) === "regexp" ) {
523
+ ok = expected.test( actual );
524
+ // expected is a constructor
525
+ } else if ( actual instanceof expected ) {
526
+ ok = true;
527
+ // expected is a validation function which returns true is validation passed
528
+ } else if ( expected.call( {}, actual ) === true ) {
529
+ ok = true;
530
+ }
531
+
532
+ QUnit.push( ok, actual, null, message );
533
+ } else {
534
+ QUnit.pushFailure( message, null, 'No exception was thrown.' );
535
+ }
536
+ }
537
+ };
538
+
539
+ /**
540
+ * @deprecate since 1.8.0
541
+ * Kept assertion helpers in root for backwards compatibility
542
+ */
543
+ extend( QUnit, QUnit.assert );
544
+
545
+ /**
546
+ * @deprecated since 1.9.0
547
+ * Kept global "raises()" for backwards compatibility
548
+ */
549
+ QUnit.raises = QUnit.assert.throws;
550
+
551
+ /**
552
+ * @deprecated since 1.0.0, replaced with error pushes since 1.3.0
553
+ * Kept to avoid TypeErrors for undefined methods.
554
+ */
555
+ QUnit.equals = function() {
556
+ QUnit.push( false, false, false, "QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead" );
557
+ };
558
+ QUnit.same = function() {
559
+ QUnit.push( false, false, false, "QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead" );
560
+ };
561
+
562
+ // We want access to the constructor's prototype
563
+ (function() {
564
+ function F() {}
565
+ F.prototype = QUnit;
566
+ QUnit = new F();
567
+ // Make F QUnit's constructor so that we can add to the prototype later
568
+ QUnit.constructor = F;
569
+ }());
570
+
571
+ /**
572
+ * Config object: Maintain internal state
573
+ * Later exposed as QUnit.config
574
+ * `config` initialized at top of scope
575
+ */
576
+ config = {
577
+ // The queue of tests to run
578
+ queue: [],
579
+
580
+ // block until document ready
581
+ blocking: true,
582
+
583
+ // when enabled, show only failing tests
584
+ // gets persisted through sessionStorage and can be changed in UI via checkbox
585
+ hidepassed: false,
586
+
587
+ // by default, run previously failed tests first
588
+ // very useful in combination with "Hide passed tests" checked
589
+ reorder: true,
590
+
591
+ // by default, modify document.title when suite is done
592
+ altertitle: true,
593
+
594
+ // when enabled, all tests must call expect()
595
+ requireExpects: false,
596
+
597
+ // add checkboxes that are persisted in the query-string
598
+ // when enabled, the id is set to `true` as a `QUnit.config` property
599
+ urlConfig: [
600
+ {
601
+ id: "noglobals",
602
+ label: "Check for Globals",
603
+ tooltip: "Enabling this will test if any test introduces new properties on the `window` object. Stored as query-strings."
604
+ },
605
+ {
606
+ id: "notrycatch",
607
+ label: "No try-catch",
608
+ tooltip: "Enabling this will run tests outside of a try-catch block. Makes debugging exceptions in IE reasonable. Stored as query-strings."
609
+ }
610
+ ],
611
+
612
+ // Set of all modules.
613
+ modules: {},
614
+
615
+ // logging callback queues
616
+ begin: [],
617
+ done: [],
618
+ log: [],
619
+ testStart: [],
620
+ testDone: [],
621
+ moduleStart: [],
622
+ moduleDone: []
623
+ };
624
+
625
+ // Initialize more QUnit.config and QUnit.urlParams
626
+ (function() {
627
+ var i,
628
+ location = window.location || { search: "", protocol: "file:" },
629
+ params = location.search.slice( 1 ).split( "&" ),
630
+ length = params.length,
631
+ urlParams = {},
632
+ current;
633
+
634
+ if ( params[ 0 ] ) {
635
+ for ( i = 0; i < length; i++ ) {
636
+ current = params[ i ].split( "=" );
637
+ current[ 0 ] = decodeURIComponent( current[ 0 ] );
638
+ // allow just a key to turn on a flag, e.g., test.html?noglobals
639
+ current[ 1 ] = current[ 1 ] ? decodeURIComponent( current[ 1 ] ) : true;
640
+ urlParams[ current[ 0 ] ] = current[ 1 ];
641
+ }
642
+ }
643
+
644
+ QUnit.urlParams = urlParams;
645
+
646
+ // String search anywhere in moduleName+testName
647
+ config.filter = urlParams.filter;
648
+
649
+ // Exact match of the module name
650
+ config.module = urlParams.module;
651
+
652
+ config.testNumber = parseInt( urlParams.testNumber, 10 ) || null;
653
+
654
+ // Figure out if we're running the tests from a server or not
655
+ QUnit.isLocal = location.protocol === "file:";
656
+ }());
657
+
658
+ // Export global variables, unless an 'exports' object exists,
659
+ // in that case we assume we're in CommonJS (dealt with on the bottom of the script)
660
+ if ( typeof exports === "undefined" ) {
661
+ extend( window, QUnit );
662
+
663
+ // Expose QUnit object
664
+ window.QUnit = QUnit;
665
+ }
666
+
667
+ // Extend QUnit object,
668
+ // these after set here because they should not be exposed as global functions
669
+ extend( QUnit, {
670
+ config: config,
671
+
672
+ // Initialize the configuration options
673
+ init: function() {
674
+ extend( config, {
675
+ stats: { all: 0, bad: 0 },
676
+ moduleStats: { all: 0, bad: 0 },
677
+ started: +new Date(),
678
+ updateRate: 1000,
679
+ blocking: false,
680
+ autostart: true,
681
+ autorun: false,
682
+ filter: "",
683
+ queue: [],
684
+ semaphore: 0
685
+ });
686
+
687
+ var tests, banner, result,
688
+ qunit = id( "qunit" );
689
+
690
+ if ( qunit ) {
691
+ qunit.innerHTML =
692
+ "<h1 id='qunit-header'>" + escapeInnerText( document.title ) + "</h1>" +
693
+ "<h2 id='qunit-banner'></h2>" +
694
+ "<div id='qunit-testrunner-toolbar'></div>" +
695
+ "<h2 id='qunit-userAgent'></h2>" +
696
+ "<ol id='qunit-tests'></ol>";
697
+ }
698
+
699
+ tests = id( "qunit-tests" );
700
+ banner = id( "qunit-banner" );
701
+ result = id( "qunit-testresult" );
702
+
703
+ if ( tests ) {
704
+ tests.innerHTML = "";
705
+ }
706
+
707
+ if ( banner ) {
708
+ banner.className = "";
709
+ }
710
+
711
+ if ( result ) {
712
+ result.parentNode.removeChild( result );
713
+ }
714
+
715
+ if ( tests ) {
716
+ result = document.createElement( "p" );
717
+ result.id = "qunit-testresult";
718
+ result.className = "result";
719
+ tests.parentNode.insertBefore( result, tests );
720
+ result.innerHTML = "Running...<br/>&nbsp;";
721
+ }
722
+ },
723
+
724
+ // Resets the test setup. Useful for tests that modify the DOM.
725
+ reset: function() {
726
+ var fixture = id( "qunit-fixture" );
727
+ if ( fixture ) {
728
+ fixture.innerHTML = config.fixture;
729
+ }
730
+ },
731
+
732
+ // Trigger an event on an element.
733
+ // @example triggerEvent( document.body, "click" );
734
+ triggerEvent: function( elem, type, event ) {
735
+ if ( document.createEvent ) {
736
+ event = document.createEvent( "MouseEvents" );
737
+ event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
738
+ 0, 0, 0, 0, 0, false, false, false, false, 0, null);
739
+
740
+ elem.dispatchEvent( event );
741
+ } else if ( elem.fireEvent ) {
742
+ elem.fireEvent( "on" + type );
743
+ }
744
+ },
745
+
746
+ // Safe object type checking
747
+ is: function( type, obj ) {
748
+ return QUnit.objectType( obj ) == type;
749
+ },
750
+
751
+ objectType: function( obj ) {
752
+ if ( typeof obj === "undefined" ) {
753
+ return "undefined";
754
+ // consider: typeof null === object
755
+ }
756
+ if ( obj === null ) {
757
+ return "null";
758
+ }
759
+
760
+ var type = toString.call( obj ).match(/^\[object\s(.*)\]$/)[1] || "";
761
+
762
+ switch ( type ) {
763
+ case "Number":
764
+ if ( isNaN(obj) ) {
765
+ return "nan";
766
+ }
767
+ return "number";
768
+ case "String":
769
+ case "Boolean":
770
+ case "Array":
771
+ case "Date":
772
+ case "RegExp":
773
+ case "Function":
774
+ return type.toLowerCase();
775
+ }
776
+ if ( typeof obj === "object" ) {
777
+ return "object";
778
+ }
779
+ return undefined;
780
+ },
781
+
782
+ push: function( result, actual, expected, message ) {
783
+ if ( !config.current ) {
784
+ throw new Error( "assertion outside test context, was " + sourceFromStacktrace() );
785
+ }
786
+
787
+ var output, source,
788
+ details = {
789
+ module: config.current.module,
790
+ name: config.current.testName,
791
+ result: result,
792
+ message: message,
793
+ actual: actual,
794
+ expected: expected
795
+ };
796
+
797
+ message = escapeInnerText( message ) || ( result ? "okay" : "failed" );
798
+ message = "<span class='test-message'>" + message + "</span>";
799
+ output = message;
800
+
801
+ if ( !result ) {
802
+ expected = escapeInnerText( QUnit.jsDump.parse(expected) );
803
+ actual = escapeInnerText( QUnit.jsDump.parse(actual) );
804
+ output += "<table><tr class='test-expected'><th>Expected: </th><td><pre>" + expected + "</pre></td></tr>";
805
+
806
+ if ( actual != expected ) {
807
+ output += "<tr class='test-actual'><th>Result: </th><td><pre>" + actual + "</pre></td></tr>";
808
+ output += "<tr class='test-diff'><th>Diff: </th><td><pre>" + QUnit.diff( expected, actual ) + "</pre></td></tr>";
809
+ }
810
+
811
+ source = sourceFromStacktrace();
812
+
813
+ if ( source ) {
814
+ details.source = source;
815
+ output += "<tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source ) + "</pre></td></tr>";
816
+ }
817
+
818
+ output += "</table>";
819
+ }
820
+
821
+ runLoggingCallbacks( "log", QUnit, details );
822
+
823
+ config.current.assertions.push({
824
+ result: !!result,
825
+ message: output
826
+ });
827
+ },
828
+
829
+ pushFailure: function( message, source, actual ) {
830
+ if ( !config.current ) {
831
+ throw new Error( "pushFailure() assertion outside test context, was " + sourceFromStacktrace(2) );
832
+ }
833
+
834
+ var output,
835
+ details = {
836
+ module: config.current.module,
837
+ name: config.current.testName,
838
+ result: false,
839
+ message: message
840
+ };
841
+
842
+ message = escapeInnerText( message ) || "error";
843
+ message = "<span class='test-message'>" + message + "</span>";
844
+ output = message;
845
+
846
+ output += "<table>";
847
+
848
+ if ( actual ) {
849
+ output += "<tr class='test-actual'><th>Result: </th><td><pre>" + escapeInnerText( actual ) + "</pre></td></tr>";
850
+ }
851
+
852
+ if ( source ) {
853
+ details.source = source;
854
+ output += "<tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source ) + "</pre></td></tr>";
855
+ }
856
+
857
+ output += "</table>";
858
+
859
+ runLoggingCallbacks( "log", QUnit, details );
860
+
861
+ config.current.assertions.push({
862
+ result: false,
863
+ message: output
864
+ });
865
+ },
866
+
867
+ url: function( params ) {
868
+ params = extend( extend( {}, QUnit.urlParams ), params );
869
+ var key,
870
+ querystring = "?";
871
+
872
+ for ( key in params ) {
873
+ if ( !hasOwn.call( params, key ) ) {
874
+ continue;
875
+ }
876
+ querystring += encodeURIComponent( key ) + "=" +
877
+ encodeURIComponent( params[ key ] ) + "&";
878
+ }
879
+ return window.location.pathname + querystring.slice( 0, -1 );
880
+ },
881
+
882
+ extend: extend,
883
+ id: id,
884
+ addEvent: addEvent
885
+ // load, equiv, jsDump, diff: Attached later
886
+ });
887
+
888
+ /**
889
+ * @deprecated: Created for backwards compatibility with test runner that set the hook function
890
+ * into QUnit.{hook}, instead of invoking it and passing the hook function.
891
+ * QUnit.constructor is set to the empty F() above so that we can add to it's prototype here.
892
+ * Doing this allows us to tell if the following methods have been overwritten on the actual
893
+ * QUnit object.
894
+ */
895
+ extend( QUnit.constructor.prototype, {
896
+
897
+ // Logging callbacks; all receive a single argument with the listed properties
898
+ // run test/logs.html for any related changes
899
+ begin: registerLoggingCallback( "begin" ),
900
+
901
+ // done: { failed, passed, total, runtime }
902
+ done: registerLoggingCallback( "done" ),
903
+
904
+ // log: { result, actual, expected, message }
905
+ log: registerLoggingCallback( "log" ),
906
+
907
+ // testStart: { name }
908
+ testStart: registerLoggingCallback( "testStart" ),
909
+
910
+ // testDone: { name, failed, passed, total }
911
+ testDone: registerLoggingCallback( "testDone" ),
912
+
913
+ // moduleStart: { name }
914
+ moduleStart: registerLoggingCallback( "moduleStart" ),
915
+
916
+ // moduleDone: { name, failed, passed, total }
917
+ moduleDone: registerLoggingCallback( "moduleDone" )
918
+ });
919
+
920
+ if ( typeof document === "undefined" || document.readyState === "complete" ) {
921
+ config.autorun = true;
922
+ }
923
+
924
+ QUnit.load = function() {
925
+ runLoggingCallbacks( "begin", QUnit, {} );
926
+
927
+ // Initialize the config, saving the execution queue
928
+ var banner, filter, i, label, len, main, ol, toolbar, userAgent, val, urlConfigCheckboxes, moduleFilter,
929
+ numModules = 0,
930
+ moduleFilterHtml = "",
931
+ urlConfigHtml = "",
932
+ oldconfig = extend( {}, config );
933
+
934
+ QUnit.init();
935
+ extend(config, oldconfig);
936
+
937
+ config.blocking = false;
938
+
939
+ len = config.urlConfig.length;
940
+
941
+ for ( i = 0; i < len; i++ ) {
942
+ val = config.urlConfig[i];
943
+ if ( typeof val === "string" ) {
944
+ val = {
945
+ id: val,
946
+ label: val,
947
+ tooltip: "[no tooltip available]"
948
+ };
949
+ }
950
+ config[ val.id ] = QUnit.urlParams[ val.id ];
951
+ urlConfigHtml += "<input id='qunit-urlconfig-" + val.id + "' name='" + val.id + "' type='checkbox'" + ( config[ val.id ] ? " checked='checked'" : "" ) + " title='" + val.tooltip + "'><label for='qunit-urlconfig-" + val.id + "' title='" + val.tooltip + "'>" + val.label + "</label>";
952
+ }
953
+
954
+ moduleFilterHtml += "<label for='qunit-modulefilter'>Module: </label><select id='qunit-modulefilter' name='modulefilter'><option value='' " + ( config.module === undefined ? "selected" : "" ) + ">< All Modules ></option>";
955
+ for ( i in config.modules ) {
956
+ if ( config.modules.hasOwnProperty( i ) ) {
957
+ numModules += 1;
958
+ moduleFilterHtml += "<option value='" + encodeURIComponent(i) + "' " + ( config.module === i ? "selected" : "" ) + ">" + i + "</option>";
959
+ }
960
+ }
961
+ moduleFilterHtml += "</select>";
962
+
963
+ // `userAgent` initialized at top of scope
964
+ userAgent = id( "qunit-userAgent" );
965
+ if ( userAgent ) {
966
+ userAgent.innerHTML = navigator.userAgent;
967
+ }
968
+
969
+ // `banner` initialized at top of scope
970
+ banner = id( "qunit-header" );
971
+ if ( banner ) {
972
+ banner.innerHTML = "<a href='" + QUnit.url({ filter: undefined, module: undefined, testNumber: undefined }) + "'>" + banner.innerHTML + "</a> ";
973
+ }
974
+
975
+ // `toolbar` initialized at top of scope
976
+ toolbar = id( "qunit-testrunner-toolbar" );
977
+ if ( toolbar ) {
978
+ // `filter` initialized at top of scope
979
+ filter = document.createElement( "input" );
980
+ filter.type = "checkbox";
981
+ filter.id = "qunit-filter-pass";
982
+
983
+ addEvent( filter, "click", function() {
984
+ var tmp,
985
+ ol = document.getElementById( "qunit-tests" );
986
+
987
+ if ( filter.checked ) {
988
+ ol.className = ol.className + " hidepass";
989
+ } else {
990
+ tmp = " " + ol.className.replace( /[\n\t\r]/g, " " ) + " ";
991
+ ol.className = tmp.replace( / hidepass /, " " );
992
+ }
993
+ if ( defined.sessionStorage ) {
994
+ if (filter.checked) {
995
+ sessionStorage.setItem( "qunit-filter-passed-tests", "true" );
996
+ } else {
997
+ sessionStorage.removeItem( "qunit-filter-passed-tests" );
998
+ }
999
+ }
1000
+ });
1001
+
1002
+ if ( config.hidepassed || defined.sessionStorage && sessionStorage.getItem( "qunit-filter-passed-tests" ) ) {
1003
+ filter.checked = true;
1004
+ // `ol` initialized at top of scope
1005
+ ol = document.getElementById( "qunit-tests" );
1006
+ ol.className = ol.className + " hidepass";
1007
+ }
1008
+ toolbar.appendChild( filter );
1009
+
1010
+ // `label` initialized at top of scope
1011
+ label = document.createElement( "label" );
1012
+ label.setAttribute( "for", "qunit-filter-pass" );
1013
+ label.setAttribute( "title", "Only show tests and assertons that fail. Stored in sessionStorage." );
1014
+ label.innerHTML = "Hide passed tests";
1015
+ toolbar.appendChild( label );
1016
+
1017
+ urlConfigCheckboxes = document.createElement( 'span' );
1018
+ urlConfigCheckboxes.innerHTML = urlConfigHtml;
1019
+ addEvent( urlConfigCheckboxes, "change", function( event ) {
1020
+ var params = {};
1021
+ params[ event.target.name ] = event.target.checked ? true : undefined;
1022
+ window.location = QUnit.url( params );
1023
+ });
1024
+ toolbar.appendChild( urlConfigCheckboxes );
1025
+
1026
+ if (numModules > 1) {
1027
+ moduleFilter = document.createElement( 'span' );
1028
+ moduleFilter.setAttribute( 'id', 'qunit-modulefilter-container' );
1029
+ moduleFilter.innerHTML = moduleFilterHtml;
1030
+ addEvent( moduleFilter, "change", function() {
1031
+ var selectBox = moduleFilter.getElementsByTagName("select")[0],
1032
+ selectedModule = decodeURIComponent(selectBox.options[selectBox.selectedIndex].value);
1033
+
1034
+ window.location = QUnit.url( { module: ( selectedModule === "" ) ? undefined : selectedModule } );
1035
+ });
1036
+ toolbar.appendChild(moduleFilter);
1037
+ }
1038
+ }
1039
+
1040
+ // `main` initialized at top of scope
1041
+ main = id( "qunit-fixture" );
1042
+ if ( main ) {
1043
+ config.fixture = main.innerHTML;
1044
+ }
1045
+
1046
+ if ( config.autostart ) {
1047
+ QUnit.start();
1048
+ }
1049
+ };
1050
+
1051
+ addEvent( window, "load", QUnit.load );
1052
+
1053
+ // `onErrorFnPrev` initialized at top of scope
1054
+ // Preserve other handlers
1055
+ onErrorFnPrev = window.onerror;
1056
+
1057
+ // Cover uncaught exceptions
1058
+ // Returning true will surpress the default browser handler,
1059
+ // returning false will let it run.
1060
+ window.onerror = function ( error, filePath, linerNr ) {
1061
+ var ret = false;
1062
+ if ( onErrorFnPrev ) {
1063
+ ret = onErrorFnPrev( error, filePath, linerNr );
1064
+ }
1065
+
1066
+ // Treat return value as window.onerror itself does,
1067
+ // Only do our handling if not surpressed.
1068
+ if ( ret !== true ) {
1069
+ if ( QUnit.config.current ) {
1070
+ if ( QUnit.config.current.ignoreGlobalErrors ) {
1071
+ return true;
1072
+ }
1073
+ QUnit.pushFailure( error, filePath + ":" + linerNr );
1074
+ } else {
1075
+ QUnit.test( "global failure", extend( function() {
1076
+ QUnit.pushFailure( error, filePath + ":" + linerNr );
1077
+ }, { validTest: validTest } ) );
1078
+ }
1079
+ return false;
1080
+ }
1081
+
1082
+ return ret;
1083
+ };
1084
+
1085
+ function done() {
1086
+ config.autorun = true;
1087
+
1088
+ // Log the last module results
1089
+ if ( config.currentModule ) {
1090
+ runLoggingCallbacks( "moduleDone", QUnit, {
1091
+ name: config.currentModule,
1092
+ failed: config.moduleStats.bad,
1093
+ passed: config.moduleStats.all - config.moduleStats.bad,
1094
+ total: config.moduleStats.all
1095
+ });
1096
+ }
1097
+
1098
+ var i, key,
1099
+ banner = id( "qunit-banner" ),
1100
+ tests = id( "qunit-tests" ),
1101
+ runtime = +new Date() - config.started,
1102
+ passed = config.stats.all - config.stats.bad,
1103
+ html = [
1104
+ "Tests completed in ",
1105
+ runtime,
1106
+ " milliseconds.<br/>",
1107
+ "<span class='passed'>",
1108
+ passed,
1109
+ "</span> tests of <span class='total'>",
1110
+ config.stats.all,
1111
+ "</span> passed, <span class='failed'>",
1112
+ config.stats.bad,
1113
+ "</span> failed."
1114
+ ].join( "" );
1115
+
1116
+ if ( banner ) {
1117
+ banner.className = ( config.stats.bad ? "qunit-fail" : "qunit-pass" );
1118
+ }
1119
+
1120
+ if ( tests ) {
1121
+ id( "qunit-testresult" ).innerHTML = html;
1122
+ }
1123
+
1124
+ if ( config.altertitle && typeof document !== "undefined" && document.title ) {
1125
+ // show ✖ for good, ✔ for bad suite result in title
1126
+ // use escape sequences in case file gets loaded with non-utf-8-charset
1127
+ document.title = [
1128
+ ( config.stats.bad ? "\u2716" : "\u2714" ),
1129
+ document.title.replace( /^[\u2714\u2716] /i, "" )
1130
+ ].join( " " );
1131
+ }
1132
+
1133
+ // clear own sessionStorage items if all tests passed
1134
+ if ( config.reorder && defined.sessionStorage && config.stats.bad === 0 ) {
1135
+ // `key` & `i` initialized at top of scope
1136
+ for ( i = 0; i < sessionStorage.length; i++ ) {
1137
+ key = sessionStorage.key( i++ );
1138
+ if ( key.indexOf( "qunit-test-" ) === 0 ) {
1139
+ sessionStorage.removeItem( key );
1140
+ }
1141
+ }
1142
+ }
1143
+
1144
+ // scroll back to top to show results
1145
+ if ( window.scrollTo ) {
1146
+ window.scrollTo(0, 0);
1147
+ }
1148
+
1149
+ runLoggingCallbacks( "done", QUnit, {
1150
+ failed: config.stats.bad,
1151
+ passed: passed,
1152
+ total: config.stats.all,
1153
+ runtime: runtime
1154
+ });
1155
+ }
1156
+
1157
+ /** @return Boolean: true if this test should be ran */
1158
+ function validTest( test ) {
1159
+ var include,
1160
+ filter = config.filter && config.filter.toLowerCase(),
1161
+ module = config.module && config.module.toLowerCase(),
1162
+ fullName = (test.module + ": " + test.testName).toLowerCase();
1163
+
1164
+ // Internally-generated tests are always valid
1165
+ if ( test.callback && test.callback.validTest === validTest ) {
1166
+ delete test.callback.validTest;
1167
+ return true;
1168
+ }
1169
+
1170
+ if ( config.testNumber ) {
1171
+ return test.testNumber === config.testNumber;
1172
+ }
1173
+
1174
+ if ( module && ( !test.module || test.module.toLowerCase() !== module ) ) {
1175
+ return false;
1176
+ }
1177
+
1178
+ if ( !filter ) {
1179
+ return true;
1180
+ }
1181
+
1182
+ include = filter.charAt( 0 ) !== "!";
1183
+ if ( !include ) {
1184
+ filter = filter.slice( 1 );
1185
+ }
1186
+
1187
+ // If the filter matches, we need to honour include
1188
+ if ( fullName.indexOf( filter ) !== -1 ) {
1189
+ return include;
1190
+ }
1191
+
1192
+ // Otherwise, do the opposite
1193
+ return !include;
1194
+ }
1195
+
1196
+ // so far supports only Firefox, Chrome and Opera (buggy), Safari (for real exceptions)
1197
+ // Later Safari and IE10 are supposed to support error.stack as well
1198
+ // See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error/Stack
1199
+ function extractStacktrace( e, offset ) {
1200
+ offset = offset === undefined ? 3 : offset;
1201
+
1202
+ var stack, include, i, regex;
1203
+
1204
+ if ( e.stacktrace ) {
1205
+ // Opera
1206
+ return e.stacktrace.split( "\n" )[ offset + 3 ];
1207
+ } else if ( e.stack ) {
1208
+ // Firefox, Chrome
1209
+ stack = e.stack.split( "\n" );
1210
+ if (/^error$/i.test( stack[0] ) ) {
1211
+ stack.shift();
1212
+ }
1213
+ if ( fileName ) {
1214
+ include = [];
1215
+ for ( i = offset; i < stack.length; i++ ) {
1216
+ if ( stack[ i ].indexOf( fileName ) != -1 ) {
1217
+ break;
1218
+ }
1219
+ include.push( stack[ i ] );
1220
+ }
1221
+ if ( include.length ) {
1222
+ return include.join( "\n" );
1223
+ }
1224
+ }
1225
+ return stack[ offset ];
1226
+ } else if ( e.sourceURL ) {
1227
+ // Safari, PhantomJS
1228
+ // hopefully one day Safari provides actual stacktraces
1229
+ // exclude useless self-reference for generated Error objects
1230
+ if ( /qunit.js$/.test( e.sourceURL ) ) {
1231
+ return;
1232
+ }
1233
+ // for actual exceptions, this is useful
1234
+ return e.sourceURL + ":" + e.line;
1235
+ }
1236
+ }
1237
+ function sourceFromStacktrace( offset ) {
1238
+ try {
1239
+ throw new Error();
1240
+ } catch ( e ) {
1241
+ return extractStacktrace( e, offset );
1242
+ }
1243
+ }
1244
+
1245
+ function escapeInnerText( s ) {
1246
+ if ( !s ) {
1247
+ return "";
1248
+ }
1249
+ s = s + "";
1250
+ return s.replace( /[\&<>]/g, function( s ) {
1251
+ switch( s ) {
1252
+ case "&": return "&amp;";
1253
+ case "<": return "&lt;";
1254
+ case ">": return "&gt;";
1255
+ default: return s;
1256
+ }
1257
+ });
1258
+ }
1259
+
1260
+ function synchronize( callback, last ) {
1261
+ config.queue.push( callback );
1262
+
1263
+ if ( config.autorun && !config.blocking ) {
1264
+ process( last );
1265
+ }
1266
+ }
1267
+
1268
+ function process( last ) {
1269
+ function next() {
1270
+ process( last );
1271
+ }
1272
+ var start = new Date().getTime();
1273
+ config.depth = config.depth ? config.depth + 1 : 1;
1274
+
1275
+ while ( config.queue.length && !config.blocking ) {
1276
+ if ( !defined.setTimeout || config.updateRate <= 0 || ( ( new Date().getTime() - start ) < config.updateRate ) ) {
1277
+ config.queue.shift()();
1278
+ } else {
1279
+ window.setTimeout( next, 13 );
1280
+ break;
1281
+ }
1282
+ }
1283
+ config.depth--;
1284
+ if ( last && !config.blocking && !config.queue.length && config.depth === 0 ) {
1285
+ done();
1286
+ }
1287
+ }
1288
+
1289
+ function saveGlobal() {
1290
+ config.pollution = [];
1291
+
1292
+ if ( config.noglobals ) {
1293
+ for ( var key in window ) {
1294
+ // in Opera sometimes DOM element ids show up here, ignore them
1295
+ if ( !hasOwn.call( window, key ) || /^qunit-test-output/.test( key ) ) {
1296
+ continue;
1297
+ }
1298
+ config.pollution.push( key );
1299
+ }
1300
+ }
1301
+ }
1302
+
1303
+ function checkPollution( name ) {
1304
+ var newGlobals,
1305
+ deletedGlobals,
1306
+ old = config.pollution;
1307
+
1308
+ saveGlobal();
1309
+
1310
+ newGlobals = diff( config.pollution, old );
1311
+ if ( newGlobals.length > 0 ) {
1312
+ QUnit.pushFailure( "Introduced global variable(s): " + newGlobals.join(", ") );
1313
+ }
1314
+
1315
+ deletedGlobals = diff( old, config.pollution );
1316
+ if ( deletedGlobals.length > 0 ) {
1317
+ QUnit.pushFailure( "Deleted global variable(s): " + deletedGlobals.join(", ") );
1318
+ }
1319
+ }
1320
+
1321
+ // returns a new Array with the elements that are in a but not in b
1322
+ function diff( a, b ) {
1323
+ var i, j,
1324
+ result = a.slice();
1325
+
1326
+ for ( i = 0; i < result.length; i++ ) {
1327
+ for ( j = 0; j < b.length; j++ ) {
1328
+ if ( result[i] === b[j] ) {
1329
+ result.splice( i, 1 );
1330
+ i--;
1331
+ break;
1332
+ }
1333
+ }
1334
+ }
1335
+ return result;
1336
+ }
1337
+
1338
+ function extend( a, b ) {
1339
+ for ( var prop in b ) {
1340
+ if ( b[ prop ] === undefined ) {
1341
+ delete a[ prop ];
1342
+
1343
+ // Avoid "Member not found" error in IE8 caused by setting window.constructor
1344
+ } else if ( prop !== "constructor" || a !== window ) {
1345
+ a[ prop ] = b[ prop ];
1346
+ }
1347
+ }
1348
+
1349
+ return a;
1350
+ }
1351
+
1352
+ function addEvent( elem, type, fn ) {
1353
+ if ( elem.addEventListener ) {
1354
+ elem.addEventListener( type, fn, false );
1355
+ } else if ( elem.attachEvent ) {
1356
+ elem.attachEvent( "on" + type, fn );
1357
+ } else {
1358
+ fn();
1359
+ }
1360
+ }
1361
+
1362
+ function id( name ) {
1363
+ return !!( typeof document !== "undefined" && document && document.getElementById ) &&
1364
+ document.getElementById( name );
1365
+ }
1366
+
1367
+ function registerLoggingCallback( key ) {
1368
+ return function( callback ) {
1369
+ config[key].push( callback );
1370
+ };
1371
+ }
1372
+
1373
+ // Supports deprecated method of completely overwriting logging callbacks
1374
+ function runLoggingCallbacks( key, scope, args ) {
1375
+ //debugger;
1376
+ var i, callbacks;
1377
+ if ( QUnit.hasOwnProperty( key ) ) {
1378
+ QUnit[ key ].call(scope, args );
1379
+ } else {
1380
+ callbacks = config[ key ];
1381
+ for ( i = 0; i < callbacks.length; i++ ) {
1382
+ callbacks[ i ].call( scope, args );
1383
+ }
1384
+ }
1385
+ }
1386
+
1387
+ // Test for equality any JavaScript type.
1388
+ // Author: Philippe Rathé <prathe@gmail.com>
1389
+ QUnit.equiv = (function() {
1390
+
1391
+ // Call the o related callback with the given arguments.
1392
+ function bindCallbacks( o, callbacks, args ) {
1393
+ var prop = QUnit.objectType( o );
1394
+ if ( prop ) {
1395
+ if ( QUnit.objectType( callbacks[ prop ] ) === "function" ) {
1396
+ return callbacks[ prop ].apply( callbacks, args );
1397
+ } else {
1398
+ return callbacks[ prop ]; // or undefined
1399
+ }
1400
+ }
1401
+ }
1402
+
1403
+ // the real equiv function
1404
+ var innerEquiv,
1405
+ // stack to decide between skip/abort functions
1406
+ callers = [],
1407
+ // stack to avoiding loops from circular referencing
1408
+ parents = [],
1409
+
1410
+ getProto = Object.getPrototypeOf || function ( obj ) {
1411
+ return obj.__proto__;
1412
+ },
1413
+ callbacks = (function () {
1414
+
1415
+ // for string, boolean, number and null
1416
+ function useStrictEquality( b, a ) {
1417
+ if ( b instanceof a.constructor || a instanceof b.constructor ) {
1418
+ // to catch short annotaion VS 'new' annotation of a
1419
+ // declaration
1420
+ // e.g. var i = 1;
1421
+ // var j = new Number(1);
1422
+ return a == b;
1423
+ } else {
1424
+ return a === b;
1425
+ }
1426
+ }
1427
+
1428
+ return {
1429
+ "string": useStrictEquality,
1430
+ "boolean": useStrictEquality,
1431
+ "number": useStrictEquality,
1432
+ "null": useStrictEquality,
1433
+ "undefined": useStrictEquality,
1434
+
1435
+ "nan": function( b ) {
1436
+ return isNaN( b );
1437
+ },
1438
+
1439
+ "date": function( b, a ) {
1440
+ return QUnit.objectType( b ) === "date" && a.valueOf() === b.valueOf();
1441
+ },
1442
+
1443
+ "regexp": function( b, a ) {
1444
+ return QUnit.objectType( b ) === "regexp" &&
1445
+ // the regex itself
1446
+ a.source === b.source &&
1447
+ // and its modifers
1448
+ a.global === b.global &&
1449
+ // (gmi) ...
1450
+ a.ignoreCase === b.ignoreCase &&
1451
+ a.multiline === b.multiline &&
1452
+ a.sticky === b.sticky;
1453
+ },
1454
+
1455
+ // - skip when the property is a method of an instance (OOP)
1456
+ // - abort otherwise,
1457
+ // initial === would have catch identical references anyway
1458
+ "function": function() {
1459
+ var caller = callers[callers.length - 1];
1460
+ return caller !== Object && typeof caller !== "undefined";
1461
+ },
1462
+
1463
+ "array": function( b, a ) {
1464
+ var i, j, len, loop;
1465
+
1466
+ // b could be an object literal here
1467
+ if ( QUnit.objectType( b ) !== "array" ) {
1468
+ return false;
1469
+ }
1470
+
1471
+ len = a.length;
1472
+ if ( len !== b.length ) {
1473
+ // safe and faster
1474
+ return false;
1475
+ }
1476
+
1477
+ // track reference to avoid circular references
1478
+ parents.push( a );
1479
+ for ( i = 0; i < len; i++ ) {
1480
+ loop = false;
1481
+ for ( j = 0; j < parents.length; j++ ) {
1482
+ if ( parents[j] === a[i] ) {
1483
+ loop = true;// dont rewalk array
1484
+ }
1485
+ }
1486
+ if ( !loop && !innerEquiv(a[i], b[i]) ) {
1487
+ parents.pop();
1488
+ return false;
1489
+ }
1490
+ }
1491
+ parents.pop();
1492
+ return true;
1493
+ },
1494
+
1495
+ "object": function( b, a ) {
1496
+ var i, j, loop,
1497
+ // Default to true
1498
+ eq = true,
1499
+ aProperties = [],
1500
+ bProperties = [];
1501
+
1502
+ // comparing constructors is more strict than using
1503
+ // instanceof
1504
+ if ( a.constructor !== b.constructor ) {
1505
+ // Allow objects with no prototype to be equivalent to
1506
+ // objects with Object as their constructor.
1507
+ if ( !(( getProto(a) === null && getProto(b) === Object.prototype ) ||
1508
+ ( getProto(b) === null && getProto(a) === Object.prototype ) ) ) {
1509
+ return false;
1510
+ }
1511
+ }
1512
+
1513
+ // stack constructor before traversing properties
1514
+ callers.push( a.constructor );
1515
+ // track reference to avoid circular references
1516
+ parents.push( a );
1517
+
1518
+ for ( i in a ) { // be strict: don't ensures hasOwnProperty
1519
+ // and go deep
1520
+ loop = false;
1521
+ for ( j = 0; j < parents.length; j++ ) {
1522
+ if ( parents[j] === a[i] ) {
1523
+ // don't go down the same path twice
1524
+ loop = true;
1525
+ }
1526
+ }
1527
+ aProperties.push(i); // collect a's properties
1528
+
1529
+ if (!loop && !innerEquiv( a[i], b[i] ) ) {
1530
+ eq = false;
1531
+ break;
1532
+ }
1533
+ }
1534
+
1535
+ callers.pop(); // unstack, we are done
1536
+ parents.pop();
1537
+
1538
+ for ( i in b ) {
1539
+ bProperties.push( i ); // collect b's properties
1540
+ }
1541
+
1542
+ // Ensures identical properties name
1543
+ return eq && innerEquiv( aProperties.sort(), bProperties.sort() );
1544
+ }
1545
+ };
1546
+ }());
1547
+
1548
+ innerEquiv = function() { // can take multiple arguments
1549
+ var args = [].slice.apply( arguments );
1550
+ if ( args.length < 2 ) {
1551
+ return true; // end transition
1552
+ }
1553
+
1554
+ return (function( a, b ) {
1555
+ if ( a === b ) {
1556
+ return true; // catch the most you can
1557
+ } else if ( a === null || b === null || typeof a === "undefined" ||
1558
+ typeof b === "undefined" ||
1559
+ QUnit.objectType(a) !== QUnit.objectType(b) ) {
1560
+ return false; // don't lose time with error prone cases
1561
+ } else {
1562
+ return bindCallbacks(a, callbacks, [ b, a ]);
1563
+ }
1564
+
1565
+ // apply transition with (1..n) arguments
1566
+ }( args[0], args[1] ) && arguments.callee.apply( this, args.splice(1, args.length - 1 )) );
1567
+ };
1568
+
1569
+ return innerEquiv;
1570
+ }());
1571
+
1572
+ /**
1573
+ * jsDump Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com |
1574
+ * http://flesler.blogspot.com Licensed under BSD
1575
+ * (http://www.opensource.org/licenses/bsd-license.php) Date: 5/15/2008
1576
+ *
1577
+ * @projectDescription Advanced and extensible data dumping for Javascript.
1578
+ * @version 1.0.0
1579
+ * @author Ariel Flesler
1580
+ * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html}
1581
+ */
1582
+ QUnit.jsDump = (function() {
1583
+ function quote( str ) {
1584
+ return '"' + str.toString().replace( /"/g, '\\"' ) + '"';
1585
+ }
1586
+ function literal( o ) {
1587
+ return o + "";
1588
+ }
1589
+ function join( pre, arr, post ) {
1590
+ var s = jsDump.separator(),
1591
+ base = jsDump.indent(),
1592
+ inner = jsDump.indent(1);
1593
+ if ( arr.join ) {
1594
+ arr = arr.join( "," + s + inner );
1595
+ }
1596
+ if ( !arr ) {
1597
+ return pre + post;
1598
+ }
1599
+ return [ pre, inner + arr, base + post ].join(s);
1600
+ }
1601
+ function array( arr, stack ) {
1602
+ var i = arr.length, ret = new Array(i);
1603
+ this.up();
1604
+ while ( i-- ) {
1605
+ ret[i] = this.parse( arr[i] , undefined , stack);
1606
+ }
1607
+ this.down();
1608
+ return join( "[", ret, "]" );
1609
+ }
1610
+
1611
+ var reName = /^function (\w+)/,
1612
+ jsDump = {
1613
+ parse: function( obj, type, stack ) { //type is used mostly internally, you can fix a (custom)type in advance
1614
+ stack = stack || [ ];
1615
+ var inStack, res,
1616
+ parser = this.parsers[ type || this.typeOf(obj) ];
1617
+
1618
+ type = typeof parser;
1619
+ inStack = inArray( obj, stack );
1620
+
1621
+ if ( inStack != -1 ) {
1622
+ return "recursion(" + (inStack - stack.length) + ")";
1623
+ }
1624
+ //else
1625
+ if ( type == "function" ) {
1626
+ stack.push( obj );
1627
+ res = parser.call( this, obj, stack );
1628
+ stack.pop();
1629
+ return res;
1630
+ }
1631
+ // else
1632
+ return ( type == "string" ) ? parser : this.parsers.error;
1633
+ },
1634
+ typeOf: function( obj ) {
1635
+ var type;
1636
+ if ( obj === null ) {
1637
+ type = "null";
1638
+ } else if ( typeof obj === "undefined" ) {
1639
+ type = "undefined";
1640
+ } else if ( QUnit.is( "regexp", obj) ) {
1641
+ type = "regexp";
1642
+ } else if ( QUnit.is( "date", obj) ) {
1643
+ type = "date";
1644
+ } else if ( QUnit.is( "function", obj) ) {
1645
+ type = "function";
1646
+ } else if ( typeof obj.setInterval !== undefined && typeof obj.document !== "undefined" && typeof obj.nodeType === "undefined" ) {
1647
+ type = "window";
1648
+ } else if ( obj.nodeType === 9 ) {
1649
+ type = "document";
1650
+ } else if ( obj.nodeType ) {
1651
+ type = "node";
1652
+ } else if (
1653
+ // native arrays
1654
+ toString.call( obj ) === "[object Array]" ||
1655
+ // NodeList objects
1656
+ ( typeof obj.length === "number" && typeof obj.item !== "undefined" && ( obj.length ? obj.item(0) === obj[0] : ( obj.item( 0 ) === null && typeof obj[0] === "undefined" ) ) )
1657
+ ) {
1658
+ type = "array";
1659
+ } else {
1660
+ type = typeof obj;
1661
+ }
1662
+ return type;
1663
+ },
1664
+ separator: function() {
1665
+ return this.multiline ? this.HTML ? "<br />" : "\n" : this.HTML ? "&nbsp;" : " ";
1666
+ },
1667
+ indent: function( extra ) {// extra can be a number, shortcut for increasing-calling-decreasing
1668
+ if ( !this.multiline ) {
1669
+ return "";
1670
+ }
1671
+ var chr = this.indentChar;
1672
+ if ( this.HTML ) {
1673
+ chr = chr.replace( /\t/g, " " ).replace( / /g, "&nbsp;" );
1674
+ }
1675
+ return new Array( this._depth_ + (extra||0) ).join(chr);
1676
+ },
1677
+ up: function( a ) {
1678
+ this._depth_ += a || 1;
1679
+ },
1680
+ down: function( a ) {
1681
+ this._depth_ -= a || 1;
1682
+ },
1683
+ setParser: function( name, parser ) {
1684
+ this.parsers[name] = parser;
1685
+ },
1686
+ // The next 3 are exposed so you can use them
1687
+ quote: quote,
1688
+ literal: literal,
1689
+ join: join,
1690
+ //
1691
+ _depth_: 1,
1692
+ // This is the list of parsers, to modify them, use jsDump.setParser
1693
+ parsers: {
1694
+ window: "[Window]",
1695
+ document: "[Document]",
1696
+ error: "[ERROR]", //when no parser is found, shouldn"t happen
1697
+ unknown: "[Unknown]",
1698
+ "null": "null",
1699
+ "undefined": "undefined",
1700
+ "function": function( fn ) {
1701
+ var ret = "function",
1702
+ name = "name" in fn ? fn.name : (reName.exec(fn) || [])[1];//functions never have name in IE
1703
+
1704
+ if ( name ) {
1705
+ ret += " " + name;
1706
+ }
1707
+ ret += "( ";
1708
+
1709
+ ret = [ ret, QUnit.jsDump.parse( fn, "functionArgs" ), "){" ].join( "" );
1710
+ return join( ret, QUnit.jsDump.parse(fn,"functionCode" ), "}" );
1711
+ },
1712
+ array: array,
1713
+ nodelist: array,
1714
+ "arguments": array,
1715
+ object: function( map, stack ) {
1716
+ var ret = [ ], keys, key, val, i;
1717
+ QUnit.jsDump.up();
1718
+ if ( Object.keys ) {
1719
+ keys = Object.keys( map );
1720
+ } else {
1721
+ keys = [];
1722
+ for ( key in map ) {
1723
+ keys.push( key );
1724
+ }
1725
+ }
1726
+ keys.sort();
1727
+ for ( i = 0; i < keys.length; i++ ) {
1728
+ key = keys[ i ];
1729
+ val = map[ key ];
1730
+ ret.push( QUnit.jsDump.parse( key, "key" ) + ": " + QUnit.jsDump.parse( val, undefined, stack ) );
1731
+ }
1732
+ QUnit.jsDump.down();
1733
+ return join( "{", ret, "}" );
1734
+ },
1735
+ node: function( node ) {
1736
+ var a, val,
1737
+ open = QUnit.jsDump.HTML ? "&lt;" : "<",
1738
+ close = QUnit.jsDump.HTML ? "&gt;" : ">",
1739
+ tag = node.nodeName.toLowerCase(),
1740
+ ret = open + tag;
1741
+
1742
+ for ( a in QUnit.jsDump.DOMAttrs ) {
1743
+ val = node[ QUnit.jsDump.DOMAttrs[a] ];
1744
+ if ( val ) {
1745
+ ret += " " + a + "=" + QUnit.jsDump.parse( val, "attribute" );
1746
+ }
1747
+ }
1748
+ return ret + close + open + "/" + tag + close;
1749
+ },
1750
+ functionArgs: function( fn ) {//function calls it internally, it's the arguments part of the function
1751
+ var args,
1752
+ l = fn.length;
1753
+
1754
+ if ( !l ) {
1755
+ return "";
1756
+ }
1757
+
1758
+ args = new Array(l);
1759
+ while ( l-- ) {
1760
+ args[l] = String.fromCharCode(97+l);//97 is 'a'
1761
+ }
1762
+ return " " + args.join( ", " ) + " ";
1763
+ },
1764
+ key: quote, //object calls it internally, the key part of an item in a map
1765
+ functionCode: "[code]", //function calls it internally, it's the content of the function
1766
+ attribute: quote, //node calls it internally, it's an html attribute value
1767
+ string: quote,
1768
+ date: quote,
1769
+ regexp: literal, //regex
1770
+ number: literal,
1771
+ "boolean": literal
1772
+ },
1773
+ DOMAttrs: {
1774
+ //attributes to dump from nodes, name=>realName
1775
+ id: "id",
1776
+ name: "name",
1777
+ "class": "className"
1778
+ },
1779
+ HTML: false,//if true, entities are escaped ( <, >, \t, space and \n )
1780
+ indentChar: " ",//indentation unit
1781
+ multiline: true //if true, items in a collection, are separated by a \n, else just a space.
1782
+ };
1783
+
1784
+ return jsDump;
1785
+ }());
1786
+
1787
+ // from Sizzle.js
1788
+ function getText( elems ) {
1789
+ var i, elem,
1790
+ ret = "";
1791
+
1792
+ for ( i = 0; elems[i]; i++ ) {
1793
+ elem = elems[i];
1794
+
1795
+ // Get the text from text nodes and CDATA nodes
1796
+ if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
1797
+ ret += elem.nodeValue;
1798
+
1799
+ // Traverse everything else, except comment nodes
1800
+ } else if ( elem.nodeType !== 8 ) {
1801
+ ret += getText( elem.childNodes );
1802
+ }
1803
+ }
1804
+
1805
+ return ret;
1806
+ }
1807
+
1808
+ // from jquery.js
1809
+ function inArray( elem, array ) {
1810
+ if ( array.indexOf ) {
1811
+ return array.indexOf( elem );
1812
+ }
1813
+
1814
+ for ( var i = 0, length = array.length; i < length; i++ ) {
1815
+ if ( array[ i ] === elem ) {
1816
+ return i;
1817
+ }
1818
+ }
1819
+
1820
+ return -1;
1821
+ }
1822
+
1823
+ /*
1824
+ * Javascript Diff Algorithm
1825
+ * By John Resig (http://ejohn.org/)
1826
+ * Modified by Chu Alan "sprite"
1827
+ *
1828
+ * Released under the MIT license.
1829
+ *
1830
+ * More Info:
1831
+ * http://ejohn.org/projects/javascript-diff-algorithm/
1832
+ *
1833
+ * Usage: QUnit.diff(expected, actual)
1834
+ *
1835
+ * QUnit.diff( "the quick brown fox jumped over", "the quick fox jumps over" ) == "the quick <del>brown </del> fox <del>jumped </del><ins>jumps </ins> over"
1836
+ */
1837
+ QUnit.diff = (function() {
1838
+ function diff( o, n ) {
1839
+ var i,
1840
+ ns = {},
1841
+ os = {};
1842
+
1843
+ for ( i = 0; i < n.length; i++ ) {
1844
+ if ( ns[ n[i] ] == null ) {
1845
+ ns[ n[i] ] = {
1846
+ rows: [],
1847
+ o: null
1848
+ };
1849
+ }
1850
+ ns[ n[i] ].rows.push( i );
1851
+ }
1852
+
1853
+ for ( i = 0; i < o.length; i++ ) {
1854
+ if ( os[ o[i] ] == null ) {
1855
+ os[ o[i] ] = {
1856
+ rows: [],
1857
+ n: null
1858
+ };
1859
+ }
1860
+ os[ o[i] ].rows.push( i );
1861
+ }
1862
+
1863
+ for ( i in ns ) {
1864
+ if ( !hasOwn.call( ns, i ) ) {
1865
+ continue;
1866
+ }
1867
+ if ( ns[i].rows.length == 1 && typeof os[i] != "undefined" && os[i].rows.length == 1 ) {
1868
+ n[ ns[i].rows[0] ] = {
1869
+ text: n[ ns[i].rows[0] ],
1870
+ row: os[i].rows[0]
1871
+ };
1872
+ o[ os[i].rows[0] ] = {
1873
+ text: o[ os[i].rows[0] ],
1874
+ row: ns[i].rows[0]
1875
+ };
1876
+ }
1877
+ }
1878
+
1879
+ for ( i = 0; i < n.length - 1; i++ ) {
1880
+ if ( n[i].text != null && n[ i + 1 ].text == null && n[i].row + 1 < o.length && o[ n[i].row + 1 ].text == null &&
1881
+ n[ i + 1 ] == o[ n[i].row + 1 ] ) {
1882
+
1883
+ n[ i + 1 ] = {
1884
+ text: n[ i + 1 ],
1885
+ row: n[i].row + 1
1886
+ };
1887
+ o[ n[i].row + 1 ] = {
1888
+ text: o[ n[i].row + 1 ],
1889
+ row: i + 1
1890
+ };
1891
+ }
1892
+ }
1893
+
1894
+ for ( i = n.length - 1; i > 0; i-- ) {
1895
+ if ( n[i].text != null && n[ i - 1 ].text == null && n[i].row > 0 && o[ n[i].row - 1 ].text == null &&
1896
+ n[ i - 1 ] == o[ n[i].row - 1 ]) {
1897
+
1898
+ n[ i - 1 ] = {
1899
+ text: n[ i - 1 ],
1900
+ row: n[i].row - 1
1901
+ };
1902
+ o[ n[i].row - 1 ] = {
1903
+ text: o[ n[i].row - 1 ],
1904
+ row: i - 1
1905
+ };
1906
+ }
1907
+ }
1908
+
1909
+ return {
1910
+ o: o,
1911
+ n: n
1912
+ };
1913
+ }
1914
+
1915
+ return function( o, n ) {
1916
+ o = o.replace( /\s+$/, "" );
1917
+ n = n.replace( /\s+$/, "" );
1918
+
1919
+ var i, pre,
1920
+ str = "",
1921
+ out = diff( o === "" ? [] : o.split(/\s+/), n === "" ? [] : n.split(/\s+/) ),
1922
+ oSpace = o.match(/\s+/g),
1923
+ nSpace = n.match(/\s+/g);
1924
+
1925
+ if ( oSpace == null ) {
1926
+ oSpace = [ " " ];
1927
+ }
1928
+ else {
1929
+ oSpace.push( " " );
1930
+ }
1931
+
1932
+ if ( nSpace == null ) {
1933
+ nSpace = [ " " ];
1934
+ }
1935
+ else {
1936
+ nSpace.push( " " );
1937
+ }
1938
+
1939
+ if ( out.n.length === 0 ) {
1940
+ for ( i = 0; i < out.o.length; i++ ) {
1941
+ str += "<del>" + out.o[i] + oSpace[i] + "</del>";
1942
+ }
1943
+ }
1944
+ else {
1945
+ if ( out.n[0].text == null ) {
1946
+ for ( n = 0; n < out.o.length && out.o[n].text == null; n++ ) {
1947
+ str += "<del>" + out.o[n] + oSpace[n] + "</del>";
1948
+ }
1949
+ }
1950
+
1951
+ for ( i = 0; i < out.n.length; i++ ) {
1952
+ if (out.n[i].text == null) {
1953
+ str += "<ins>" + out.n[i] + nSpace[i] + "</ins>";
1954
+ }
1955
+ else {
1956
+ // `pre` initialized at top of scope
1957
+ pre = "";
1958
+
1959
+ for ( n = out.n[i].row + 1; n < out.o.length && out.o[n].text == null; n++ ) {
1960
+ pre += "<del>" + out.o[n] + oSpace[n] + "</del>";
1961
+ }
1962
+ str += " " + out.n[i].text + nSpace[i] + pre;
1963
+ }
1964
+ }
1965
+ }
1966
+
1967
+ return str;
1968
+ };
1969
+ }());
1970
+
1971
+ // for CommonJS enviroments, export everything
1972
+ if ( typeof exports !== "undefined" ) {
1973
+ extend(exports, QUnit);
1974
+ }
1975
+
1976
+ // get at whatever the global object is, like window in browsers
1977
+ }( (function() {return this;}.call()) ));