jasmine-jquery-rails 1.5.9 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jasmine-jquery-rails/version.rb +1 -1
- data/vendor/assets/javascripts/jasmine-jquery.js +410 -302
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3586de1a3e0f7d2e160bffc4fe8bc38fd0b49b7
|
4
|
+
data.tar.gz: d5d38ca8d7c32c6e87720c49fda85a9af0f9f51a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0230afceba722243a2951698c9fdc404fbc377d7d300d80076665be7152c362e8a741dc31acbc326ae7f56300da9f69d3d39ef2abd270999116bb53f37229df
|
7
|
+
data.tar.gz: e8008fe6f78d14dcb07e558293cc8d01ea15a1be0df95663c3a3c80b495edb108c3aa0e718c6718fe7bfbde64384f9b4a0b146441c92cba2e8fbb8e4c82316d8
|
@@ -1,11 +1,11 @@
|
|
1
1
|
/*!
|
2
2
|
Jasmine-jQuery: a set of jQuery helpers for Jasmine tests.
|
3
3
|
|
4
|
-
Version
|
4
|
+
Version 2.0.2
|
5
5
|
|
6
6
|
https://github.com/velesin/jasmine-jquery
|
7
7
|
|
8
|
-
Copyright (c) 2010-
|
8
|
+
Copyright (c) 2010-2014 Wojciech Zawistowski, Travis Jeffery
|
9
9
|
|
10
10
|
Permission is hereby granted, free of charge, to any person obtaining
|
11
11
|
a copy of this software and associated documentation files (the
|
@@ -27,7 +27,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
27
27
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
28
28
|
*/
|
29
29
|
|
30
|
-
+function (jasmine, $) { "use strict";
|
30
|
+
+function (window, jasmine, $) { "use strict";
|
31
31
|
|
32
32
|
jasmine.spiedEventsKey = function (selector, eventName) {
|
33
33
|
return [$(selector).selector, eventName].toString()
|
@@ -104,7 +104,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
104
104
|
|
105
105
|
jasmine.Fixtures.prototype.addToContainer_ = function (html){
|
106
106
|
var container = $(document.body).find('#'+this.containerId).append(html)
|
107
|
-
|
107
|
+
|
108
|
+
if (!container.length) {
|
108
109
|
this.createContainer_(html)
|
109
110
|
}
|
110
111
|
}
|
@@ -119,17 +120,36 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
119
120
|
jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) {
|
120
121
|
var self = this
|
121
122
|
, url = this.makeFixtureUrl_(relativeUrl)
|
123
|
+
, htmlText = ''
|
122
124
|
, request = $.ajax({
|
123
125
|
async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
|
124
126
|
cache: false,
|
125
127
|
url: url,
|
126
128
|
success: function (data, status, $xhr) {
|
127
|
-
|
128
|
-
},
|
129
|
-
error: function (jqXHR, status, errorThrown) {
|
130
|
-
throw new Error('Fixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')')
|
129
|
+
htmlText = $xhr.responseText
|
131
130
|
}
|
131
|
+
}).fail(function () {
|
132
|
+
throw new Error('Fixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')')
|
133
|
+
})
|
134
|
+
|
135
|
+
var scripts = $($.parseHTML(htmlText, true)).find('script[src]') || [];
|
136
|
+
|
137
|
+
scripts.each(function(){
|
138
|
+
$.ajax({
|
139
|
+
async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
|
140
|
+
cache: false,
|
141
|
+
dataType: 'script',
|
142
|
+
url: $(this).attr('src'),
|
143
|
+
success: function (data, status, $xhr) {
|
144
|
+
htmlText += '<script>' + $xhr.responseText + '</script>'
|
145
|
+
},
|
146
|
+
error: function (jqXHR, status, errorThrown) {
|
147
|
+
throw new Error('Script could not be loaded: ' + scriptSrc + ' (status: ' + status + ', message: ' + errorThrown.message + ')')
|
148
|
+
}
|
149
|
+
});
|
132
150
|
})
|
151
|
+
|
152
|
+
self.fixturesCache_[relativeUrl] = htmlText;
|
133
153
|
}
|
134
154
|
|
135
155
|
jasmine.Fixtures.prototype.makeFixtureUrl_ = function (relativeUrl){
|
@@ -219,7 +239,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
219
239
|
}
|
220
240
|
|
221
241
|
jasmine.JSONFixtures.prototype.getFixtureData_ = function (url) {
|
222
|
-
this.loadFixtureIntoCache_(url)
|
242
|
+
if (!this.fixturesCache_[url]) this.loadFixtureIntoCache_(url)
|
223
243
|
return this.fixturesCache_[url]
|
224
244
|
}
|
225
245
|
|
@@ -245,461 +265,549 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
245
265
|
return this[methodName].apply(this, passedArguments)
|
246
266
|
}
|
247
267
|
|
248
|
-
jasmine.
|
268
|
+
jasmine.jQuery = function () {}
|
249
269
|
|
250
|
-
jasmine.
|
270
|
+
jasmine.jQuery.browserTagCaseIndependentHtml = function (html) {
|
251
271
|
return $('<div/>').append(html).html()
|
252
272
|
}
|
253
273
|
|
254
|
-
jasmine.
|
255
|
-
|
274
|
+
jasmine.jQuery.elementToString = function (element) {
|
275
|
+
return $(element).map(function () { return this.outerHTML; }).toArray().join(', ')
|
276
|
+
}
|
256
277
|
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
return element.toString()
|
278
|
+
var data = {
|
279
|
+
spiedEvents: {}
|
280
|
+
, handlers: []
|
261
281
|
}
|
262
282
|
|
263
|
-
jasmine.
|
283
|
+
jasmine.jQuery.events = {
|
284
|
+
spyOn: function (selector, eventName) {
|
285
|
+
var handler = function (e) {
|
286
|
+
data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = jasmine.util.argsToArray(arguments)
|
287
|
+
}
|
264
288
|
|
265
|
-
|
266
|
-
|
267
|
-
spiedEvents: {}
|
268
|
-
, handlers: []
|
269
|
-
}
|
289
|
+
$(selector).on(eventName, handler)
|
290
|
+
data.handlers.push(handler)
|
270
291
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
292
|
+
return {
|
293
|
+
selector: selector,
|
294
|
+
eventName: eventName,
|
295
|
+
handler: handler,
|
296
|
+
reset: function (){
|
297
|
+
delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
|
275
298
|
}
|
299
|
+
}
|
300
|
+
},
|
276
301
|
|
277
|
-
|
278
|
-
|
302
|
+
args: function (selector, eventName) {
|
303
|
+
var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
|
279
304
|
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
handler: handler,
|
284
|
-
reset: function (){
|
285
|
-
delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
|
286
|
-
}
|
287
|
-
}
|
288
|
-
},
|
305
|
+
if (!actualArgs) {
|
306
|
+
throw "There is no spy for " + eventName + " on " + selector.toString() + ". Make sure to create a spy using spyOnEvent."
|
307
|
+
}
|
289
308
|
|
290
|
-
|
291
|
-
|
309
|
+
return actualArgs
|
310
|
+
},
|
292
311
|
|
293
|
-
|
294
|
-
|
295
|
-
|
312
|
+
wasTriggered: function (selector, eventName) {
|
313
|
+
return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)])
|
314
|
+
},
|
296
315
|
|
297
|
-
|
298
|
-
|
316
|
+
wasTriggeredWith: function (selector, eventName, expectedArgs, util, customEqualityTesters) {
|
317
|
+
var actualArgs = jasmine.jQuery.events.args(selector, eventName).slice(1)
|
299
318
|
|
300
|
-
|
301
|
-
|
302
|
-
},
|
319
|
+
if (Object.prototype.toString.call(expectedArgs) !== '[object Array]')
|
320
|
+
actualArgs = actualArgs[0]
|
303
321
|
|
304
|
-
|
305
|
-
|
306
|
-
if (Object.prototype.toString.call(expectedArgs) !== '[object Array]') {
|
307
|
-
actualArgs = actualArgs[0]
|
308
|
-
}
|
309
|
-
return env.equals_(expectedArgs, actualArgs)
|
310
|
-
},
|
322
|
+
return util.equals(expectedArgs, actualArgs, customEqualityTesters)
|
323
|
+
},
|
311
324
|
|
312
|
-
|
313
|
-
|
314
|
-
|
325
|
+
wasPrevented: function (selector, eventName) {
|
326
|
+
var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
|
327
|
+
, e = args ? args[0] : undefined
|
315
328
|
|
316
|
-
|
317
|
-
|
329
|
+
return e && e.isDefaultPrevented()
|
330
|
+
},
|
318
331
|
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
332
|
+
wasStopped: function (selector, eventName) {
|
333
|
+
var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
|
334
|
+
, e = args ? args[0] : undefined
|
335
|
+
return e && e.isPropagationStopped()
|
336
|
+
},
|
324
337
|
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
}
|
338
|
+
cleanUp: function () {
|
339
|
+
data.spiedEvents = {}
|
340
|
+
data.handlers = []
|
329
341
|
}
|
330
|
-
}
|
342
|
+
}
|
343
|
+
|
344
|
+
var hasProperty = function (actualValue, expectedValue) {
|
345
|
+
if (expectedValue === undefined)
|
346
|
+
return actualValue !== undefined
|
331
347
|
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
348
|
+
return actualValue === expectedValue
|
349
|
+
}
|
350
|
+
|
351
|
+
beforeEach(function () {
|
352
|
+
jasmine.addMatchers({
|
353
|
+
toHaveClass: function () {
|
354
|
+
return {
|
355
|
+
compare: function (actual, className) {
|
356
|
+
return { pass: $(actual).hasClass(className) }
|
357
|
+
}
|
358
|
+
}
|
336
359
|
},
|
337
360
|
|
338
|
-
toHaveCss: function (
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
361
|
+
toHaveCss: function () {
|
362
|
+
return {
|
363
|
+
compare: function (actual, css) {
|
364
|
+
for (var prop in css){
|
365
|
+
var value = css[prop]
|
366
|
+
// see issue #147 on gh
|
367
|
+
;if (value === 'auto' && $(actual).get(0).style[prop] === 'auto') continue
|
368
|
+
if ($(actual).css(prop) !== value) return { pass: false }
|
369
|
+
}
|
370
|
+
return { pass: true }
|
371
|
+
}
|
344
372
|
}
|
345
|
-
return true
|
346
373
|
},
|
347
374
|
|
348
375
|
toBeVisible: function () {
|
349
|
-
return
|
376
|
+
return {
|
377
|
+
compare: function (actual) {
|
378
|
+
return { pass: $(actual).is(':visible') }
|
379
|
+
}
|
380
|
+
}
|
350
381
|
},
|
351
382
|
|
352
383
|
toBeHidden: function () {
|
353
|
-
return
|
384
|
+
return {
|
385
|
+
compare: function (actual) {
|
386
|
+
return { pass: $(actual).is(':hidden') }
|
387
|
+
}
|
388
|
+
}
|
354
389
|
},
|
355
390
|
|
356
391
|
toBeSelected: function () {
|
357
|
-
return
|
392
|
+
return {
|
393
|
+
compare: function (actual) {
|
394
|
+
return { pass: $(actual).is(':selected') }
|
395
|
+
}
|
396
|
+
}
|
358
397
|
},
|
359
398
|
|
360
399
|
toBeChecked: function () {
|
361
|
-
return
|
400
|
+
return {
|
401
|
+
compare: function (actual) {
|
402
|
+
return { pass: $(actual).is(':checked') }
|
403
|
+
}
|
404
|
+
}
|
362
405
|
},
|
363
406
|
|
364
407
|
toBeEmpty: function () {
|
365
|
-
return
|
408
|
+
return {
|
409
|
+
compare: function (actual) {
|
410
|
+
return { pass: $(actual).is(':empty') }
|
411
|
+
}
|
412
|
+
}
|
366
413
|
},
|
367
414
|
|
368
|
-
|
369
|
-
return
|
415
|
+
toBeInDOM: function () {
|
416
|
+
return {
|
417
|
+
compare: function (actual) {
|
418
|
+
return { pass: $.contains(document.documentElement, $(actual)[0]) }
|
419
|
+
}
|
420
|
+
}
|
370
421
|
},
|
371
422
|
|
372
|
-
|
373
|
-
return
|
423
|
+
toExist: function () {
|
424
|
+
return {
|
425
|
+
compare: function (actual) {
|
426
|
+
return { pass: $(actual).length }
|
427
|
+
}
|
428
|
+
}
|
374
429
|
},
|
375
430
|
|
376
|
-
|
377
|
-
return
|
431
|
+
toHaveLength: function () {
|
432
|
+
return {
|
433
|
+
compare: function (actual, length) {
|
434
|
+
return { pass: $(actual).length === length }
|
435
|
+
}
|
436
|
+
}
|
378
437
|
},
|
379
438
|
|
380
|
-
|
381
|
-
return
|
439
|
+
toHaveAttr: function () {
|
440
|
+
return {
|
441
|
+
compare: function (actual, attributeName, expectedAttributeValue) {
|
442
|
+
return { pass: hasProperty($(actual).attr(attributeName), expectedAttributeValue) }
|
443
|
+
}
|
444
|
+
}
|
382
445
|
},
|
383
446
|
|
384
|
-
|
385
|
-
return
|
447
|
+
toHaveProp: function () {
|
448
|
+
return {
|
449
|
+
compare: function (actual, propertyName, expectedPropertyValue) {
|
450
|
+
return { pass: hasProperty($(actual).prop(propertyName), expectedPropertyValue) }
|
451
|
+
}
|
452
|
+
}
|
386
453
|
},
|
387
454
|
|
388
|
-
|
389
|
-
return
|
455
|
+
toHaveId: function () {
|
456
|
+
return {
|
457
|
+
compare: function (actual, id) {
|
458
|
+
return { pass: $(actual).attr('id') == id }
|
459
|
+
}
|
460
|
+
}
|
390
461
|
},
|
391
462
|
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
463
|
+
toHaveHtml: function () {
|
464
|
+
return {
|
465
|
+
compare: function (actual, html) {
|
466
|
+
return { pass: $(actual).html() == jasmine.jQuery.browserTagCaseIndependentHtml(html) }
|
467
|
+
}
|
468
|
+
}
|
397
469
|
},
|
398
470
|
|
399
|
-
|
400
|
-
|
471
|
+
toContainHtml: function () {
|
472
|
+
return {
|
473
|
+
compare: function (actual, html) {
|
474
|
+
var actualHtml = $(actual).html()
|
475
|
+
, expectedHtml = jasmine.jQuery.browserTagCaseIndependentHtml(html)
|
401
476
|
|
402
|
-
|
403
|
-
|
404
|
-
} else {
|
405
|
-
return trimmedText == text
|
477
|
+
return { pass: (actualHtml.indexOf(expectedHtml) >= 0) }
|
478
|
+
}
|
406
479
|
}
|
407
480
|
},
|
408
481
|
|
409
|
-
|
410
|
-
|
482
|
+
toHaveText: function () {
|
483
|
+
return {
|
484
|
+
compare: function (actual, text) {
|
485
|
+
var trimmedText = $.trim($(actual).text())
|
411
486
|
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
487
|
+
if (text && $.isFunction(text.test)) {
|
488
|
+
return { pass: text.test(trimmedText) }
|
489
|
+
} else {
|
490
|
+
return { pass: trimmedText == text }
|
491
|
+
}
|
492
|
+
}
|
416
493
|
}
|
417
494
|
},
|
418
495
|
|
419
|
-
|
420
|
-
return
|
496
|
+
toContainText: function () {
|
497
|
+
return {
|
498
|
+
compare: function (actual, text) {
|
499
|
+
var trimmedText = $.trim($(actual).text())
|
500
|
+
|
501
|
+
if (text && $.isFunction(text.test)) {
|
502
|
+
return { pass: text.test(trimmedText) }
|
503
|
+
} else {
|
504
|
+
return { pass: trimmedText.indexOf(text) != -1 }
|
505
|
+
}
|
506
|
+
}
|
507
|
+
}
|
421
508
|
},
|
422
509
|
|
423
|
-
|
424
|
-
return
|
510
|
+
toHaveValue: function () {
|
511
|
+
return {
|
512
|
+
compare: function (actual, value) {
|
513
|
+
return { pass: $(actual).val() === value }
|
514
|
+
}
|
515
|
+
}
|
425
516
|
},
|
426
517
|
|
427
|
-
|
428
|
-
return
|
518
|
+
toHaveData: function () {
|
519
|
+
return {
|
520
|
+
compare: function (actual, key, expectedValue) {
|
521
|
+
return { pass: hasProperty($(actual).data(key), expectedValue) }
|
522
|
+
}
|
523
|
+
}
|
429
524
|
},
|
430
525
|
|
431
|
-
|
432
|
-
return
|
526
|
+
toContainElement: function () {
|
527
|
+
return {
|
528
|
+
compare: function (actual, selector) {
|
529
|
+
if (window.debug) debugger
|
530
|
+
return { pass: $(actual).find(selector).length }
|
531
|
+
}
|
532
|
+
}
|
433
533
|
},
|
434
534
|
|
435
|
-
toBeMatchedBy: function (
|
436
|
-
return
|
535
|
+
toBeMatchedBy: function () {
|
536
|
+
return {
|
537
|
+
compare: function (actual, selector) {
|
538
|
+
return { pass: $(actual).filter(selector).length }
|
539
|
+
}
|
540
|
+
}
|
437
541
|
},
|
438
542
|
|
439
|
-
toBeDisabled: function (
|
440
|
-
return
|
543
|
+
toBeDisabled: function () {
|
544
|
+
return {
|
545
|
+
compare: function (actual, selector) {
|
546
|
+
return { pass: $(actual).is(':disabled') }
|
547
|
+
}
|
548
|
+
}
|
441
549
|
},
|
442
550
|
|
443
551
|
toBeFocused: function (selector) {
|
444
|
-
return
|
552
|
+
return {
|
553
|
+
compare: function (actual, selector) {
|
554
|
+
return { pass: $(actual)[0] === $(actual)[0].ownerDocument.activeElement }
|
555
|
+
}
|
556
|
+
}
|
445
557
|
},
|
446
558
|
|
447
|
-
toHandle: function (
|
448
|
-
|
559
|
+
toHandle: function () {
|
560
|
+
return {
|
561
|
+
compare: function (actual, event) {
|
562
|
+
var events = $._data($(actual).get(0), "events")
|
449
563
|
|
450
|
-
|
451
|
-
|
452
|
-
|
564
|
+
if (!events || !event || typeof event !== "string") {
|
565
|
+
return { pass: false }
|
566
|
+
}
|
453
567
|
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
568
|
+
var namespaces = event.split(".")
|
569
|
+
, eventType = namespaces.shift()
|
570
|
+
, sortedNamespaces = namespaces.slice(0).sort()
|
571
|
+
, namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)")
|
458
572
|
|
459
|
-
|
460
|
-
|
461
|
-
|
573
|
+
if (events[eventType] && namespaces.length) {
|
574
|
+
for (var i = 0; i < events[eventType].length; i++) {
|
575
|
+
var namespace = events[eventType][i].namespace
|
462
576
|
|
463
|
-
|
464
|
-
|
577
|
+
if (namespaceRegExp.test(namespace))
|
578
|
+
return { pass: true }
|
579
|
+
}
|
580
|
+
} else {
|
581
|
+
return { pass: (events[eventType] && events[eventType].length > 0) }
|
465
582
|
}
|
583
|
+
|
584
|
+
return { pass: false }
|
466
585
|
}
|
467
|
-
} else {
|
468
|
-
return events[eventType] && events[eventType].length > 0
|
469
586
|
}
|
470
587
|
},
|
471
588
|
|
472
|
-
toHandleWith: function (
|
473
|
-
|
474
|
-
|
589
|
+
toHandleWith: function () {
|
590
|
+
return {
|
591
|
+
compare: function (actual, eventName, eventHandler) {
|
592
|
+
var normalizedEventName = eventName.split('.')[0]
|
593
|
+
, stack = $._data($(actual).get(0), "events")[normalizedEventName]
|
475
594
|
|
476
|
-
|
477
|
-
|
595
|
+
for (var i = 0; i < stack.length; i++) {
|
596
|
+
if (stack[i].handler == eventHandler) return { pass: true }
|
597
|
+
}
|
598
|
+
|
599
|
+
return { pass: false }
|
600
|
+
}
|
478
601
|
}
|
602
|
+
},
|
479
603
|
|
480
|
-
|
481
|
-
|
482
|
-
|
604
|
+
toHaveBeenTriggeredOn: function () {
|
605
|
+
return {
|
606
|
+
compare: function (actual, selector) {
|
607
|
+
var result = { pass: jasmine.jQuery.events.wasTriggered(selector, actual) }
|
483
608
|
|
484
|
-
|
485
|
-
|
609
|
+
result.message = result.pass ?
|
610
|
+
"Expected event " + $(actual) + " not to have been triggered on " + selector :
|
611
|
+
"Expected event " + $(actual) + " to have been triggered on " + selector
|
486
612
|
|
487
|
-
|
488
|
-
|
613
|
+
return result;
|
614
|
+
}
|
615
|
+
}
|
616
|
+
},
|
489
617
|
|
490
|
-
|
491
|
-
|
618
|
+
toHaveBeenTriggered: function (){
|
619
|
+
return {
|
620
|
+
compare: function (actual) {
|
621
|
+
var eventName = actual.eventName
|
622
|
+
, selector = actual.selector
|
623
|
+
, result = { pass: jasmine.jQuery.events.wasTriggered(selector, eventName) }
|
624
|
+
|
625
|
+
result.message = result.pass ?
|
626
|
+
"Expected event " + eventName + " not to have been triggered on " + selector :
|
627
|
+
"Expected event " + eventName + " to have been triggered on " + selector
|
492
628
|
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
this.actual = $(this.actual)
|
498
|
-
var result = jQueryMatchers[methodName].apply(this, arguments)
|
499
|
-
, element
|
629
|
+
return result
|
630
|
+
}
|
631
|
+
}
|
632
|
+
},
|
500
633
|
|
501
|
-
|
502
|
-
|
634
|
+
toHaveBeenTriggeredOnAndWith: function (j$, customEqualityTesters) {
|
635
|
+
return {
|
636
|
+
compare: function (actual, selector, expectedArgs) {
|
637
|
+
var wasTriggered = jasmine.jQuery.events.wasTriggered(selector, actual)
|
638
|
+
, result = { pass: wasTriggered && jasmine.jQuery.events.wasTriggeredWith(selector, actual, expectedArgs, j$, customEqualityTesters) }
|
639
|
+
|
640
|
+
if (wasTriggered) {
|
641
|
+
var actualArgs = jasmine.jQuery.events.args(selector, actual, expectedArgs)[1]
|
642
|
+
result.message = result.pass ?
|
643
|
+
"Expected event " + actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs) :
|
644
|
+
"Expected event " + actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs)
|
645
|
+
|
646
|
+
} else {
|
647
|
+
// todo check on this
|
648
|
+
result.message = result.pass ?
|
649
|
+
"Expected event " + actual + " not to have been triggered on " + selector :
|
650
|
+
"Expected event " + actual + " to have been triggered on " + selector
|
651
|
+
}
|
503
652
|
|
504
653
|
return result
|
505
|
-
|
654
|
+
}
|
655
|
+
}
|
656
|
+
},
|
506
657
|
|
507
|
-
|
508
|
-
|
509
|
-
|
658
|
+
toHaveBeenPreventedOn: function () {
|
659
|
+
return {
|
660
|
+
compare: function (actual, selector) {
|
661
|
+
var result = { pass: jasmine.jQuery.events.wasPrevented(selector, actual) }
|
510
662
|
|
511
|
-
|
512
|
-
|
513
|
-
|
663
|
+
result.message = result.pass ?
|
664
|
+
"Expected event " + actual + " not to have been prevented on " + selector :
|
665
|
+
"Expected event " + actual + " to have been prevented on " + selector
|
514
666
|
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
667
|
+
return result
|
668
|
+
}
|
669
|
+
}
|
670
|
+
},
|
519
671
|
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
"Expected event " + this.actual + " to have been triggered on " + selector,
|
527
|
-
"Expected event " + this.actual + " not to have been triggered on " + selector
|
528
|
-
]
|
529
|
-
}
|
530
|
-
return jasmine.JQuery.events.wasTriggered(selector, this.actual)
|
531
|
-
}
|
532
|
-
})
|
533
|
-
this.addMatchers({
|
534
|
-
toHaveBeenTriggered: function (){
|
535
|
-
var eventName = this.actual.eventName
|
536
|
-
, selector = this.actual.selector
|
672
|
+
toHaveBeenPrevented: function () {
|
673
|
+
return {
|
674
|
+
compare: function (actual) {
|
675
|
+
var eventName = actual.eventName
|
676
|
+
, selector = actual.selector
|
677
|
+
, result = { pass: jasmine.jQuery.events.wasPrevented(selector, eventName) }
|
537
678
|
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
"Expected event " + eventName + " not to have been triggered on " + selector
|
542
|
-
]
|
543
|
-
}
|
679
|
+
result.message = result.pass ?
|
680
|
+
"Expected event " + eventName + " not to have been prevented on " + selector :
|
681
|
+
"Expected event " + eventName + " to have been prevented on " + selector
|
544
682
|
|
545
|
-
|
546
|
-
|
547
|
-
})
|
548
|
-
this.addMatchers({
|
549
|
-
toHaveBeenTriggeredOnAndWith: function () {
|
550
|
-
var selector = arguments[0]
|
551
|
-
, expectedArgs = arguments[1]
|
552
|
-
, wasTriggered = jasmine.JQuery.events.wasTriggered(selector, this.actual)
|
553
|
-
|
554
|
-
this.message = function () {
|
555
|
-
if (wasTriggered) {
|
556
|
-
var actualArgs = jasmine.JQuery.events.args(selector, this.actual, expectedArgs)[1]
|
557
|
-
return [
|
558
|
-
"Expected event " + this.actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs),
|
559
|
-
"Expected event " + this.actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs)
|
560
|
-
]
|
561
|
-
} else {
|
562
|
-
return [
|
563
|
-
"Expected event " + this.actual + " to have been triggered on " + selector,
|
564
|
-
"Expected event " + this.actual + " not to have been triggered on " + selector
|
565
|
-
]
|
566
|
-
}
|
567
|
-
}
|
568
|
-
|
569
|
-
return wasTriggered && jasmine.JQuery.events.wasTriggeredWith(selector, this.actual, expectedArgs, this.env)
|
570
|
-
}
|
571
|
-
})
|
572
|
-
this.addMatchers({
|
573
|
-
toHaveBeenPreventedOn: function (selector) {
|
574
|
-
this.message = function () {
|
575
|
-
return [
|
576
|
-
"Expected event " + this.actual + " to have been prevented on " + selector,
|
577
|
-
"Expected event " + this.actual + " not to have been prevented on " + selector
|
578
|
-
]
|
683
|
+
return result
|
684
|
+
}
|
579
685
|
}
|
686
|
+
},
|
580
687
|
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
toHaveBeenPrevented: function () {
|
586
|
-
var eventName = this.actual.eventName
|
587
|
-
, selector = this.actual.selector
|
588
|
-
this.message = function () {
|
589
|
-
return [
|
590
|
-
"Expected event " + eventName + " to have been prevented on " + selector,
|
591
|
-
"Expected event " + eventName + " not to have been prevented on " + selector
|
592
|
-
]
|
593
|
-
}
|
688
|
+
toHaveBeenStoppedOn: function () {
|
689
|
+
return {
|
690
|
+
compare: function (actual, selector) {
|
691
|
+
var result = { pass: jasmine.jQuery.events.wasStopped(selector, actual) }
|
594
692
|
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
return [
|
602
|
-
"Expected event " + this.actual + " to have been stopped on " + selector,
|
603
|
-
"Expected event " + this.actual + " not to have been stopped on " + selector
|
604
|
-
]
|
693
|
+
result.message = result.pass ?
|
694
|
+
"Expected event " + actual + " not to have been stopped on " + selector :
|
695
|
+
"Expected event " + actual + " to have been stopped on " + selector
|
696
|
+
|
697
|
+
return result;
|
698
|
+
}
|
605
699
|
}
|
700
|
+
},
|
606
701
|
|
607
|
-
return jasmine.JQuery.events.wasStopped(selector, this.actual)
|
608
|
-
}
|
609
|
-
})
|
610
|
-
this.addMatchers({
|
611
702
|
toHaveBeenStopped: function () {
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
if(a instanceof jQuery && b instanceof jQuery) {
|
625
|
-
if(a.size() != b.size()) {
|
626
|
-
return jasmine.undefined
|
627
|
-
}
|
628
|
-
else if(a.is(b)) {
|
629
|
-
return true
|
703
|
+
return {
|
704
|
+
compare: function (actual) {
|
705
|
+
var eventName = actual.eventName
|
706
|
+
, selector = actual.selector
|
707
|
+
, result = { pass: jasmine.jQuery.events.wasStopped(selector, eventName) }
|
708
|
+
|
709
|
+
result.message = result.pass ?
|
710
|
+
"Expected event " + eventName + " not to have been stopped on " + selector :
|
711
|
+
"Expected event " + eventName + " to have been stopped on " + selector
|
712
|
+
|
713
|
+
return result
|
714
|
+
}
|
630
715
|
}
|
631
716
|
}
|
717
|
+
})
|
718
|
+
|
719
|
+
jasmine.getEnv().addCustomEqualityTester(function(a, b) {
|
720
|
+
if (a && b) {
|
721
|
+
if (a instanceof $ || jasmine.isDomNode(a)) {
|
722
|
+
var $a = $(a)
|
723
|
+
|
724
|
+
if (b instanceof $)
|
725
|
+
return $a.length == b.length && a.is(b)
|
726
|
+
|
727
|
+
return $a.is(b);
|
728
|
+
}
|
729
|
+
|
730
|
+
if (b instanceof $ || jasmine.isDomNode(b)) {
|
731
|
+
var $b = $(b)
|
632
732
|
|
633
|
-
|
733
|
+
if (a instanceof jQuery)
|
734
|
+
return a.length == $b.length && $b.is(a)
|
735
|
+
|
736
|
+
return $(b).is(a);
|
737
|
+
}
|
738
|
+
}
|
739
|
+
})
|
740
|
+
|
741
|
+
jasmine.getEnv().addCustomEqualityTester(function (a, b) {
|
742
|
+
if (a instanceof jQuery && b instanceof jQuery && a.size() == b.size())
|
743
|
+
return a.is(b)
|
634
744
|
})
|
635
745
|
})
|
636
746
|
|
637
747
|
afterEach(function () {
|
638
748
|
jasmine.getFixtures().cleanUp()
|
639
749
|
jasmine.getStyleFixtures().cleanUp()
|
640
|
-
jasmine.
|
750
|
+
jasmine.jQuery.events.cleanUp()
|
641
751
|
})
|
642
|
-
}(window.jasmine, window.jQuery)
|
643
752
|
|
644
|
-
|
645
|
-
|
646
|
-
global.readFixtures = function () {
|
753
|
+
window.readFixtures = function () {
|
647
754
|
return jasmine.getFixtures().proxyCallTo_('read', arguments)
|
648
755
|
}
|
649
756
|
|
650
|
-
|
757
|
+
window.preloadFixtures = function () {
|
651
758
|
jasmine.getFixtures().proxyCallTo_('preload', arguments)
|
652
759
|
}
|
653
760
|
|
654
|
-
|
761
|
+
window.loadFixtures = function () {
|
655
762
|
jasmine.getFixtures().proxyCallTo_('load', arguments)
|
656
763
|
}
|
657
764
|
|
658
|
-
|
765
|
+
window.appendLoadFixtures = function () {
|
659
766
|
jasmine.getFixtures().proxyCallTo_('appendLoad', arguments)
|
660
767
|
}
|
661
768
|
|
662
|
-
|
769
|
+
window.setFixtures = function (html) {
|
663
770
|
return jasmine.getFixtures().proxyCallTo_('set', arguments)
|
664
771
|
}
|
665
772
|
|
666
|
-
|
773
|
+
window.appendSetFixtures = function () {
|
667
774
|
jasmine.getFixtures().proxyCallTo_('appendSet', arguments)
|
668
775
|
}
|
669
776
|
|
670
|
-
|
777
|
+
window.sandbox = function (attributes) {
|
671
778
|
return jasmine.getFixtures().sandbox(attributes)
|
672
779
|
}
|
673
780
|
|
674
|
-
|
675
|
-
return jasmine.
|
781
|
+
window.spyOnEvent = function (selector, eventName) {
|
782
|
+
return jasmine.jQuery.events.spyOn(selector, eventName)
|
676
783
|
}
|
677
784
|
|
678
|
-
|
785
|
+
window.preloadStyleFixtures = function () {
|
679
786
|
jasmine.getStyleFixtures().proxyCallTo_('preload', arguments)
|
680
787
|
}
|
681
788
|
|
682
|
-
|
789
|
+
window.loadStyleFixtures = function () {
|
683
790
|
jasmine.getStyleFixtures().proxyCallTo_('load', arguments)
|
684
791
|
}
|
685
792
|
|
686
|
-
|
793
|
+
window.appendLoadStyleFixtures = function () {
|
687
794
|
jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments)
|
688
795
|
}
|
689
796
|
|
690
|
-
|
797
|
+
window.setStyleFixtures = function (html) {
|
691
798
|
jasmine.getStyleFixtures().proxyCallTo_('set', arguments)
|
692
799
|
}
|
693
800
|
|
694
|
-
|
801
|
+
window.appendSetStyleFixtures = function (html) {
|
695
802
|
jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments)
|
696
803
|
}
|
697
804
|
|
698
|
-
|
805
|
+
window.loadJSONFixtures = function () {
|
699
806
|
return jasmine.getJSONFixtures().proxyCallTo_('load', arguments)
|
700
807
|
}
|
701
808
|
|
702
|
-
|
809
|
+
window.getJSONFixture = function (url) {
|
703
810
|
return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url]
|
704
811
|
}
|
705
|
-
}(jasmine, window);
|
812
|
+
}(window, window.jasmine, window.jQuery);
|
813
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jasmine-jquery-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Jeffery
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|