jasmine-jquery.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. /*!
  2. Jasmine-jQuery: a set of jQuery helpers for Jasmine tests.
  3. Version 1.5.8
  4. https://github.com/velesin/jasmine-jquery
  5. Copyright (c) 2010-2013 Wojciech Zawistowski, Travis Jeffery
  6. Permission is hereby granted, free of charge, to any person obtaining
  7. a copy of this software and associated documentation files (the
  8. "Software"), to deal in the Software without restriction, including
  9. without limitation the rights to use, copy, modify, merge, publish,
  10. distribute, sublicense, and/or sell copies of the Software, and to
  11. permit persons to whom the Software is furnished to do so, subject to
  12. the following conditions:
  13. The above copyright notice and this permission notice shall be
  14. included in all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. var readFixtures = function() {
  24. return jasmine.getFixtures().proxyCallTo_('read', arguments)
  25. }
  26. var preloadFixtures = function() {
  27. jasmine.getFixtures().proxyCallTo_('preload', arguments)
  28. }
  29. var loadFixtures = function() {
  30. jasmine.getFixtures().proxyCallTo_('load', arguments)
  31. }
  32. var appendLoadFixtures = function() {
  33. jasmine.getFixtures().proxyCallTo_('appendLoad', arguments)
  34. }
  35. var setFixtures = function(html) {
  36. return jasmine.getFixtures().proxyCallTo_('set', arguments)
  37. }
  38. var appendSetFixtures = function() {
  39. jasmine.getFixtures().proxyCallTo_('appendSet', arguments)
  40. }
  41. var sandbox = function(attributes) {
  42. return jasmine.getFixtures().sandbox(attributes)
  43. }
  44. var spyOnEvent = function(selector, eventName) {
  45. return jasmine.JQuery.events.spyOn(selector, eventName)
  46. }
  47. var preloadStyleFixtures = function() {
  48. jasmine.getStyleFixtures().proxyCallTo_('preload', arguments)
  49. }
  50. var loadStyleFixtures = function() {
  51. jasmine.getStyleFixtures().proxyCallTo_('load', arguments)
  52. }
  53. var appendLoadStyleFixtures = function() {
  54. jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments)
  55. }
  56. var setStyleFixtures = function(html) {
  57. jasmine.getStyleFixtures().proxyCallTo_('set', arguments)
  58. }
  59. var appendSetStyleFixtures = function(html) {
  60. jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments)
  61. }
  62. var loadJSONFixtures = function() {
  63. return jasmine.getJSONFixtures().proxyCallTo_('load', arguments)
  64. }
  65. var getJSONFixture = function(url) {
  66. return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url]
  67. }
  68. jasmine.spiedEventsKey = function (selector, eventName) {
  69. return [$(selector).selector, eventName].toString()
  70. }
  71. jasmine.getFixtures = function() {
  72. return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures()
  73. }
  74. jasmine.getStyleFixtures = function() {
  75. return jasmine.currentStyleFixtures_ = jasmine.currentStyleFixtures_ || new jasmine.StyleFixtures()
  76. }
  77. jasmine.Fixtures = function() {
  78. this.containerId = 'jasmine-fixtures'
  79. this.fixturesCache_ = {}
  80. this.fixturesPath = 'spec/javascripts/fixtures'
  81. }
  82. jasmine.Fixtures.prototype.set = function(html) {
  83. this.cleanUp()
  84. return this.createContainer_(html)
  85. }
  86. jasmine.Fixtures.prototype.appendSet= function(html) {
  87. this.addToContainer_(html)
  88. }
  89. jasmine.Fixtures.prototype.preload = function() {
  90. this.read.apply(this, arguments)
  91. }
  92. jasmine.Fixtures.prototype.load = function() {
  93. this.cleanUp()
  94. this.createContainer_(this.read.apply(this, arguments))
  95. }
  96. jasmine.Fixtures.prototype.appendLoad = function() {
  97. this.addToContainer_(this.read.apply(this, arguments))
  98. }
  99. jasmine.Fixtures.prototype.read = function() {
  100. var htmlChunks = []
  101. var fixtureUrls = arguments
  102. for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
  103. htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex]))
  104. }
  105. return htmlChunks.join('')
  106. }
  107. jasmine.Fixtures.prototype.clearCache = function() {
  108. this.fixturesCache_ = {}
  109. }
  110. jasmine.Fixtures.prototype.cleanUp = function() {
  111. $('#' + this.containerId).remove()
  112. }
  113. jasmine.Fixtures.prototype.sandbox = function(attributes) {
  114. var attributesToSet = attributes || {}
  115. return $('<div id="sandbox" />').attr(attributesToSet)
  116. }
  117. jasmine.Fixtures.prototype.createContainer_ = function(html) {
  118. var container = $('<div>')
  119. .attr('id', this.containerId)
  120. .html(html);
  121. $(document.body).append(container)
  122. return container
  123. }
  124. jasmine.Fixtures.prototype.addToContainer_ = function(html){
  125. var container = $(document.body).find('#'+this.containerId).append(html)
  126. if(!container.length){
  127. this.createContainer_(html)
  128. }
  129. }
  130. jasmine.Fixtures.prototype.getFixtureHtml_ = function(url) {
  131. if (typeof this.fixturesCache_[url] === 'undefined') {
  132. this.loadFixtureIntoCache_(url)
  133. }
  134. return this.fixturesCache_[url]
  135. }
  136. jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) {
  137. var url = this.makeFixtureUrl_(relativeUrl)
  138. var request = $.ajax({
  139. type: "GET",
  140. url: url + "?" + new Date().getTime(),
  141. async: false
  142. })
  143. this.fixturesCache_[relativeUrl] = request.responseText
  144. }
  145. jasmine.Fixtures.prototype.makeFixtureUrl_ = function(relativeUrl){
  146. return this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
  147. }
  148. jasmine.Fixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) {
  149. return this[methodName].apply(this, passedArguments)
  150. }
  151. jasmine.StyleFixtures = function() {
  152. this.fixturesCache_ = {}
  153. this.fixturesNodes_ = []
  154. this.fixturesPath = 'spec/javascripts/fixtures'
  155. }
  156. jasmine.StyleFixtures.prototype.set = function(css) {
  157. this.cleanUp()
  158. this.createStyle_(css)
  159. }
  160. jasmine.StyleFixtures.prototype.appendSet = function(css) {
  161. this.createStyle_(css)
  162. }
  163. jasmine.StyleFixtures.prototype.preload = function() {
  164. this.read_.apply(this, arguments)
  165. }
  166. jasmine.StyleFixtures.prototype.load = function() {
  167. this.cleanUp()
  168. this.createStyle_(this.read_.apply(this, arguments))
  169. }
  170. jasmine.StyleFixtures.prototype.appendLoad = function() {
  171. this.createStyle_(this.read_.apply(this, arguments))
  172. }
  173. jasmine.StyleFixtures.prototype.cleanUp = function() {
  174. while(this.fixturesNodes_.length) {
  175. this.fixturesNodes_.pop().remove()
  176. }
  177. }
  178. jasmine.StyleFixtures.prototype.createStyle_ = function(html) {
  179. var styleText = $('<div></div>').html(html).text(),
  180. style = $('<style>' + styleText + '</style>')
  181. this.fixturesNodes_.push(style)
  182. $('head').append(style)
  183. }
  184. jasmine.StyleFixtures.prototype.clearCache = jasmine.Fixtures.prototype.clearCache
  185. jasmine.StyleFixtures.prototype.read_ = jasmine.Fixtures.prototype.read
  186. jasmine.StyleFixtures.prototype.getFixtureHtml_ = jasmine.Fixtures.prototype.getFixtureHtml_
  187. jasmine.StyleFixtures.prototype.loadFixtureIntoCache_ = jasmine.Fixtures.prototype.loadFixtureIntoCache_
  188. jasmine.StyleFixtures.prototype.makeFixtureUrl_ = jasmine.Fixtures.prototype.makeFixtureUrl_
  189. jasmine.StyleFixtures.prototype.proxyCallTo_ = jasmine.Fixtures.prototype.proxyCallTo_
  190. jasmine.getJSONFixtures = function() {
  191. return jasmine.currentJSONFixtures_ = jasmine.currentJSONFixtures_ || new jasmine.JSONFixtures()
  192. }
  193. jasmine.JSONFixtures = function() {
  194. this.fixturesCache_ = {}
  195. this.fixturesPath = 'spec/javascripts/fixtures/json'
  196. }
  197. jasmine.JSONFixtures.prototype.load = function() {
  198. this.read.apply(this, arguments)
  199. return this.fixturesCache_
  200. }
  201. jasmine.JSONFixtures.prototype.read = function() {
  202. var fixtureUrls = arguments
  203. for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
  204. this.getFixtureData_(fixtureUrls[urlIndex])
  205. }
  206. return this.fixturesCache_
  207. }
  208. jasmine.JSONFixtures.prototype.clearCache = function() {
  209. this.fixturesCache_ = {}
  210. }
  211. jasmine.JSONFixtures.prototype.getFixtureData_ = function(url) {
  212. this.loadFixtureIntoCache_(url)
  213. return this.fixturesCache_[url]
  214. }
  215. jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) {
  216. var self = this
  217. var url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
  218. $.ajax({
  219. async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
  220. cache: false,
  221. dataType: 'json',
  222. url: url,
  223. success: function(data) {
  224. self.fixturesCache_[relativeUrl] = data
  225. },
  226. error: function(jqXHR, status, errorThrown) {
  227. throw Error('JSONFixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')')
  228. }
  229. })
  230. }
  231. jasmine.JSONFixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) {
  232. return this[methodName].apply(this, passedArguments)
  233. }
  234. jasmine.JQuery = function() {}
  235. jasmine.JQuery.browserTagCaseIndependentHtml = function(html) {
  236. return $('<div/>').append(html).html()
  237. }
  238. jasmine.JQuery.elementToString = function(element) {
  239. var domEl = $(element).get(0)
  240. if (domEl == undefined || domEl.cloneNode)
  241. return $('<div />').append($(element).clone()).html()
  242. else
  243. return element.toString()
  244. }
  245. jasmine.JQuery.matchersClass = {}
  246. !function(namespace) {
  247. var data = {
  248. spiedEvents: {},
  249. handlers: []
  250. }
  251. namespace.events = {
  252. spyOn: function(selector, eventName) {
  253. var handler = function(e) {
  254. data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = jasmine.util.argsToArray(arguments)
  255. }
  256. $(selector).on(eventName, handler)
  257. data.handlers.push(handler)
  258. return {
  259. selector: selector,
  260. eventName: eventName,
  261. handler: handler,
  262. reset: function(){
  263. delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
  264. }
  265. }
  266. },
  267. args: function(selector, eventName) {
  268. var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)];
  269. if (!actualArgs) {
  270. throw "There is no spy for " + eventName + " on " + selector.toString() + ". Make sure to create a spy using spyOnEvent.";
  271. }
  272. return actualArgs;
  273. },
  274. wasTriggered: function(selector, eventName) {
  275. return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)])
  276. },
  277. wasTriggeredWith: function(selector, eventName, expectedArgs, env) {
  278. var actualArgs = jasmine.JQuery.events.args(selector, eventName).slice(1);
  279. if (Object.prototype.toString.call(expectedArgs) !== '[object Array]') {
  280. actualArgs = actualArgs[0];
  281. }
  282. return env.equals_(expectedArgs, actualArgs);
  283. },
  284. wasPrevented: function(selector, eventName) {
  285. var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)],
  286. e = args ? args[0] : undefined;
  287. return e && e.isDefaultPrevented()
  288. },
  289. wasStopped: function(selector, eventName) {
  290. var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)],
  291. e = args ? args[0] : undefined;
  292. return e && e.isPropagationStopped()
  293. },
  294. cleanUp: function() {
  295. data.spiedEvents = {}
  296. data.handlers = []
  297. }
  298. }
  299. }(jasmine.JQuery)
  300. !function(){
  301. var jQueryMatchers = {
  302. toHaveClass: function(className) {
  303. return this.actual.hasClass(className)
  304. },
  305. toHaveCss: function(css){
  306. for (var prop in css){
  307. if (this.actual.css(prop) !== css[prop]) return false
  308. }
  309. return true
  310. },
  311. toBeVisible: function() {
  312. return this.actual.is(':visible')
  313. },
  314. toBeHidden: function() {
  315. return this.actual.is(':hidden')
  316. },
  317. toBeSelected: function() {
  318. return this.actual.is(':selected')
  319. },
  320. toBeChecked: function() {
  321. return this.actual.is(':checked')
  322. },
  323. toBeEmpty: function() {
  324. return this.actual.is(':empty')
  325. },
  326. toExist: function() {
  327. return $(document).find(this.actual).length
  328. },
  329. toHaveLength: function(length) {
  330. return this.actual.length === length
  331. },
  332. toHaveAttr: function(attributeName, expectedAttributeValue) {
  333. return hasProperty(this.actual.attr(attributeName), expectedAttributeValue)
  334. },
  335. toHaveProp: function(propertyName, expectedPropertyValue) {
  336. return hasProperty(this.actual.prop(propertyName), expectedPropertyValue)
  337. },
  338. toHaveId: function(id) {
  339. return this.actual.attr('id') == id
  340. },
  341. toHaveHtml: function(html) {
  342. return this.actual.html() == jasmine.JQuery.browserTagCaseIndependentHtml(html)
  343. },
  344. toContainHtml: function(html){
  345. var actualHtml = this.actual.html()
  346. var expectedHtml = jasmine.JQuery.browserTagCaseIndependentHtml(html)
  347. return (actualHtml.indexOf(expectedHtml) >= 0)
  348. },
  349. toHaveText: function(text) {
  350. var trimmedText = $.trim(this.actual.text())
  351. if (text && $.isFunction(text.test)) {
  352. return text.test(trimmedText)
  353. } else {
  354. return trimmedText == text
  355. }
  356. },
  357. toContainText: function(text) {
  358. var trimmedText = $.trim(this.actual.text())
  359. if (text && $.isFunction(text.test)) {
  360. return text.test(trimmedText)
  361. } else {
  362. return trimmedText.indexOf(text) != -1;
  363. }
  364. },
  365. toHaveValue: function(value) {
  366. return this.actual.val() === value
  367. },
  368. toHaveData: function(key, expectedValue) {
  369. return hasProperty(this.actual.data(key), expectedValue)
  370. },
  371. toBe: function(selector) {
  372. return this.actual.is(selector)
  373. },
  374. toContain: function(selector) {
  375. return this.actual.find(selector).length
  376. },
  377. toBeMatchedBy: function(selector) {
  378. return this.actual.filter(selector).length
  379. },
  380. toBeDisabled: function(selector){
  381. return this.actual.is(':disabled')
  382. },
  383. toBeFocused: function(selector) {
  384. return this.actual[0] === this.actual[0].ownerDocument.activeElement
  385. },
  386. toHandle: function(event) {
  387. var events = $._data(this.actual.get(0), "events")
  388. if(!events || !event || typeof event !== "string") {
  389. return false
  390. }
  391. var namespaces = event.split(".")
  392. var eventType = namespaces.shift()
  393. var sortedNamespaces = namespaces.slice(0).sort()
  394. var namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)")
  395. if(events[eventType] && namespaces.length) {
  396. for(var i = 0; i < events[eventType].length; i++) {
  397. var namespace = events[eventType][i].namespace
  398. if(namespaceRegExp.test(namespace)) {
  399. return true
  400. }
  401. }
  402. } else {
  403. return events[eventType] && events[eventType].length > 0
  404. }
  405. },
  406. // tests the existence of a specific event binding + handler
  407. toHandleWith: function(eventName, eventHandler) {
  408. var normalizedEventName = eventName.split('.')[0];
  409. var stack = $._data(this.actual.get(0), "events")[normalizedEventName]
  410. for (var i = 0; i < stack.length; i++) {
  411. if (stack[i].handler == eventHandler) return true
  412. }
  413. return false
  414. }
  415. }
  416. var hasProperty = function(actualValue, expectedValue) {
  417. if (expectedValue === undefined) return actualValue !== undefined
  418. return actualValue == expectedValue
  419. }
  420. var bindMatcher = function(methodName) {
  421. var builtInMatcher = jasmine.Matchers.prototype[methodName]
  422. jasmine.JQuery.matchersClass[methodName] = function() {
  423. if (this.actual
  424. && (this.actual instanceof $
  425. || jasmine.isDomNode(this.actual))) {
  426. this.actual = $(this.actual)
  427. var result = jQueryMatchers[methodName].apply(this, arguments)
  428. var element
  429. if (this.actual.get && (element = this.actual.get()[0]) && !$.isWindow(element) && element.tagName !== "HTML")
  430. this.actual = jasmine.JQuery.elementToString(this.actual)
  431. return result
  432. }
  433. if (builtInMatcher) {
  434. return builtInMatcher.apply(this, arguments)
  435. }
  436. return false
  437. }
  438. }
  439. for(var methodName in jQueryMatchers) {
  440. bindMatcher(methodName)
  441. }
  442. }()
  443. beforeEach(function() {
  444. this.addMatchers(jasmine.JQuery.matchersClass)
  445. this.addMatchers({
  446. toHaveBeenTriggeredOn: function(selector) {
  447. this.message = function() {
  448. return [
  449. "Expected event " + this.actual + " to have been triggered on " + selector,
  450. "Expected event " + this.actual + " not to have been triggered on " + selector
  451. ]
  452. }
  453. return jasmine.JQuery.events.wasTriggered(selector, this.actual)
  454. }
  455. })
  456. this.addMatchers({
  457. toHaveBeenTriggered: function(){
  458. var eventName = this.actual.eventName,
  459. selector = this.actual.selector
  460. this.message = function() {
  461. return [
  462. "Expected event " + eventName + " to have been triggered on " + selector,
  463. "Expected event " + eventName + " not to have been triggered on " + selector
  464. ]
  465. }
  466. return jasmine.JQuery.events.wasTriggered(selector, eventName)
  467. }
  468. })
  469. this.addMatchers({
  470. toHaveBeenTriggeredOnAndWith: function() {
  471. var selector = arguments[0],
  472. expectedArgs = arguments[1],
  473. wasTriggered = jasmine.JQuery.events.wasTriggered(selector, this.actual);
  474. this.message = function() {
  475. if (wasTriggered) {
  476. var actualArgs = jasmine.JQuery.events.args(selector, this.actual, expectedArgs)[1];
  477. return [
  478. "Expected event " + this.actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs),
  479. "Expected event " + this.actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs)
  480. ]
  481. } else {
  482. return [
  483. "Expected event " + this.actual + " to have been triggered on " + selector,
  484. "Expected event " + this.actual + " not to have been triggered on " + selector
  485. ]
  486. }
  487. }
  488. return wasTriggered && jasmine.JQuery.events.wasTriggeredWith(selector, this.actual, expectedArgs, this.env);
  489. }
  490. })
  491. this.addMatchers({
  492. toHaveBeenPreventedOn: function(selector) {
  493. this.message = function() {
  494. return [
  495. "Expected event " + this.actual + " to have been prevented on " + selector,
  496. "Expected event " + this.actual + " not to have been prevented on " + selector
  497. ]
  498. }
  499. return jasmine.JQuery.events.wasPrevented(selector, this.actual)
  500. }
  501. })
  502. this.addMatchers({
  503. toHaveBeenPrevented: function() {
  504. var eventName = this.actual.eventName,
  505. selector = this.actual.selector
  506. this.message = function() {
  507. return [
  508. "Expected event " + eventName + " to have been prevented on " + selector,
  509. "Expected event " + eventName + " not to have been prevented on " + selector
  510. ]
  511. }
  512. return jasmine.JQuery.events.wasPrevented(selector, eventName)
  513. }
  514. })
  515. this.addMatchers({
  516. toHaveBeenStoppedOn: function(selector) {
  517. this.message = function() {
  518. return [
  519. "Expected event " + this.actual + " to have been stopped on " + selector,
  520. "Expected event " + this.actual + " not to have been stopped on " + selector
  521. ]
  522. }
  523. return jasmine.JQuery.events.wasStopped(selector, this.actual)
  524. }
  525. })
  526. this.addMatchers({
  527. toHaveBeenStopped: function() {
  528. var eventName = this.actual.eventName,
  529. selector = this.actual.selector
  530. this.message = function() {
  531. return [
  532. "Expected event " + eventName + " to have been stopped on " + selector,
  533. "Expected event " + eventName + " not to have been stopped on " + selector
  534. ]
  535. }
  536. return jasmine.JQuery.events.wasStopped(selector, eventName)
  537. }
  538. })
  539. jasmine.getEnv().addEqualityTester(function(a, b) {
  540. if(a instanceof jQuery && b instanceof jQuery) {
  541. if(a.size() != b.size()) {
  542. return jasmine.undefined;
  543. }
  544. else if(a.is(b)) {
  545. return true;
  546. }
  547. }
  548. return jasmine.undefined;
  549. })
  550. })
  551. afterEach(function() {
  552. jasmine.getFixtures().cleanUp()
  553. jasmine.getStyleFixtures().cleanUp()
  554. jasmine.JQuery.events.cleanUp()
  555. })