You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

812 lines
24 KiB

  1. /*!
  2. Jasmine-jQuery: a set of jQuery helpers for Jasmine tests.
  3. Version 2.1.0
  4. https://github.com/velesin/jasmine-jquery
  5. Copyright (c) 2010-2014 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. +function (window, jasmine, $) { "use strict";
  24. jasmine.spiedEventsKey = function (selector, eventName) {
  25. return [$(selector).selector, eventName].toString()
  26. }
  27. jasmine.getFixtures = function () {
  28. return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures()
  29. }
  30. jasmine.getStyleFixtures = function () {
  31. return jasmine.currentStyleFixtures_ = jasmine.currentStyleFixtures_ || new jasmine.StyleFixtures()
  32. }
  33. jasmine.Fixtures = function () {
  34. this.containerId = 'jasmine-fixtures'
  35. this.fixturesCache_ = {}
  36. this.fixturesPath = 'spec/javascripts/fixtures'
  37. }
  38. jasmine.Fixtures.prototype.set = function (html) {
  39. this.cleanUp()
  40. return this.createContainer_(html)
  41. }
  42. jasmine.Fixtures.prototype.appendSet= function (html) {
  43. this.addToContainer_(html)
  44. }
  45. jasmine.Fixtures.prototype.preload = function () {
  46. this.read.apply(this, arguments)
  47. }
  48. jasmine.Fixtures.prototype.load = function () {
  49. this.cleanUp()
  50. this.createContainer_(this.read.apply(this, arguments))
  51. }
  52. jasmine.Fixtures.prototype.appendLoad = function () {
  53. this.addToContainer_(this.read.apply(this, arguments))
  54. }
  55. jasmine.Fixtures.prototype.read = function () {
  56. var htmlChunks = []
  57. , fixtureUrls = arguments
  58. for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
  59. htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex]))
  60. }
  61. return htmlChunks.join('')
  62. }
  63. jasmine.Fixtures.prototype.clearCache = function () {
  64. this.fixturesCache_ = {}
  65. }
  66. jasmine.Fixtures.prototype.cleanUp = function () {
  67. $('#' + this.containerId).remove()
  68. }
  69. jasmine.Fixtures.prototype.sandbox = function (attributes) {
  70. var attributesToSet = attributes || {}
  71. return $('<div id="sandbox" />').attr(attributesToSet)
  72. }
  73. jasmine.Fixtures.prototype.createContainer_ = function (html) {
  74. var container = $('<div>')
  75. .attr('id', this.containerId)
  76. .html(html)
  77. $(document.body).append(container)
  78. return container
  79. }
  80. jasmine.Fixtures.prototype.addToContainer_ = function (html){
  81. var container = $(document.body).find('#'+this.containerId).append(html)
  82. if (!container.length) {
  83. this.createContainer_(html)
  84. }
  85. }
  86. jasmine.Fixtures.prototype.getFixtureHtml_ = function (url) {
  87. if (typeof this.fixturesCache_[url] === 'undefined') {
  88. this.loadFixtureIntoCache_(url)
  89. }
  90. return this.fixturesCache_[url]
  91. }
  92. jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) {
  93. var self = this
  94. , url = this.makeFixtureUrl_(relativeUrl)
  95. , htmlText = ''
  96. , request = $.ajax({
  97. async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
  98. cache: false,
  99. url: url,
  100. success: function (data, status, $xhr) {
  101. htmlText = $xhr.responseText
  102. }
  103. }).fail(function ($xhr, status, err) {
  104. throw new Error('Fixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + err.message + ')')
  105. })
  106. var scripts = $($.parseHTML(htmlText, true)).find('script[src]') || [];
  107. scripts.each(function(){
  108. $.ajax({
  109. async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
  110. cache: false,
  111. dataType: 'script',
  112. url: $(this).attr('src'),
  113. success: function (data, status, $xhr) {
  114. htmlText += '<script>' + $xhr.responseText + '</script>'
  115. },
  116. error: function ($xhr, status, err) {
  117. throw new Error('Script could not be loaded: ' + scriptSrc + ' (status: ' + status + ', message: ' + err.message + ')')
  118. }
  119. });
  120. })
  121. self.fixturesCache_[relativeUrl] = htmlText;
  122. }
  123. jasmine.Fixtures.prototype.makeFixtureUrl_ = function (relativeUrl){
  124. return this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
  125. }
  126. jasmine.Fixtures.prototype.proxyCallTo_ = function (methodName, passedArguments) {
  127. return this[methodName].apply(this, passedArguments)
  128. }
  129. jasmine.StyleFixtures = function () {
  130. this.fixturesCache_ = {}
  131. this.fixturesNodes_ = []
  132. this.fixturesPath = 'spec/javascripts/fixtures'
  133. }
  134. jasmine.StyleFixtures.prototype.set = function (css) {
  135. this.cleanUp()
  136. this.createStyle_(css)
  137. }
  138. jasmine.StyleFixtures.prototype.appendSet = function (css) {
  139. this.createStyle_(css)
  140. }
  141. jasmine.StyleFixtures.prototype.preload = function () {
  142. this.read_.apply(this, arguments)
  143. }
  144. jasmine.StyleFixtures.prototype.load = function () {
  145. this.cleanUp()
  146. this.createStyle_(this.read_.apply(this, arguments))
  147. }
  148. jasmine.StyleFixtures.prototype.appendLoad = function () {
  149. this.createStyle_(this.read_.apply(this, arguments))
  150. }
  151. jasmine.StyleFixtures.prototype.cleanUp = function () {
  152. while(this.fixturesNodes_.length) {
  153. this.fixturesNodes_.pop().remove()
  154. }
  155. }
  156. jasmine.StyleFixtures.prototype.createStyle_ = function (html) {
  157. var styleText = $('<div></div>').html(html).text()
  158. , style = $('<style>' + styleText + '</style>')
  159. this.fixturesNodes_.push(style)
  160. $('head').append(style)
  161. }
  162. jasmine.StyleFixtures.prototype.clearCache = jasmine.Fixtures.prototype.clearCache
  163. jasmine.StyleFixtures.prototype.read_ = jasmine.Fixtures.prototype.read
  164. jasmine.StyleFixtures.prototype.getFixtureHtml_ = jasmine.Fixtures.prototype.getFixtureHtml_
  165. jasmine.StyleFixtures.prototype.loadFixtureIntoCache_ = jasmine.Fixtures.prototype.loadFixtureIntoCache_
  166. jasmine.StyleFixtures.prototype.makeFixtureUrl_ = jasmine.Fixtures.prototype.makeFixtureUrl_
  167. jasmine.StyleFixtures.prototype.proxyCallTo_ = jasmine.Fixtures.prototype.proxyCallTo_
  168. jasmine.getJSONFixtures = function () {
  169. return jasmine.currentJSONFixtures_ = jasmine.currentJSONFixtures_ || new jasmine.JSONFixtures()
  170. }
  171. jasmine.JSONFixtures = function () {
  172. this.fixturesCache_ = {}
  173. this.fixturesPath = 'spec/javascripts/fixtures/json'
  174. }
  175. jasmine.JSONFixtures.prototype.load = function () {
  176. this.read.apply(this, arguments)
  177. return this.fixturesCache_
  178. }
  179. jasmine.JSONFixtures.prototype.read = function () {
  180. var fixtureUrls = arguments
  181. for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
  182. this.getFixtureData_(fixtureUrls[urlIndex])
  183. }
  184. return this.fixturesCache_
  185. }
  186. jasmine.JSONFixtures.prototype.clearCache = function () {
  187. this.fixturesCache_ = {}
  188. }
  189. jasmine.JSONFixtures.prototype.getFixtureData_ = function (url) {
  190. if (!this.fixturesCache_[url]) this.loadFixtureIntoCache_(url)
  191. return this.fixturesCache_[url]
  192. }
  193. jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) {
  194. var self = this
  195. , url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
  196. $.ajax({
  197. async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
  198. cache: false,
  199. dataType: 'json',
  200. url: url,
  201. success: function (data) {
  202. self.fixturesCache_[relativeUrl] = data
  203. },
  204. error: function ($xhr, status, err) {
  205. throw new Error('JSONFixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + err.message + ')')
  206. }
  207. })
  208. }
  209. jasmine.JSONFixtures.prototype.proxyCallTo_ = function (methodName, passedArguments) {
  210. return this[methodName].apply(this, passedArguments)
  211. }
  212. jasmine.jQuery = function () {}
  213. jasmine.jQuery.browserTagCaseIndependentHtml = function (html) {
  214. return $('<div/>').append(html).html()
  215. }
  216. jasmine.jQuery.elementToString = function (element) {
  217. return $(element).map(function () { return this.outerHTML; }).toArray().join(', ')
  218. }
  219. var data = {
  220. spiedEvents: {}
  221. , handlers: []
  222. }
  223. jasmine.jQuery.events = {
  224. spyOn: function (selector, eventName) {
  225. var handler = function (e) {
  226. data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = jasmine.util.argsToArray(arguments)
  227. }
  228. $(selector).on(eventName, handler)
  229. data.handlers.push(handler)
  230. return {
  231. selector: selector,
  232. eventName: eventName,
  233. handler: handler,
  234. reset: function (){
  235. delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
  236. }
  237. }
  238. },
  239. args: function (selector, eventName) {
  240. var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
  241. if (!actualArgs) {
  242. throw "There is no spy for " + eventName + " on " + selector.toString() + ". Make sure to create a spy using spyOnEvent."
  243. }
  244. return actualArgs
  245. },
  246. wasTriggered: function (selector, eventName) {
  247. return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)])
  248. },
  249. wasTriggeredWith: function (selector, eventName, expectedArgs, util, customEqualityTesters) {
  250. var actualArgs = jasmine.jQuery.events.args(selector, eventName).slice(1)
  251. if (Object.prototype.toString.call(expectedArgs) !== '[object Array]')
  252. actualArgs = actualArgs[0]
  253. return util.equals(expectedArgs, actualArgs, customEqualityTesters)
  254. },
  255. wasPrevented: function (selector, eventName) {
  256. var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
  257. , e = args ? args[0] : undefined
  258. return e && e.isDefaultPrevented()
  259. },
  260. wasStopped: function (selector, eventName) {
  261. var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
  262. , e = args ? args[0] : undefined
  263. return e && e.isPropagationStopped()
  264. },
  265. cleanUp: function () {
  266. data.spiedEvents = {}
  267. data.handlers = []
  268. }
  269. }
  270. var hasProperty = function (actualValue, expectedValue) {
  271. if (expectedValue === undefined)
  272. return actualValue !== undefined
  273. return actualValue === expectedValue
  274. }
  275. beforeEach(function () {
  276. jasmine.addMatchers({
  277. toHaveClass: function () {
  278. return {
  279. compare: function (actual, className) {
  280. return { pass: $(actual).hasClass(className) }
  281. }
  282. }
  283. },
  284. toHaveCss: function () {
  285. return {
  286. compare: function (actual, css) {
  287. for (var prop in css){
  288. var value = css[prop]
  289. // see issue #147 on gh
  290. ;if (value === 'auto' && $(actual).get(0).style[prop] === 'auto') continue
  291. if ($(actual).css(prop) !== value) return { pass: false }
  292. }
  293. return { pass: true }
  294. }
  295. }
  296. },
  297. toBeVisible: function () {
  298. return {
  299. compare: function (actual) {
  300. return { pass: $(actual).is(':visible') }
  301. }
  302. }
  303. },
  304. toBeHidden: function () {
  305. return {
  306. compare: function (actual) {
  307. return { pass: $(actual).is(':hidden') }
  308. }
  309. }
  310. },
  311. toBeSelected: function () {
  312. return {
  313. compare: function (actual) {
  314. return { pass: $(actual).is(':selected') }
  315. }
  316. }
  317. },
  318. toBeChecked: function () {
  319. return {
  320. compare: function (actual) {
  321. return { pass: $(actual).is(':checked') }
  322. }
  323. }
  324. },
  325. toBeEmpty: function () {
  326. return {
  327. compare: function (actual) {
  328. return { pass: $(actual).is(':empty') }
  329. }
  330. }
  331. },
  332. toBeInDOM: function () {
  333. return {
  334. compare: function (actual) {
  335. return { pass: $.contains(document.documentElement, $(actual)[0]) }
  336. }
  337. }
  338. },
  339. toExist: function () {
  340. return {
  341. compare: function (actual) {
  342. return { pass: $(actual).length }
  343. }
  344. }
  345. },
  346. toHaveLength: function () {
  347. return {
  348. compare: function (actual, length) {
  349. return { pass: $(actual).length === length }
  350. }
  351. }
  352. },
  353. toHaveAttr: function () {
  354. return {
  355. compare: function (actual, attributeName, expectedAttributeValue) {
  356. return { pass: hasProperty($(actual).attr(attributeName), expectedAttributeValue) }
  357. }
  358. }
  359. },
  360. toHaveProp: function () {
  361. return {
  362. compare: function (actual, propertyName, expectedPropertyValue) {
  363. return { pass: hasProperty($(actual).prop(propertyName), expectedPropertyValue) }
  364. }
  365. }
  366. },
  367. toHaveId: function () {
  368. return {
  369. compare: function (actual, id) {
  370. return { pass: $(actual).attr('id') == id }
  371. }
  372. }
  373. },
  374. toHaveHtml: function () {
  375. return {
  376. compare: function (actual, html) {
  377. return { pass: $(actual).html() == jasmine.jQuery.browserTagCaseIndependentHtml(html) }
  378. }
  379. }
  380. },
  381. toContainHtml: function () {
  382. return {
  383. compare: function (actual, html) {
  384. var actualHtml = $(actual).html()
  385. , expectedHtml = jasmine.jQuery.browserTagCaseIndependentHtml(html)
  386. return { pass: (actualHtml.indexOf(expectedHtml) >= 0) }
  387. }
  388. }
  389. },
  390. toHaveText: function () {
  391. return {
  392. compare: function (actual, text) {
  393. var trimmedText = $.trim($(actual).text())
  394. if (text && $.isFunction(text.test)) {
  395. return { pass: text.test(trimmedText) }
  396. } else {
  397. return { pass: trimmedText == text }
  398. }
  399. }
  400. }
  401. },
  402. toContainText: function () {
  403. return {
  404. compare: function (actual, text) {
  405. var trimmedText = $.trim($(actual).text())
  406. if (text && $.isFunction(text.test)) {
  407. return { pass: text.test(trimmedText) }
  408. } else {
  409. return { pass: trimmedText.indexOf(text) != -1 }
  410. }
  411. }
  412. }
  413. },
  414. toHaveValue: function () {
  415. return {
  416. compare: function (actual, value) {
  417. return { pass: $(actual).val() === value }
  418. }
  419. }
  420. },
  421. toHaveData: function () {
  422. return {
  423. compare: function (actual, key, expectedValue) {
  424. return { pass: hasProperty($(actual).data(key), expectedValue) }
  425. }
  426. }
  427. },
  428. toContainElement: function () {
  429. return {
  430. compare: function (actual, selector) {
  431. if (window.debug) debugger
  432. return { pass: $(actual).find(selector).length }
  433. }
  434. }
  435. },
  436. toBeMatchedBy: function () {
  437. return {
  438. compare: function (actual, selector) {
  439. return { pass: $(actual).filter(selector).length }
  440. }
  441. }
  442. },
  443. toBeDisabled: function () {
  444. return {
  445. compare: function (actual, selector) {
  446. return { pass: $(actual).is(':disabled') }
  447. }
  448. }
  449. },
  450. toBeFocused: function (selector) {
  451. return {
  452. compare: function (actual, selector) {
  453. return { pass: $(actual)[0] === $(actual)[0].ownerDocument.activeElement }
  454. }
  455. }
  456. },
  457. toHandle: function () {
  458. return {
  459. compare: function (actual, event) {
  460. var events = $._data($(actual).get(0), "events")
  461. if (!events || !event || typeof event !== "string") {
  462. return { pass: false }
  463. }
  464. var namespaces = event.split(".")
  465. , eventType = namespaces.shift()
  466. , sortedNamespaces = namespaces.slice(0).sort()
  467. , namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)")
  468. if (events[eventType] && namespaces.length) {
  469. for (var i = 0; i < events[eventType].length; i++) {
  470. var namespace = events[eventType][i].namespace
  471. if (namespaceRegExp.test(namespace))
  472. return { pass: true }
  473. }
  474. } else {
  475. return { pass: (events[eventType] && events[eventType].length > 0) }
  476. }
  477. return { pass: false }
  478. }
  479. }
  480. },
  481. toHandleWith: function () {
  482. return {
  483. compare: function (actual, eventName, eventHandler) {
  484. var normalizedEventName = eventName.split('.')[0]
  485. , stack = $._data($(actual).get(0), "events")[normalizedEventName]
  486. for (var i = 0; i < stack.length; i++) {
  487. if (stack[i].handler == eventHandler) return { pass: true }
  488. }
  489. return { pass: false }
  490. }
  491. }
  492. },
  493. toHaveBeenTriggeredOn: function () {
  494. return {
  495. compare: function (actual, selector) {
  496. var result = { pass: jasmine.jQuery.events.wasTriggered(selector, actual) }
  497. result.message = result.pass ?
  498. "Expected event " + $(actual) + " not to have been triggered on " + selector :
  499. "Expected event " + $(actual) + " to have been triggered on " + selector
  500. return result;
  501. }
  502. }
  503. },
  504. toHaveBeenTriggered: function (){
  505. return {
  506. compare: function (actual) {
  507. var eventName = actual.eventName
  508. , selector = actual.selector
  509. , result = { pass: jasmine.jQuery.events.wasTriggered(selector, eventName) }
  510. result.message = result.pass ?
  511. "Expected event " + eventName + " not to have been triggered on " + selector :
  512. "Expected event " + eventName + " to have been triggered on " + selector
  513. return result
  514. }
  515. }
  516. },
  517. toHaveBeenTriggeredOnAndWith: function (j$, customEqualityTesters) {
  518. return {
  519. compare: function (actual, selector, expectedArgs) {
  520. var wasTriggered = jasmine.jQuery.events.wasTriggered(selector, actual)
  521. , result = { pass: wasTriggered && jasmine.jQuery.events.wasTriggeredWith(selector, actual, expectedArgs, j$, customEqualityTesters) }
  522. if (wasTriggered) {
  523. var actualArgs = jasmine.jQuery.events.args(selector, actual, expectedArgs)[1]
  524. result.message = result.pass ?
  525. "Expected event " + actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs) :
  526. "Expected event " + actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs)
  527. } else {
  528. // todo check on this
  529. result.message = result.pass ?
  530. "Expected event " + actual + " not to have been triggered on " + selector :
  531. "Expected event " + actual + " to have been triggered on " + selector
  532. }
  533. return result
  534. }
  535. }
  536. },
  537. toHaveBeenPreventedOn: function () {
  538. return {
  539. compare: function (actual, selector) {
  540. var result = { pass: jasmine.jQuery.events.wasPrevented(selector, actual) }
  541. result.message = result.pass ?
  542. "Expected event " + actual + " not to have been prevented on " + selector :
  543. "Expected event " + actual + " to have been prevented on " + selector
  544. return result
  545. }
  546. }
  547. },
  548. toHaveBeenPrevented: function () {
  549. return {
  550. compare: function (actual) {
  551. var eventName = actual.eventName
  552. , selector = actual.selector
  553. , result = { pass: jasmine.jQuery.events.wasPrevented(selector, eventName) }
  554. result.message = result.pass ?
  555. "Expected event " + eventName + " not to have been prevented on " + selector :
  556. "Expected event " + eventName + " to have been prevented on " + selector
  557. return result
  558. }
  559. }
  560. },
  561. toHaveBeenStoppedOn: function () {
  562. return {
  563. compare: function (actual, selector) {
  564. var result = { pass: jasmine.jQuery.events.wasStopped(selector, actual) }
  565. result.message = result.pass ?
  566. "Expected event " + actual + " not to have been stopped on " + selector :
  567. "Expected event " + actual + " to have been stopped on " + selector
  568. return result;
  569. }
  570. }
  571. },
  572. toHaveBeenStopped: function () {
  573. return {
  574. compare: function (actual) {
  575. var eventName = actual.eventName
  576. , selector = actual.selector
  577. , result = { pass: jasmine.jQuery.events.wasStopped(selector, eventName) }
  578. result.message = result.pass ?
  579. "Expected event " + eventName + " not to have been stopped on " + selector :
  580. "Expected event " + eventName + " to have been stopped on " + selector
  581. return result
  582. }
  583. }
  584. }
  585. })
  586. jasmine.getEnv().addCustomEqualityTester(function(a, b) {
  587. if (a && b) {
  588. if (a instanceof $ || jasmine.isDomNode(a)) {
  589. var $a = $(a)
  590. if (b instanceof $)
  591. return $a.length == b.length && a.is(b)
  592. return $a.is(b);
  593. }
  594. if (b instanceof $ || jasmine.isDomNode(b)) {
  595. var $b = $(b)
  596. if (a instanceof jQuery)
  597. return a.length == $b.length && $b.is(a)
  598. return $(b).is(a);
  599. }
  600. }
  601. })
  602. jasmine.getEnv().addCustomEqualityTester(function (a, b) {
  603. if (a instanceof jQuery && b instanceof jQuery && a.size() == b.size())
  604. return a.is(b)
  605. })
  606. })
  607. afterEach(function () {
  608. jasmine.getFixtures().cleanUp()
  609. jasmine.getStyleFixtures().cleanUp()
  610. jasmine.jQuery.events.cleanUp()
  611. })
  612. window.readFixtures = function () {
  613. return jasmine.getFixtures().proxyCallTo_('read', arguments)
  614. }
  615. window.preloadFixtures = function () {
  616. jasmine.getFixtures().proxyCallTo_('preload', arguments)
  617. }
  618. window.loadFixtures = function () {
  619. jasmine.getFixtures().proxyCallTo_('load', arguments)
  620. }
  621. window.appendLoadFixtures = function () {
  622. jasmine.getFixtures().proxyCallTo_('appendLoad', arguments)
  623. }
  624. window.setFixtures = function (html) {
  625. return jasmine.getFixtures().proxyCallTo_('set', arguments)
  626. }
  627. window.appendSetFixtures = function () {
  628. jasmine.getFixtures().proxyCallTo_('appendSet', arguments)
  629. }
  630. window.sandbox = function (attributes) {
  631. return jasmine.getFixtures().sandbox(attributes)
  632. }
  633. window.spyOnEvent = function (selector, eventName) {
  634. return jasmine.jQuery.events.spyOn(selector, eventName)
  635. }
  636. window.preloadStyleFixtures = function () {
  637. jasmine.getStyleFixtures().proxyCallTo_('preload', arguments)
  638. }
  639. window.loadStyleFixtures = function () {
  640. jasmine.getStyleFixtures().proxyCallTo_('load', arguments)
  641. }
  642. window.appendLoadStyleFixtures = function () {
  643. jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments)
  644. }
  645. window.setStyleFixtures = function (html) {
  646. jasmine.getStyleFixtures().proxyCallTo_('set', arguments)
  647. }
  648. window.appendSetStyleFixtures = function (html) {
  649. jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments)
  650. }
  651. window.loadJSONFixtures = function () {
  652. return jasmine.getJSONFixtures().proxyCallTo_('load', arguments)
  653. }
  654. window.getJSONFixture = function (url) {
  655. return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url]
  656. }
  657. }(window, window.jasmine, window.jQuery);