jasmine-core 3.6.0 → 3.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jasmine-core/boot.js +1 -1
- data/lib/jasmine-core/jasmine-html.js +26 -9
- data/lib/jasmine-core/jasmine.js +824 -316
- data/lib/jasmine-core/node_boot.js +1 -1
- data/lib/jasmine-core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0633e3d3e468f779220b229062eae61754bc886788981cadb4ac571ca61f09e
|
4
|
+
data.tar.gz: c738ae0489e9b35212f228b0c81674ef19544338b39ca0fa86f09977d04c61ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce627b117c79117d1c83b17411291022310e5d15eeec55a99eb90663397a21657d64361c7a8384bf6a3909c7bef5961d25344f0d66467be1fa267ad74aa1421e
|
7
|
+
data.tar.gz: 492b3ce3d974d9ce732fbf799e2b6c8eee5c98466b5c9656d910e6df5f4ad2a225b206a9d14b400abc8749a6ebaffaf6f4f77b80d9df9e96f211bf1b14bfb6e3
|
data/lib/jasmine-core/boot.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
Copyright (c) 2008-
|
2
|
+
Copyright (c) 2008-2021 Pivotal Labs
|
3
3
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
a copy of this software and associated documentation files (the
|
@@ -132,7 +132,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|
132
132
|
if (result.status === 'failed') {
|
133
133
|
failures.push(failureDom(result));
|
134
134
|
}
|
135
|
-
addDeprecationWarnings(result);
|
135
|
+
addDeprecationWarnings(result, 'suite');
|
136
136
|
};
|
137
137
|
|
138
138
|
this.specStarted = function(result) {
|
@@ -168,7 +168,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|
168
168
|
failures.push(failureDom(result));
|
169
169
|
}
|
170
170
|
|
171
|
-
addDeprecationWarnings(result);
|
171
|
+
addDeprecationWarnings(result, 'spec');
|
172
172
|
};
|
173
173
|
|
174
174
|
this.displaySpecInCorrectFormat = function(result) {
|
@@ -307,14 +307,27 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|
307
307
|
|
308
308
|
addDeprecationWarnings(doneResult);
|
309
309
|
|
310
|
-
var warningBarClassName = 'jasmine-bar jasmine-warning';
|
311
310
|
for (i = 0; i < deprecationWarnings.length; i++) {
|
312
|
-
var
|
311
|
+
var context;
|
312
|
+
|
313
|
+
switch (deprecationWarnings[i].runnableType) {
|
314
|
+
case 'spec':
|
315
|
+
context = '(in spec: ' + deprecationWarnings[i].runnableName + ')';
|
316
|
+
break;
|
317
|
+
case 'suite':
|
318
|
+
context = '(in suite: ' + deprecationWarnings[i].runnableName + ')';
|
319
|
+
break;
|
320
|
+
default:
|
321
|
+
context = '';
|
322
|
+
}
|
323
|
+
|
313
324
|
alert.appendChild(
|
314
325
|
createDom(
|
315
326
|
'span',
|
316
|
-
{ className:
|
317
|
-
'DEPRECATION: ' +
|
327
|
+
{ className: 'jasmine-bar jasmine-warning' },
|
328
|
+
'DEPRECATION: ' + deprecationWarnings[i].message,
|
329
|
+
createDom('br'),
|
330
|
+
context
|
318
331
|
)
|
319
332
|
);
|
320
333
|
}
|
@@ -625,12 +638,16 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|
625
638
|
return addToExistingQueryString('spec', els.join(' '));
|
626
639
|
}
|
627
640
|
|
628
|
-
function addDeprecationWarnings(result) {
|
641
|
+
function addDeprecationWarnings(result, runnableType) {
|
629
642
|
if (result && result.deprecationWarnings) {
|
630
643
|
for (var i = 0; i < result.deprecationWarnings.length; i++) {
|
631
644
|
var warning = result.deprecationWarnings[i].message;
|
632
645
|
if (!j$.util.arrayContains(warning)) {
|
633
|
-
deprecationWarnings.push(
|
646
|
+
deprecationWarnings.push({
|
647
|
+
message: warning,
|
648
|
+
runnableName: result.fullName,
|
649
|
+
runnableType: runnableType
|
650
|
+
});
|
634
651
|
}
|
635
652
|
}
|
636
653
|
}
|
data/lib/jasmine-core/jasmine.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
Copyright (c) 2008-
|
2
|
+
Copyright (c) 2008-2021 Pivotal Labs
|
3
3
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
a copy of this software and associated documentation files (the
|
@@ -244,6 +244,10 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
244
244
|
return j$.isA_('AsyncFunction', value);
|
245
245
|
};
|
246
246
|
|
247
|
+
j$.isGeneratorFunction_ = function(value) {
|
248
|
+
return j$.isA_('GeneratorFunction', value);
|
249
|
+
};
|
250
|
+
|
247
251
|
j$.isTypedArray_ = function(value) {
|
248
252
|
return (
|
249
253
|
j$.isA_('Float32Array', value) ||
|
@@ -325,6 +329,15 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
325
329
|
);
|
326
330
|
};
|
327
331
|
|
332
|
+
j$.isURL = function(obj) {
|
333
|
+
return (
|
334
|
+
obj !== null &&
|
335
|
+
typeof obj !== 'undefined' &&
|
336
|
+
typeof jasmineGlobal.URL !== 'undefined' &&
|
337
|
+
obj.constructor === jasmineGlobal.URL
|
338
|
+
);
|
339
|
+
};
|
340
|
+
|
328
341
|
j$.isDataView = function(obj) {
|
329
342
|
return (
|
330
343
|
obj !== null &&
|
@@ -499,6 +512,14 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|
499
512
|
return new j$.SetContaining(sample);
|
500
513
|
};
|
501
514
|
|
515
|
+
/**
|
516
|
+
* Determines whether the provided function is a Jasmine spy.
|
517
|
+
* @name jasmine.isSpy
|
518
|
+
* @since 2.0.0
|
519
|
+
* @function
|
520
|
+
* @param {Function} putativeSpy - The function to check.
|
521
|
+
* @return {Boolean}
|
522
|
+
*/
|
502
523
|
j$.isSpy = function(putativeSpy) {
|
503
524
|
if (!putativeSpy) {
|
504
525
|
return false;
|
@@ -519,16 +540,6 @@ getJasmineRequireObj().util = function(j$) {
|
|
519
540
|
childClass.prototype = new Subclass();
|
520
541
|
};
|
521
542
|
|
522
|
-
util.htmlEscape = function(str) {
|
523
|
-
if (!str) {
|
524
|
-
return str;
|
525
|
-
}
|
526
|
-
return str
|
527
|
-
.replace(/&/g, '&')
|
528
|
-
.replace(/</g, '<')
|
529
|
-
.replace(/>/g, '>');
|
530
|
-
};
|
531
|
-
|
532
543
|
util.argsToArray = function(args) {
|
533
544
|
var arrayOfArgs = [];
|
534
545
|
for (var i = 0; i < args.length; i++) {
|
@@ -1376,6 +1387,9 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1376
1387
|
resources.customAsyncMatchers = j$.util.clone(
|
1377
1388
|
runnableResources[parentRunnableId].customAsyncMatchers
|
1378
1389
|
);
|
1390
|
+
resources.customObjectFormatters = j$.util.clone(
|
1391
|
+
runnableResources[parentRunnableId].customObjectFormatters
|
1392
|
+
);
|
1379
1393
|
resources.defaultStrategyFn =
|
1380
1394
|
runnableResources[parentRunnableId].defaultStrategyFn;
|
1381
1395
|
}
|
@@ -1533,12 +1547,22 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1533
1547
|
|
1534
1548
|
this.deprecated = function(deprecation) {
|
1535
1549
|
var runnable = currentRunnable() || topSuite;
|
1550
|
+
var context;
|
1551
|
+
|
1552
|
+
if (runnable === topSuite) {
|
1553
|
+
context = '';
|
1554
|
+
} else if (runnable === currentSuite()) {
|
1555
|
+
context = ' (in suite: ' + runnable.getFullName() + ')';
|
1556
|
+
} else {
|
1557
|
+
context = ' (in spec: ' + runnable.getFullName() + ')';
|
1558
|
+
}
|
1559
|
+
|
1536
1560
|
runnable.addDeprecationWarning(deprecation);
|
1537
1561
|
if (
|
1538
1562
|
typeof console !== 'undefined' &&
|
1539
1563
|
typeof console.error === 'function'
|
1540
1564
|
) {
|
1541
|
-
console.error('DEPRECATION:'
|
1565
|
+
console.error('DEPRECATION: ' + deprecation + context);
|
1542
1566
|
}
|
1543
1567
|
};
|
1544
1568
|
|
@@ -1657,7 +1681,8 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1657
1681
|
queueRunnerFactory
|
1658
1682
|
);
|
1659
1683
|
|
1660
|
-
|
1684
|
+
// Both params are optional.
|
1685
|
+
this.execute = function(runnablesToRun, onComplete) {
|
1661
1686
|
installGlobalErrors();
|
1662
1687
|
|
1663
1688
|
if (!runnablesToRun) {
|
@@ -1765,7 +1790,11 @@ getJasmineRequireObj().Env = function(j$) {
|
|
1765
1790
|
failedExpectations: topSuite.result.failedExpectations,
|
1766
1791
|
deprecationWarnings: topSuite.result.deprecationWarnings
|
1767
1792
|
},
|
1768
|
-
function() {
|
1793
|
+
function() {
|
1794
|
+
if (onComplete) {
|
1795
|
+
onComplete();
|
1796
|
+
}
|
1797
|
+
}
|
1769
1798
|
);
|
1770
1799
|
});
|
1771
1800
|
}
|
@@ -2350,12 +2379,11 @@ getJasmineRequireObj().JsApiReporter = function(j$) {
|
|
2350
2379
|
};
|
2351
2380
|
|
2352
2381
|
getJasmineRequireObj().Any = function(j$) {
|
2353
|
-
|
2354
2382
|
function Any(expectedObject) {
|
2355
2383
|
if (typeof expectedObject === 'undefined') {
|
2356
2384
|
throw new TypeError(
|
2357
2385
|
'jasmine.any() expects to be passed a constructor function. ' +
|
2358
|
-
|
2386
|
+
'Please pass one or use jasmine.anything() to match any object.'
|
2359
2387
|
);
|
2360
2388
|
}
|
2361
2389
|
this.expectedObject = expectedObject;
|
@@ -2400,7 +2428,6 @@ getJasmineRequireObj().Any = function(j$) {
|
|
2400
2428
|
};
|
2401
2429
|
|
2402
2430
|
getJasmineRequireObj().Anything = function(j$) {
|
2403
|
-
|
2404
2431
|
function Anything() {}
|
2405
2432
|
|
2406
2433
|
Anything.prototype.asymmetricMatch = function(other) {
|
@@ -2421,7 +2448,11 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
|
|
2421
2448
|
|
2422
2449
|
ArrayContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
|
2423
2450
|
if (!j$.isArray_(this.sample)) {
|
2424
|
-
throw new Error(
|
2451
|
+
throw new Error(
|
2452
|
+
'You must provide an array to arrayContaining, not ' +
|
2453
|
+
j$.pp(this.sample) +
|
2454
|
+
'.'
|
2455
|
+
);
|
2425
2456
|
}
|
2426
2457
|
|
2427
2458
|
// If the actual parameter is not an array, we can fail immediately, since it couldn't
|
@@ -2441,22 +2472,28 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
|
|
2441
2472
|
return true;
|
2442
2473
|
};
|
2443
2474
|
|
2444
|
-
ArrayContaining.prototype.jasmineToString = function
|
2445
|
-
return '<jasmine.arrayContaining(' + pp(this.sample) +')>';
|
2475
|
+
ArrayContaining.prototype.jasmineToString = function(pp) {
|
2476
|
+
return '<jasmine.arrayContaining(' + pp(this.sample) + ')>';
|
2446
2477
|
};
|
2447
2478
|
|
2448
2479
|
return ArrayContaining;
|
2449
2480
|
};
|
2450
2481
|
|
2451
2482
|
getJasmineRequireObj().ArrayWithExactContents = function(j$) {
|
2452
|
-
|
2453
2483
|
function ArrayWithExactContents(sample) {
|
2454
2484
|
this.sample = sample;
|
2455
2485
|
}
|
2456
2486
|
|
2457
|
-
ArrayWithExactContents.prototype.asymmetricMatch = function(
|
2487
|
+
ArrayWithExactContents.prototype.asymmetricMatch = function(
|
2488
|
+
other,
|
2489
|
+
matchersUtil
|
2490
|
+
) {
|
2458
2491
|
if (!j$.isArray_(this.sample)) {
|
2459
|
-
throw new Error(
|
2492
|
+
throw new Error(
|
2493
|
+
'You must provide an array to arrayWithExactContents, not ' +
|
2494
|
+
j$.pp(this.sample) +
|
2495
|
+
'.'
|
2496
|
+
);
|
2460
2497
|
}
|
2461
2498
|
|
2462
2499
|
if (this.sample.length !== other.length) {
|
@@ -2480,11 +2517,10 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$) {
|
|
2480
2517
|
return ArrayWithExactContents;
|
2481
2518
|
};
|
2482
2519
|
|
2483
|
-
getJasmineRequireObj().Empty = function
|
2484
|
-
|
2520
|
+
getJasmineRequireObj().Empty = function(j$) {
|
2485
2521
|
function Empty() {}
|
2486
2522
|
|
2487
|
-
Empty.prototype.asymmetricMatch = function
|
2523
|
+
Empty.prototype.asymmetricMatch = function(other) {
|
2488
2524
|
if (j$.isString_(other) || j$.isArray_(other) || j$.isTypedArray_(other)) {
|
2489
2525
|
return other.length === 0;
|
2490
2526
|
}
|
@@ -2499,7 +2535,7 @@ getJasmineRequireObj().Empty = function (j$) {
|
|
2499
2535
|
return false;
|
2500
2536
|
};
|
2501
2537
|
|
2502
|
-
Empty.prototype.jasmineToString = function
|
2538
|
+
Empty.prototype.jasmineToString = function() {
|
2503
2539
|
return '<jasmine.empty>';
|
2504
2540
|
};
|
2505
2541
|
|
@@ -2507,7 +2543,6 @@ getJasmineRequireObj().Empty = function (j$) {
|
|
2507
2543
|
};
|
2508
2544
|
|
2509
2545
|
getJasmineRequireObj().Falsy = function(j$) {
|
2510
|
-
|
2511
2546
|
function Falsy() {}
|
2512
2547
|
|
2513
2548
|
Falsy.prototype.asymmetricMatch = function(other) {
|
@@ -2524,7 +2559,9 @@ getJasmineRequireObj().Falsy = function(j$) {
|
|
2524
2559
|
getJasmineRequireObj().MapContaining = function(j$) {
|
2525
2560
|
function MapContaining(sample) {
|
2526
2561
|
if (!j$.isMap(sample)) {
|
2527
|
-
throw new Error(
|
2562
|
+
throw new Error(
|
2563
|
+
'You must provide a map to `mapContaining`, not ' + j$.pp(sample)
|
2564
|
+
);
|
2528
2565
|
}
|
2529
2566
|
|
2530
2567
|
this.sample = sample;
|
@@ -2540,8 +2577,8 @@ getJasmineRequireObj().MapContaining = function(j$) {
|
|
2540
2577
|
var hasMatch = false;
|
2541
2578
|
j$.util.forEachBreakable(other, function(oBreakLoop, oValue, oKey) {
|
2542
2579
|
if (
|
2543
|
-
matchersUtil.equals(oKey, key)
|
2544
|
-
|
2580
|
+
matchersUtil.equals(oKey, key) &&
|
2581
|
+
matchersUtil.equals(oValue, value)
|
2545
2582
|
) {
|
2546
2583
|
hasMatch = true;
|
2547
2584
|
oBreakLoop();
|
@@ -2563,11 +2600,10 @@ getJasmineRequireObj().MapContaining = function(j$) {
|
|
2563
2600
|
return MapContaining;
|
2564
2601
|
};
|
2565
2602
|
|
2566
|
-
getJasmineRequireObj().NotEmpty = function
|
2567
|
-
|
2603
|
+
getJasmineRequireObj().NotEmpty = function(j$) {
|
2568
2604
|
function NotEmpty() {}
|
2569
2605
|
|
2570
|
-
NotEmpty.prototype.asymmetricMatch = function
|
2606
|
+
NotEmpty.prototype.asymmetricMatch = function(other) {
|
2571
2607
|
if (j$.isString_(other) || j$.isArray_(other) || j$.isTypedArray_(other)) {
|
2572
2608
|
return other.length !== 0;
|
2573
2609
|
}
|
@@ -2583,7 +2619,7 @@ getJasmineRequireObj().NotEmpty = function (j$) {
|
|
2583
2619
|
return false;
|
2584
2620
|
};
|
2585
2621
|
|
2586
|
-
NotEmpty.prototype.jasmineToString = function
|
2622
|
+
NotEmpty.prototype.jasmineToString = function() {
|
2587
2623
|
return '<jasmine.notEmpty>';
|
2588
2624
|
};
|
2589
2625
|
|
@@ -2591,7 +2627,6 @@ getJasmineRequireObj().NotEmpty = function (j$) {
|
|
2591
2627
|
};
|
2592
2628
|
|
2593
2629
|
getJasmineRequireObj().ObjectContaining = function(j$) {
|
2594
|
-
|
2595
2630
|
function ObjectContaining(sample) {
|
2596
2631
|
this.sample = sample;
|
2597
2632
|
}
|
@@ -2609,7 +2644,7 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
|
|
2609
2644
|
}
|
2610
2645
|
|
2611
2646
|
function hasProperty(obj, property) {
|
2612
|
-
if (!obj || typeof
|
2647
|
+
if (!obj || typeof obj !== 'object') {
|
2613
2648
|
return false;
|
2614
2649
|
}
|
2615
2650
|
|
@@ -2621,12 +2656,22 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
|
|
2621
2656
|
}
|
2622
2657
|
|
2623
2658
|
ObjectContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
|
2624
|
-
if (typeof
|
2625
|
-
|
2659
|
+
if (typeof this.sample !== 'object') {
|
2660
|
+
throw new Error(
|
2661
|
+
"You must provide an object to objectContaining, not '" +
|
2662
|
+
this.sample +
|
2663
|
+
"'."
|
2664
|
+
);
|
2665
|
+
}
|
2666
|
+
if (typeof other !== 'object') {
|
2667
|
+
return false;
|
2668
|
+
}
|
2626
2669
|
|
2627
2670
|
for (var property in this.sample) {
|
2628
|
-
if (
|
2629
|
-
|
2671
|
+
if (
|
2672
|
+
!hasProperty(other, property) ||
|
2673
|
+
!matchersUtil.equals(this.sample[property], other[property])
|
2674
|
+
) {
|
2630
2675
|
return false;
|
2631
2676
|
}
|
2632
2677
|
}
|
@@ -2643,7 +2688,7 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
|
|
2643
2688
|
}
|
2644
2689
|
|
2645
2690
|
var filteredOther = {};
|
2646
|
-
Object.keys(this.sample).forEach(function
|
2691
|
+
Object.keys(this.sample).forEach(function(k) {
|
2647
2692
|
// eq short-circuits comparison of objects that have different key sets,
|
2648
2693
|
// so include all keys even if undefined.
|
2649
2694
|
filteredOther[k] = other[k];
|
@@ -2665,7 +2710,9 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
|
|
2665
2710
|
getJasmineRequireObj().SetContaining = function(j$) {
|
2666
2711
|
function SetContaining(sample) {
|
2667
2712
|
if (!j$.isSet(sample)) {
|
2668
|
-
throw new Error(
|
2713
|
+
throw new Error(
|
2714
|
+
'You must provide a set to `setContaining`, not ' + j$.pp(sample)
|
2715
|
+
);
|
2669
2716
|
}
|
2670
2717
|
|
2671
2718
|
this.sample = sample;
|
@@ -2703,7 +2750,6 @@ getJasmineRequireObj().SetContaining = function(j$) {
|
|
2703
2750
|
};
|
2704
2751
|
|
2705
2752
|
getJasmineRequireObj().StringMatching = function(j$) {
|
2706
|
-
|
2707
2753
|
function StringMatching(expected) {
|
2708
2754
|
if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) {
|
2709
2755
|
throw new Error('Expected is not a String or a RegExp');
|
@@ -2724,7 +2770,6 @@ getJasmineRequireObj().StringMatching = function(j$) {
|
|
2724
2770
|
};
|
2725
2771
|
|
2726
2772
|
getJasmineRequireObj().Truthy = function(j$) {
|
2727
|
-
|
2728
2773
|
function Truthy() {}
|
2729
2774
|
|
2730
2775
|
Truthy.prototype.asymmetricMatch = function(other) {
|
@@ -2806,7 +2851,9 @@ getJasmineRequireObj().asymmetricEqualityTesterArgCompatShim = function(j$) {
|
|
2806
2851
|
|
2807
2852
|
for (i = 0; i < props.length; i++) {
|
2808
2853
|
k = props[i];
|
2809
|
-
|
2854
|
+
// Skip length (dealt with above), and anything that collides with
|
2855
|
+
// MatchesUtil e.g. an Array.prototype.contains method added by user code
|
2856
|
+
if (k !== 'length' && !self[k]) {
|
2810
2857
|
copy(self, Array.prototype, k);
|
2811
2858
|
}
|
2812
2859
|
}
|
@@ -3522,7 +3569,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
|
3522
3569
|
stackTrace.style === 'webkit' ? '<Jasmine>' : ' at <Jasmine>';
|
3523
3570
|
|
3524
3571
|
stackTrace.frames.forEach(function(frame) {
|
3525
|
-
if (frame.file
|
3572
|
+
if (frame.file !== jasmineFile) {
|
3526
3573
|
result.push(frame.raw);
|
3527
3574
|
} else if (result[result.length - 1] !== jasmineMarker) {
|
3528
3575
|
result.push(jasmineMarker);
|
@@ -4077,9 +4124,9 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
|
|
4077
4124
|
if (j$.isError_(event.reason)) {
|
4078
4125
|
event.reason.jasmineMessage =
|
4079
4126
|
'Unhandled promise rejection: ' + event.reason;
|
4080
|
-
onerror(event.reason);
|
4127
|
+
global.onerror(event.reason);
|
4081
4128
|
} else {
|
4082
|
-
onerror('Unhandled promise rejection: ' + event.reason);
|
4129
|
+
global.onerror('Unhandled promise rejection: ' + event.reason);
|
4083
4130
|
}
|
4084
4131
|
};
|
4085
4132
|
|
@@ -4106,7 +4153,11 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
|
|
4106
4153
|
handlers.push(listener);
|
4107
4154
|
};
|
4108
4155
|
|
4109
|
-
this.popListener = function popListener() {
|
4156
|
+
this.popListener = function popListener(listener) {
|
4157
|
+
if (!listener) {
|
4158
|
+
throw new Error('popListener expects a listener');
|
4159
|
+
}
|
4160
|
+
|
4110
4161
|
handlers.pop();
|
4111
4162
|
};
|
4112
4163
|
}
|
@@ -4117,7 +4168,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
|
|
4117
4168
|
/* eslint-disable compat/compat */
|
4118
4169
|
getJasmineRequireObj().toBePending = function(j$) {
|
4119
4170
|
/**
|
4120
|
-
* Expect a promise to be pending,
|
4171
|
+
* Expect a promise to be pending, i.e. the promise is neither resolved nor rejected.
|
4121
4172
|
* @function
|
4122
4173
|
* @async
|
4123
4174
|
* @name async-matchers#toBePending
|
@@ -4133,8 +4184,12 @@ getJasmineRequireObj().toBePending = function(j$) {
|
|
4133
4184
|
}
|
4134
4185
|
var want = {};
|
4135
4186
|
return Promise.race([actual, Promise.resolve(want)]).then(
|
4136
|
-
function(got) {
|
4137
|
-
|
4187
|
+
function(got) {
|
4188
|
+
return { pass: want === got };
|
4189
|
+
},
|
4190
|
+
function() {
|
4191
|
+
return { pass: false };
|
4192
|
+
}
|
4138
4193
|
);
|
4139
4194
|
}
|
4140
4195
|
};
|
@@ -4160,8 +4215,12 @@ getJasmineRequireObj().toBeRejected = function(j$) {
|
|
4160
4215
|
throw new Error('Expected toBeRejected to be called on a promise.');
|
4161
4216
|
}
|
4162
4217
|
return actual.then(
|
4163
|
-
function() {
|
4164
|
-
|
4218
|
+
function() {
|
4219
|
+
return { pass: false };
|
4220
|
+
},
|
4221
|
+
function() {
|
4222
|
+
return { pass: true };
|
4223
|
+
}
|
4165
4224
|
);
|
4166
4225
|
}
|
4167
4226
|
};
|
@@ -4185,35 +4244,44 @@ getJasmineRequireObj().toBeRejectedWith = function(j$) {
|
|
4185
4244
|
return {
|
4186
4245
|
compare: function(actualPromise, expectedValue) {
|
4187
4246
|
if (!j$.isPromiseLike(actualPromise)) {
|
4188
|
-
throw new Error(
|
4247
|
+
throw new Error(
|
4248
|
+
'Expected toBeRejectedWith to be called on a promise.'
|
4249
|
+
);
|
4189
4250
|
}
|
4190
4251
|
|
4191
4252
|
function prefix(passed) {
|
4192
|
-
return
|
4253
|
+
return (
|
4254
|
+
'Expected a promise ' +
|
4193
4255
|
(passed ? 'not ' : '') +
|
4194
|
-
'to be rejected with ' +
|
4256
|
+
'to be rejected with ' +
|
4257
|
+
matchersUtil.pp(expectedValue)
|
4258
|
+
);
|
4195
4259
|
}
|
4196
4260
|
|
4197
4261
|
return actualPromise.then(
|
4198
4262
|
function() {
|
4199
|
-
return {
|
4200
|
-
pass: false,
|
4201
|
-
message: prefix(false) + ' but it was resolved.'
|
4202
|
-
};
|
4203
|
-
},
|
4204
|
-
function(actualValue) {
|
4205
|
-
if (matchersUtil.equals(actualValue, expectedValue)) {
|
4206
|
-
return {
|
4207
|
-
pass: true,
|
4208
|
-
message: prefix(true) + '.'
|
4209
|
-
};
|
4210
|
-
} else {
|
4211
4263
|
return {
|
4212
4264
|
pass: false,
|
4213
|
-
message: prefix(false) + ' but it was
|
4265
|
+
message: prefix(false) + ' but it was resolved.'
|
4214
4266
|
};
|
4267
|
+
},
|
4268
|
+
function(actualValue) {
|
4269
|
+
if (matchersUtil.equals(actualValue, expectedValue)) {
|
4270
|
+
return {
|
4271
|
+
pass: true,
|
4272
|
+
message: prefix(true) + '.'
|
4273
|
+
};
|
4274
|
+
} else {
|
4275
|
+
return {
|
4276
|
+
pass: false,
|
4277
|
+
message:
|
4278
|
+
prefix(false) +
|
4279
|
+
' but it was rejected with ' +
|
4280
|
+
matchersUtil.pp(actualValue) +
|
4281
|
+
'.'
|
4282
|
+
};
|
4283
|
+
}
|
4215
4284
|
}
|
4216
|
-
}
|
4217
4285
|
);
|
4218
4286
|
}
|
4219
4287
|
};
|
@@ -4240,7 +4308,9 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
|
|
4240
4308
|
return {
|
4241
4309
|
compare: function(actualPromise, arg1, arg2) {
|
4242
4310
|
if (!j$.isPromiseLike(actualPromise)) {
|
4243
|
-
throw new Error(
|
4311
|
+
throw new Error(
|
4312
|
+
'Expected toBeRejectedWithError to be called on a promise.'
|
4313
|
+
);
|
4244
4314
|
}
|
4245
4315
|
|
4246
4316
|
var expected = getExpectedFromArgs(arg1, arg2, matchersUtil);
|
@@ -4252,7 +4322,9 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
|
|
4252
4322
|
message: 'Expected a promise to be rejected but it was resolved.'
|
4253
4323
|
};
|
4254
4324
|
},
|
4255
|
-
function(actualValue) {
|
4325
|
+
function(actualValue) {
|
4326
|
+
return matchError(actualValue, expected, matchersUtil);
|
4327
|
+
}
|
4256
4328
|
);
|
4257
4329
|
}
|
4258
4330
|
};
|
@@ -4264,16 +4336,25 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
|
|
4264
4336
|
}
|
4265
4337
|
|
4266
4338
|
if (!(actual instanceof expected.error)) {
|
4267
|
-
return fail(
|
4339
|
+
return fail(
|
4340
|
+
expected,
|
4341
|
+
'rejected with type ' + j$.fnNameFor(actual.constructor)
|
4342
|
+
);
|
4268
4343
|
}
|
4269
4344
|
|
4270
4345
|
var actualMessage = actual.message;
|
4271
4346
|
|
4272
|
-
if (
|
4347
|
+
if (
|
4348
|
+
actualMessage === expected.message ||
|
4349
|
+
typeof expected.message === 'undefined'
|
4350
|
+
) {
|
4273
4351
|
return pass(expected);
|
4274
4352
|
}
|
4275
4353
|
|
4276
|
-
if (
|
4354
|
+
if (
|
4355
|
+
expected.message instanceof RegExp &&
|
4356
|
+
expected.message.test(actualMessage)
|
4357
|
+
) {
|
4277
4358
|
return pass(expected);
|
4278
4359
|
}
|
4279
4360
|
|
@@ -4283,18 +4364,25 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
|
|
4283
4364
|
function pass(expected) {
|
4284
4365
|
return {
|
4285
4366
|
pass: true,
|
4286
|
-
message:
|
4367
|
+
message:
|
4368
|
+
'Expected a promise not to be rejected with ' +
|
4369
|
+
expected.printValue +
|
4370
|
+
', but it was.'
|
4287
4371
|
};
|
4288
4372
|
}
|
4289
4373
|
|
4290
4374
|
function fail(expected, message) {
|
4291
4375
|
return {
|
4292
4376
|
pass: false,
|
4293
|
-
message:
|
4377
|
+
message:
|
4378
|
+
'Expected a promise to be rejected with ' +
|
4379
|
+
expected.printValue +
|
4380
|
+
' but it was ' +
|
4381
|
+
message +
|
4382
|
+
'.'
|
4294
4383
|
};
|
4295
4384
|
}
|
4296
4385
|
|
4297
|
-
|
4298
4386
|
function getExpectedFromArgs(arg1, arg2, matchersUtil) {
|
4299
4387
|
var error, message;
|
4300
4388
|
|
@@ -4309,12 +4397,17 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
|
|
4309
4397
|
return {
|
4310
4398
|
error: error,
|
4311
4399
|
message: message,
|
4312
|
-
printValue:
|
4400
|
+
printValue:
|
4401
|
+
j$.fnNameFor(error) +
|
4402
|
+
(typeof message === 'undefined' ? '' : ': ' + matchersUtil.pp(message))
|
4313
4403
|
};
|
4314
4404
|
}
|
4315
4405
|
|
4316
4406
|
function isErrorConstructor(value) {
|
4317
|
-
return
|
4407
|
+
return (
|
4408
|
+
typeof value === 'function' &&
|
4409
|
+
(value === Error || j$.isError_(value.prototype))
|
4410
|
+
);
|
4318
4411
|
}
|
4319
4412
|
};
|
4320
4413
|
|
@@ -4338,8 +4431,12 @@ getJasmineRequireObj().toBeResolved = function(j$) {
|
|
4338
4431
|
}
|
4339
4432
|
|
4340
4433
|
return actual.then(
|
4341
|
-
function() {
|
4342
|
-
|
4434
|
+
function() {
|
4435
|
+
return { pass: true };
|
4436
|
+
},
|
4437
|
+
function() {
|
4438
|
+
return { pass: false };
|
4439
|
+
}
|
4343
4440
|
);
|
4344
4441
|
}
|
4345
4442
|
};
|
@@ -4367,9 +4464,12 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
|
|
4367
4464
|
}
|
4368
4465
|
|
4369
4466
|
function prefix(passed) {
|
4370
|
-
return
|
4467
|
+
return (
|
4468
|
+
'Expected a promise ' +
|
4371
4469
|
(passed ? 'not ' : '') +
|
4372
|
-
'to be resolved to ' +
|
4470
|
+
'to be resolved to ' +
|
4471
|
+
matchersUtil.pp(expectedValue)
|
4472
|
+
);
|
4373
4473
|
}
|
4374
4474
|
|
4375
4475
|
return actualPromise.then(
|
@@ -4382,7 +4482,11 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
|
|
4382
4482
|
} else {
|
4383
4483
|
return {
|
4384
4484
|
pass: false,
|
4385
|
-
message:
|
4485
|
+
message:
|
4486
|
+
prefix(false) +
|
4487
|
+
' but it was resolved to ' +
|
4488
|
+
matchersUtil.pp(actualValue) +
|
4489
|
+
'.'
|
4386
4490
|
};
|
4387
4491
|
}
|
4388
4492
|
},
|
@@ -4398,7 +4502,7 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
|
|
4398
4502
|
};
|
4399
4503
|
};
|
4400
4504
|
|
4401
|
-
getJasmineRequireObj().DiffBuilder = function
|
4505
|
+
getJasmineRequireObj().DiffBuilder = function(j$) {
|
4402
4506
|
return function DiffBuilder(config) {
|
4403
4507
|
var prettyPrinter = (config || {}).prettyPrinter || j$.makePrettyPrinter(),
|
4404
4508
|
mismatches = new j$.MismatchTree(),
|
@@ -4407,21 +4511,28 @@ getJasmineRequireObj().DiffBuilder = function (j$) {
|
|
4407
4511
|
expectedRoot = undefined;
|
4408
4512
|
|
4409
4513
|
return {
|
4410
|
-
setRoots: function
|
4514
|
+
setRoots: function(actual, expected) {
|
4411
4515
|
actualRoot = actual;
|
4412
4516
|
expectedRoot = expected;
|
4413
4517
|
},
|
4414
4518
|
|
4415
|
-
recordMismatch: function
|
4519
|
+
recordMismatch: function(formatter) {
|
4416
4520
|
mismatches.add(path, formatter);
|
4417
4521
|
},
|
4418
4522
|
|
4419
|
-
getMessage: function
|
4523
|
+
getMessage: function() {
|
4420
4524
|
var messages = [];
|
4421
4525
|
|
4422
|
-
mismatches.traverse(function
|
4423
|
-
var actualCustom,
|
4424
|
-
|
4526
|
+
mismatches.traverse(function(path, isLeaf, formatter) {
|
4527
|
+
var actualCustom,
|
4528
|
+
expectedCustom,
|
4529
|
+
useCustom,
|
4530
|
+
derefResult = dereferencePath(
|
4531
|
+
path,
|
4532
|
+
actualRoot,
|
4533
|
+
expectedRoot,
|
4534
|
+
prettyPrinter
|
4535
|
+
),
|
4425
4536
|
actual = derefResult.actual,
|
4426
4537
|
expected = derefResult.expected;
|
4427
4538
|
|
@@ -4432,15 +4543,22 @@ getJasmineRequireObj().DiffBuilder = function (j$) {
|
|
4432
4543
|
|
4433
4544
|
actualCustom = prettyPrinter.customFormat_(actual);
|
4434
4545
|
expectedCustom = prettyPrinter.customFormat_(expected);
|
4435
|
-
useCustom = !(
|
4546
|
+
useCustom = !(
|
4547
|
+
j$.util.isUndefined(actualCustom) &&
|
4548
|
+
j$.util.isUndefined(expectedCustom)
|
4549
|
+
);
|
4436
4550
|
|
4437
4551
|
if (useCustom) {
|
4438
|
-
messages.push(
|
4552
|
+
messages.push(
|
4553
|
+
wrapPrettyPrinted(actualCustom, expectedCustom, path)
|
4554
|
+
);
|
4439
4555
|
return false; // don't recurse further
|
4440
4556
|
}
|
4441
4557
|
|
4442
4558
|
if (isLeaf) {
|
4443
|
-
messages.push(
|
4559
|
+
messages.push(
|
4560
|
+
defaultFormatter(actual, expected, path, prettyPrinter)
|
4561
|
+
);
|
4444
4562
|
}
|
4445
4563
|
|
4446
4564
|
return true;
|
@@ -4449,7 +4567,7 @@ getJasmineRequireObj().DiffBuilder = function (j$) {
|
|
4449
4567
|
return messages.join('\n');
|
4450
4568
|
},
|
4451
4569
|
|
4452
|
-
withPath: function
|
4570
|
+
withPath: function(pathComponent, block) {
|
4453
4571
|
var oldPath = path;
|
4454
4572
|
path = path.add(pathComponent);
|
4455
4573
|
block();
|
@@ -4458,22 +4576,32 @@ getJasmineRequireObj().DiffBuilder = function (j$) {
|
|
4458
4576
|
};
|
4459
4577
|
|
4460
4578
|
function defaultFormatter(actual, expected, path, prettyPrinter) {
|
4461
|
-
return wrapPrettyPrinted(
|
4579
|
+
return wrapPrettyPrinted(
|
4580
|
+
prettyPrinter(actual),
|
4581
|
+
prettyPrinter(expected),
|
4582
|
+
path
|
4583
|
+
);
|
4462
4584
|
}
|
4463
4585
|
|
4464
4586
|
function wrapPrettyPrinted(actual, expected, path) {
|
4465
|
-
return
|
4466
|
-
|
4587
|
+
return (
|
4588
|
+
'Expected ' +
|
4589
|
+
path +
|
4590
|
+
(path.depth() ? ' = ' : '') +
|
4467
4591
|
actual +
|
4468
4592
|
' to equal ' +
|
4469
4593
|
expected +
|
4470
|
-
'.'
|
4594
|
+
'.'
|
4595
|
+
);
|
4471
4596
|
}
|
4472
4597
|
};
|
4473
4598
|
|
4474
4599
|
function dereferencePath(objectPath, actual, expected, pp) {
|
4475
4600
|
function handleAsymmetricExpected() {
|
4476
|
-
if (
|
4601
|
+
if (
|
4602
|
+
j$.isAsymmetricEqualityTester_(expected) &&
|
4603
|
+
j$.isFunction_(expected.valuesForDiff_)
|
4604
|
+
) {
|
4477
4605
|
var asymmetricResult = expected.valuesForDiff_(actual, pp);
|
4478
4606
|
expected = asymmetricResult.self;
|
4479
4607
|
actual = asymmetricResult.other;
|
@@ -4489,9 +4617,8 @@ getJasmineRequireObj().DiffBuilder = function (j$) {
|
|
4489
4617
|
handleAsymmetricExpected();
|
4490
4618
|
}
|
4491
4619
|
|
4492
|
-
return {actual: actual, expected: expected};
|
4620
|
+
return { actual: actual, expected: expected };
|
4493
4621
|
}
|
4494
|
-
|
4495
4622
|
};
|
4496
4623
|
|
4497
4624
|
getJasmineRequireObj().MatchersUtil = function(j$) {
|
@@ -4517,7 +4644,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4517
4644
|
* @return {string} The pretty-printed value
|
4518
4645
|
*/
|
4519
4646
|
this.pp = options.pp || function() {};
|
4520
|
-
}
|
4647
|
+
}
|
4521
4648
|
|
4522
4649
|
/**
|
4523
4650
|
* Determines whether `haystack` contains `needle`, using the same comparison
|
@@ -4535,9 +4662,10 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4535
4662
|
return haystack.has(needle);
|
4536
4663
|
}
|
4537
4664
|
|
4538
|
-
if (
|
4539
|
-
(
|
4540
|
-
|
4665
|
+
if (
|
4666
|
+
Object.prototype.toString.apply(haystack) === '[object Array]' ||
|
4667
|
+
(!!haystack && !haystack.indexOf)
|
4668
|
+
) {
|
4541
4669
|
for (var i = 0; i < haystack.length; i++) {
|
4542
4670
|
if (this.equals(haystack[i], needle, customTesters)) {
|
4543
4671
|
return true;
|
@@ -4556,9 +4684,12 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4556
4684
|
isNot = args[1],
|
4557
4685
|
actual = args[2],
|
4558
4686
|
expected = args.slice(3),
|
4559
|
-
englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) {
|
4687
|
+
englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) {
|
4688
|
+
return ' ' + s.toLowerCase();
|
4689
|
+
});
|
4560
4690
|
|
4561
|
-
var message =
|
4691
|
+
var message =
|
4692
|
+
'Expected ' +
|
4562
4693
|
self.pp(actual) +
|
4563
4694
|
(isNot ? ' not ' : ' ') +
|
4564
4695
|
englishyPredicate;
|
@@ -4575,20 +4706,41 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4575
4706
|
return message + '.';
|
4576
4707
|
};
|
4577
4708
|
|
4578
|
-
MatchersUtil.prototype.asymmetricDiff_ = function(
|
4709
|
+
MatchersUtil.prototype.asymmetricDiff_ = function(
|
4710
|
+
a,
|
4711
|
+
b,
|
4712
|
+
aStack,
|
4713
|
+
bStack,
|
4714
|
+
customTesters,
|
4715
|
+
diffBuilder
|
4716
|
+
) {
|
4579
4717
|
if (j$.isFunction_(b.valuesForDiff_)) {
|
4580
4718
|
var values = b.valuesForDiff_(a, this.pp);
|
4581
|
-
this.eq_(
|
4719
|
+
this.eq_(
|
4720
|
+
values.other,
|
4721
|
+
values.self,
|
4722
|
+
aStack,
|
4723
|
+
bStack,
|
4724
|
+
customTesters,
|
4725
|
+
diffBuilder
|
4726
|
+
);
|
4582
4727
|
} else {
|
4583
4728
|
diffBuilder.recordMismatch();
|
4584
4729
|
}
|
4585
4730
|
};
|
4586
4731
|
|
4587
|
-
MatchersUtil.prototype.asymmetricMatch_ = function(
|
4732
|
+
MatchersUtil.prototype.asymmetricMatch_ = function(
|
4733
|
+
a,
|
4734
|
+
b,
|
4735
|
+
aStack,
|
4736
|
+
bStack,
|
4737
|
+
customTesters,
|
4738
|
+
diffBuilder
|
4739
|
+
) {
|
4588
4740
|
var asymmetricA = j$.isAsymmetricEqualityTester_(a),
|
4589
|
-
|
4590
|
-
|
4591
|
-
|
4741
|
+
asymmetricB = j$.isAsymmetricEqualityTester_(b),
|
4742
|
+
shim,
|
4743
|
+
result;
|
4592
4744
|
|
4593
4745
|
if (asymmetricA === asymmetricB) {
|
4594
4746
|
return undefined;
|
@@ -4623,7 +4775,12 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4623
4775
|
* @param [customTesters] An array of custom equality testers
|
4624
4776
|
* @returns {boolean} True if the values are equal
|
4625
4777
|
*/
|
4626
|
-
MatchersUtil.prototype.equals = function(
|
4778
|
+
MatchersUtil.prototype.equals = function(
|
4779
|
+
a,
|
4780
|
+
b,
|
4781
|
+
customTestersOrDiffBuilder,
|
4782
|
+
diffBuilderOrNothing
|
4783
|
+
) {
|
4627
4784
|
var customTesters, diffBuilder;
|
4628
4785
|
|
4629
4786
|
if (isDiffBuilder(customTestersOrDiffBuilder)) {
|
@@ -4642,10 +4799,26 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4642
4799
|
|
4643
4800
|
// Equality function lovingly adapted from isEqual in
|
4644
4801
|
// [Underscore](http://underscorejs.org)
|
4645
|
-
MatchersUtil.prototype.eq_ = function(
|
4646
|
-
|
4647
|
-
|
4648
|
-
|
4802
|
+
MatchersUtil.prototype.eq_ = function(
|
4803
|
+
a,
|
4804
|
+
b,
|
4805
|
+
aStack,
|
4806
|
+
bStack,
|
4807
|
+
customTesters,
|
4808
|
+
diffBuilder
|
4809
|
+
) {
|
4810
|
+
var result = true,
|
4811
|
+
self = this,
|
4812
|
+
i;
|
4813
|
+
|
4814
|
+
var asymmetricResult = this.asymmetricMatch_(
|
4815
|
+
a,
|
4816
|
+
b,
|
4817
|
+
aStack,
|
4818
|
+
bStack,
|
4819
|
+
customTesters,
|
4820
|
+
diffBuilder
|
4821
|
+
);
|
4649
4822
|
if (!j$.util.isUndefined(asymmetricResult)) {
|
4650
4823
|
return asymmetricResult;
|
4651
4824
|
}
|
@@ -4703,7 +4876,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4703
4876
|
case '[object Number]':
|
4704
4877
|
// `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
|
4705
4878
|
// other numeric values.
|
4706
|
-
result =
|
4879
|
+
result =
|
4880
|
+
a != +a ? b != +b : a === 0 && b === 0 ? 1 / a == 1 / b : a == +b;
|
4707
4881
|
if (!result) {
|
4708
4882
|
diffBuilder.recordMismatch();
|
4709
4883
|
}
|
@@ -4720,10 +4894,12 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4720
4894
|
return result;
|
4721
4895
|
// RegExps are compared by their source patterns and flags.
|
4722
4896
|
case '[object RegExp]':
|
4723
|
-
return
|
4897
|
+
return (
|
4898
|
+
a.source == b.source &&
|
4724
4899
|
a.global == b.global &&
|
4725
4900
|
a.multiline == b.multiline &&
|
4726
|
-
a.ignoreCase == b.ignoreCase
|
4901
|
+
a.ignoreCase == b.ignoreCase
|
4902
|
+
);
|
4727
4903
|
}
|
4728
4904
|
if (typeof a != 'object' || typeof b != 'object') {
|
4729
4905
|
diffBuilder.recordMismatch();
|
@@ -4757,7 +4933,9 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4757
4933
|
while (length--) {
|
4758
4934
|
// Linear search. Performance is inversely proportional to the number of
|
4759
4935
|
// unique nested structures.
|
4760
|
-
if (aStack[length] == a) {
|
4936
|
+
if (aStack[length] == a) {
|
4937
|
+
return bStack[length] == b;
|
4938
|
+
}
|
4761
4939
|
}
|
4762
4940
|
// Add the first object to the stack of traversed objects.
|
4763
4941
|
aStack.push(a);
|
@@ -4779,10 +4957,20 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4779
4957
|
for (i = 0; i < aLength || i < bLength; i++) {
|
4780
4958
|
diffBuilder.withPath(i, function() {
|
4781
4959
|
if (i >= bLength) {
|
4782
|
-
diffBuilder.recordMismatch(
|
4960
|
+
diffBuilder.recordMismatch(
|
4961
|
+
actualArrayIsLongerFormatter.bind(null, self.pp)
|
4962
|
+
);
|
4783
4963
|
result = false;
|
4784
4964
|
} else {
|
4785
|
-
result =
|
4965
|
+
result =
|
4966
|
+
self.eq_(
|
4967
|
+
i < aLength ? a[i] : void 0,
|
4968
|
+
i < bLength ? b[i] : void 0,
|
4969
|
+
aStack,
|
4970
|
+
bStack,
|
4971
|
+
customTesters,
|
4972
|
+
diffBuilder
|
4973
|
+
) && result;
|
4786
4974
|
}
|
4787
4975
|
});
|
4788
4976
|
}
|
@@ -4797,11 +4985,11 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4797
4985
|
|
4798
4986
|
var keysA = [];
|
4799
4987
|
var keysB = [];
|
4800
|
-
a.forEach(
|
4801
|
-
keysA.push(
|
4988
|
+
a.forEach(function(valueA, keyA) {
|
4989
|
+
keysA.push(keyA);
|
4802
4990
|
});
|
4803
|
-
b.forEach(
|
4804
|
-
keysB.push(
|
4991
|
+
b.forEach(function(valueB, keyB) {
|
4992
|
+
keysB.push(keyB);
|
4805
4993
|
});
|
4806
4994
|
|
4807
4995
|
// For both sets of keys, check they map to equal values in both maps.
|
@@ -4822,13 +5010,30 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4822
5010
|
// Only use the cmpKey when one of the keys is asymmetric and the corresponding key matches,
|
4823
5011
|
// otherwise explicitly look up the mapKey in the other Map since we want keys with unique
|
4824
5012
|
// obj identity (that are otherwise equal) to not match.
|
4825
|
-
if (
|
4826
|
-
|
5013
|
+
if (
|
5014
|
+
j$.isAsymmetricEqualityTester_(mapKey) ||
|
5015
|
+
(j$.isAsymmetricEqualityTester_(cmpKey) &&
|
5016
|
+
this.eq_(
|
5017
|
+
mapKey,
|
5018
|
+
cmpKey,
|
5019
|
+
aStack,
|
5020
|
+
bStack,
|
5021
|
+
customTesters,
|
5022
|
+
j$.NullDiffBuilder()
|
5023
|
+
))
|
5024
|
+
) {
|
4827
5025
|
mapValueB = b.get(cmpKey);
|
4828
5026
|
} else {
|
4829
5027
|
mapValueB = b.get(mapKey);
|
4830
5028
|
}
|
4831
|
-
result = this.eq_(
|
5029
|
+
result = this.eq_(
|
5030
|
+
mapValueA,
|
5031
|
+
mapValueB,
|
5032
|
+
aStack,
|
5033
|
+
bStack,
|
5034
|
+
customTesters,
|
5035
|
+
j$.NullDiffBuilder()
|
5036
|
+
);
|
4832
5037
|
}
|
4833
5038
|
}
|
4834
5039
|
|
@@ -4843,12 +5048,12 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4843
5048
|
}
|
4844
5049
|
|
4845
5050
|
var valuesA = [];
|
4846
|
-
a.forEach(
|
4847
|
-
valuesA.push(
|
5051
|
+
a.forEach(function(valueA) {
|
5052
|
+
valuesA.push(valueA);
|
4848
5053
|
});
|
4849
5054
|
var valuesB = [];
|
4850
|
-
b.forEach(
|
4851
|
-
valuesB.push(
|
5055
|
+
b.forEach(function(valueB) {
|
5056
|
+
valuesB.push(valueB);
|
4852
5057
|
});
|
4853
5058
|
|
4854
5059
|
// For both sets, check they are all contained in the other set
|
@@ -4872,7 +5077,14 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4872
5077
|
otherValue = otherValues[l];
|
4873
5078
|
prevStackSize = baseStack.length;
|
4874
5079
|
// compare by value equality
|
4875
|
-
found = this.eq_(
|
5080
|
+
found = this.eq_(
|
5081
|
+
baseValue,
|
5082
|
+
otherValue,
|
5083
|
+
baseStack,
|
5084
|
+
otherStack,
|
5085
|
+
customTesters,
|
5086
|
+
j$.NullDiffBuilder()
|
5087
|
+
);
|
4876
5088
|
if (!found && prevStackSize !== baseStack.length) {
|
4877
5089
|
baseStack.splice(prevStackSize);
|
4878
5090
|
otherStack.splice(prevStackSize);
|
@@ -4886,28 +5098,40 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4886
5098
|
diffBuilder.recordMismatch();
|
4887
5099
|
return false;
|
4888
5100
|
}
|
5101
|
+
} else if (j$.isURL(a) && j$.isURL(b)) {
|
5102
|
+
// URLs have no enumrable properties, so the default object comparison
|
5103
|
+
// would consider any two URLs to be equal.
|
5104
|
+
return a.toString() === b.toString();
|
4889
5105
|
} else {
|
4890
|
-
|
4891
5106
|
// Objects with different constructors are not equivalent, but `Object`s
|
4892
5107
|
// or `Array`s from different frames are.
|
4893
|
-
var aCtor = a.constructor,
|
4894
|
-
|
4895
|
-
|
4896
|
-
|
4897
|
-
|
4898
|
-
|
4899
|
-
|
5108
|
+
var aCtor = a.constructor,
|
5109
|
+
bCtor = b.constructor;
|
5110
|
+
if (
|
5111
|
+
aCtor !== bCtor &&
|
5112
|
+
isFunction(aCtor) &&
|
5113
|
+
isFunction(bCtor) &&
|
5114
|
+
a instanceof aCtor &&
|
5115
|
+
b instanceof bCtor &&
|
5116
|
+
!(aCtor instanceof aCtor && bCtor instanceof bCtor)
|
5117
|
+
) {
|
5118
|
+
diffBuilder.recordMismatch(
|
5119
|
+
constructorsAreDifferentFormatter.bind(null, this.pp)
|
5120
|
+
);
|
4900
5121
|
return false;
|
4901
5122
|
}
|
4902
5123
|
}
|
4903
5124
|
|
4904
5125
|
// Deep compare objects.
|
4905
|
-
var aKeys = keys(a, className == '[object Array]'),
|
5126
|
+
var aKeys = keys(a, className == '[object Array]'),
|
5127
|
+
key;
|
4906
5128
|
size = aKeys.length;
|
4907
5129
|
|
4908
5130
|
// Ensure that both objects contain the same number of properties before comparing deep equality.
|
4909
5131
|
if (keys(b, className == '[object Array]').length !== size) {
|
4910
|
-
diffBuilder.recordMismatch(
|
5132
|
+
diffBuilder.recordMismatch(
|
5133
|
+
objectKeysAreDifferentFormatter.bind(null, this.pp)
|
5134
|
+
);
|
4911
5135
|
return false;
|
4912
5136
|
}
|
4913
5137
|
|
@@ -4915,13 +5139,17 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4915
5139
|
key = aKeys[i];
|
4916
5140
|
// Deep compare each member
|
4917
5141
|
if (!j$.util.has(b, key)) {
|
4918
|
-
diffBuilder.recordMismatch(
|
5142
|
+
diffBuilder.recordMismatch(
|
5143
|
+
objectKeysAreDifferentFormatter.bind(null, this.pp)
|
5144
|
+
);
|
4919
5145
|
result = false;
|
4920
5146
|
continue;
|
4921
5147
|
}
|
4922
5148
|
|
4923
5149
|
diffBuilder.withPath(key, function() {
|
4924
|
-
if(
|
5150
|
+
if (
|
5151
|
+
!self.eq_(a[key], b[key], aStack, bStack, customTesters, diffBuilder)
|
5152
|
+
) {
|
4925
5153
|
result = false;
|
4926
5154
|
}
|
4927
5155
|
});
|
@@ -4939,23 +5167,24 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4939
5167
|
};
|
4940
5168
|
|
4941
5169
|
function keys(obj, isArray) {
|
4942
|
-
var allKeys = Object.keys
|
4943
|
-
(
|
5170
|
+
var allKeys = Object.keys
|
5171
|
+
? Object.keys(obj)
|
5172
|
+
: (function(o) {
|
4944
5173
|
var keys = [];
|
4945
5174
|
for (var key in o) {
|
4946
|
-
|
4947
|
-
|
4948
|
-
|
5175
|
+
if (j$.util.has(o, key)) {
|
5176
|
+
keys.push(key);
|
5177
|
+
}
|
4949
5178
|
}
|
4950
5179
|
return keys;
|
4951
|
-
|
5180
|
+
})(obj);
|
4952
5181
|
|
4953
5182
|
if (!isArray) {
|
4954
5183
|
return allKeys;
|
4955
5184
|
}
|
4956
5185
|
|
4957
5186
|
if (allKeys.length === 0) {
|
4958
|
-
|
5187
|
+
return allKeys;
|
4959
5188
|
}
|
4960
5189
|
|
4961
5190
|
var extraKeys = [];
|
@@ -4974,21 +5203,25 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4974
5203
|
|
4975
5204
|
function objectKeysAreDifferentFormatter(pp, actual, expected, path) {
|
4976
5205
|
var missingProperties = j$.util.objectDifference(expected, actual),
|
4977
|
-
|
4978
|
-
|
4979
|
-
|
4980
|
-
|
5206
|
+
extraProperties = j$.util.objectDifference(actual, expected),
|
5207
|
+
missingPropertiesMessage = formatKeyValuePairs(pp, missingProperties),
|
5208
|
+
extraPropertiesMessage = formatKeyValuePairs(pp, extraProperties),
|
5209
|
+
messages = [];
|
4981
5210
|
|
4982
5211
|
if (!path.depth()) {
|
4983
5212
|
path = 'object';
|
4984
5213
|
}
|
4985
5214
|
|
4986
5215
|
if (missingPropertiesMessage.length) {
|
4987
|
-
messages.push(
|
5216
|
+
messages.push(
|
5217
|
+
'Expected ' + path + ' to have properties' + missingPropertiesMessage
|
5218
|
+
);
|
4988
5219
|
}
|
4989
5220
|
|
4990
5221
|
if (extraPropertiesMessage.length) {
|
4991
|
-
messages.push(
|
5222
|
+
messages.push(
|
5223
|
+
'Expected ' + path + ' not to have properties' + extraPropertiesMessage
|
5224
|
+
);
|
4992
5225
|
}
|
4993
5226
|
|
4994
5227
|
return messages.join('\n');
|
@@ -4999,17 +5232,25 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
4999
5232
|
path = 'object';
|
5000
5233
|
}
|
5001
5234
|
|
5002
|
-
return
|
5003
|
-
|
5235
|
+
return (
|
5236
|
+
'Expected ' +
|
5237
|
+
path +
|
5238
|
+
' to be a kind of ' +
|
5004
5239
|
j$.fnNameFor(expected.constructor) +
|
5005
|
-
', but was ' +
|
5240
|
+
', but was ' +
|
5241
|
+
pp(actual) +
|
5242
|
+
'.'
|
5243
|
+
);
|
5006
5244
|
}
|
5007
5245
|
|
5008
5246
|
function actualArrayIsLongerFormatter(pp, actual, expected, path) {
|
5009
|
-
return
|
5010
|
-
|
5247
|
+
return (
|
5248
|
+
'Unexpected ' +
|
5249
|
+
path +
|
5250
|
+
(path.depth() ? ' = ' : '') +
|
5011
5251
|
pp(actual) +
|
5012
|
-
' in array.'
|
5252
|
+
' in array.'
|
5253
|
+
);
|
5013
5254
|
}
|
5014
5255
|
|
5015
5256
|
function formatKeyValuePairs(pp, obj) {
|
@@ -5027,8 +5268,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
|
5027
5268
|
return MatchersUtil;
|
5028
5269
|
};
|
5029
5270
|
|
5030
|
-
getJasmineRequireObj().MismatchTree = function
|
5031
|
-
|
5271
|
+
getJasmineRequireObj().MismatchTree = function(j$) {
|
5032
5272
|
/*
|
5033
5273
|
To be able to apply custom object formatters at all possible levels of an
|
5034
5274
|
object graph, DiffBuilder needs to be able to know not just where the
|
@@ -5043,7 +5283,7 @@ getJasmineRequireObj().MismatchTree = function (j$) {
|
|
5043
5283
|
this.isMismatch = false;
|
5044
5284
|
}
|
5045
5285
|
|
5046
|
-
MismatchTree.prototype.add = function
|
5286
|
+
MismatchTree.prototype.add = function(path, formatter) {
|
5047
5287
|
var key, child;
|
5048
5288
|
|
5049
5289
|
if (path.depth() === 0) {
|
@@ -5063,8 +5303,9 @@ getJasmineRequireObj().MismatchTree = function (j$) {
|
|
5063
5303
|
}
|
5064
5304
|
};
|
5065
5305
|
|
5066
|
-
MismatchTree.prototype.traverse = function
|
5067
|
-
var i,
|
5306
|
+
MismatchTree.prototype.traverse = function(visit) {
|
5307
|
+
var i,
|
5308
|
+
hasChildren = this.children.length > 0;
|
5068
5309
|
|
5069
5310
|
if (this.isMismatch || hasChildren) {
|
5070
5311
|
if (visit(this.path, !hasChildren, this.formatter)) {
|
@@ -5089,7 +5330,6 @@ getJasmineRequireObj().MismatchTree = function (j$) {
|
|
5089
5330
|
return MismatchTree;
|
5090
5331
|
};
|
5091
5332
|
|
5092
|
-
|
5093
5333
|
getJasmineRequireObj().nothing = function() {
|
5094
5334
|
/**
|
5095
5335
|
* {@link expect} nothing explicitly.
|
@@ -5158,7 +5398,7 @@ getJasmineRequireObj().ObjectPath = function(j$) {
|
|
5158
5398
|
return '.' + prop;
|
5159
5399
|
}
|
5160
5400
|
|
5161
|
-
return
|
5401
|
+
return "['" + prop + "']";
|
5162
5402
|
}
|
5163
5403
|
|
5164
5404
|
function map(array, fn) {
|
@@ -5206,7 +5446,8 @@ getJasmineRequireObj().toBe = function(j$) {
|
|
5206
5446
|
* expect(thing).toBe(realThing);
|
5207
5447
|
*/
|
5208
5448
|
function toBe(matchersUtil) {
|
5209
|
-
var tip =
|
5449
|
+
var tip =
|
5450
|
+
' Tip: To check for deep equality, use .toEqual() instead of .toBe().';
|
5210
5451
|
|
5211
5452
|
return {
|
5212
5453
|
compare: function(actual, expected) {
|
@@ -5215,7 +5456,13 @@ getJasmineRequireObj().toBe = function(j$) {
|
|
5215
5456
|
};
|
5216
5457
|
|
5217
5458
|
if (typeof expected === 'object') {
|
5218
|
-
result.message =
|
5459
|
+
result.message =
|
5460
|
+
matchersUtil.buildFailureMessage(
|
5461
|
+
'toBe',
|
5462
|
+
result.pass,
|
5463
|
+
actual,
|
5464
|
+
expected
|
5465
|
+
) + tip;
|
5219
5466
|
}
|
5220
5467
|
|
5221
5468
|
return result;
|
@@ -5245,8 +5492,13 @@ getJasmineRequireObj().toBeCloseTo = function() {
|
|
5245
5492
|
}
|
5246
5493
|
|
5247
5494
|
if (expected === null || actual === null) {
|
5248
|
-
throw new Error(
|
5249
|
-
'
|
5495
|
+
throw new Error(
|
5496
|
+
'Cannot use toBeCloseTo with null. Arguments evaluated to: ' +
|
5497
|
+
'expect(' +
|
5498
|
+
actual +
|
5499
|
+
').toBeCloseTo(' +
|
5500
|
+
expected +
|
5501
|
+
').'
|
5250
5502
|
);
|
5251
5503
|
}
|
5252
5504
|
|
@@ -5277,7 +5529,7 @@ getJasmineRequireObj().toBeDefined = function() {
|
|
5277
5529
|
return {
|
5278
5530
|
compare: function(actual) {
|
5279
5531
|
return {
|
5280
|
-
pass:
|
5532
|
+
pass: void 0 !== actual
|
5281
5533
|
};
|
5282
5534
|
}
|
5283
5535
|
};
|
@@ -5353,7 +5605,6 @@ getJasmineRequireObj().toBeGreaterThan = function() {
|
|
5353
5605
|
return toBeGreaterThan;
|
5354
5606
|
};
|
5355
5607
|
|
5356
|
-
|
5357
5608
|
getJasmineRequireObj().toBeGreaterThanOrEqual = function() {
|
5358
5609
|
/**
|
5359
5610
|
* {@link expect} the actual value to be greater than or equal to the expected value.
|
@@ -5378,7 +5629,10 @@ getJasmineRequireObj().toBeGreaterThanOrEqual = function() {
|
|
5378
5629
|
};
|
5379
5630
|
|
5380
5631
|
getJasmineRequireObj().toBeInstanceOf = function(j$) {
|
5381
|
-
var usageError =
|
5632
|
+
var usageError = j$.formatErrorMsg(
|
5633
|
+
'<toBeInstanceOf>',
|
5634
|
+
'expect(value).toBeInstanceOf(<ConstructorFunction>)'
|
5635
|
+
);
|
5382
5636
|
|
5383
5637
|
/**
|
5384
5638
|
* {@link expect} the actual to be an instance of the expected class
|
@@ -5394,27 +5648,42 @@ getJasmineRequireObj().toBeInstanceOf = function(j$) {
|
|
5394
5648
|
function toBeInstanceOf(matchersUtil) {
|
5395
5649
|
return {
|
5396
5650
|
compare: function(actual, expected) {
|
5397
|
-
var actualType =
|
5398
|
-
|
5399
|
-
|
5400
|
-
|
5651
|
+
var actualType =
|
5652
|
+
actual && actual.constructor
|
5653
|
+
? j$.fnNameFor(actual.constructor)
|
5654
|
+
: matchersUtil.pp(actual),
|
5655
|
+
expectedType = expected
|
5656
|
+
? j$.fnNameFor(expected)
|
5657
|
+
: matchersUtil.pp(expected),
|
5658
|
+
expectedMatcher,
|
5659
|
+
pass;
|
5401
5660
|
|
5402
5661
|
try {
|
5403
|
-
|
5404
|
-
|
5662
|
+
expectedMatcher = new j$.Any(expected);
|
5663
|
+
pass = expectedMatcher.asymmetricMatch(actual);
|
5405
5664
|
} catch (error) {
|
5406
|
-
|
5665
|
+
throw new Error(
|
5666
|
+
usageError('Expected value is not a constructor function')
|
5667
|
+
);
|
5407
5668
|
}
|
5408
5669
|
|
5409
5670
|
if (pass) {
|
5410
5671
|
return {
|
5411
5672
|
pass: true,
|
5412
|
-
message:
|
5673
|
+
message:
|
5674
|
+
'Expected instance of ' +
|
5675
|
+
actualType +
|
5676
|
+
' not to be an instance of ' +
|
5677
|
+
expectedType
|
5413
5678
|
};
|
5414
5679
|
} else {
|
5415
5680
|
return {
|
5416
5681
|
pass: false,
|
5417
|
-
message:
|
5682
|
+
message:
|
5683
|
+
'Expected instance of ' +
|
5684
|
+
actualType +
|
5685
|
+
' to be an instance of ' +
|
5686
|
+
expectedType
|
5418
5687
|
};
|
5419
5688
|
}
|
5420
5689
|
}
|
@@ -5436,7 +5705,6 @@ getJasmineRequireObj().toBeLessThan = function() {
|
|
5436
5705
|
*/
|
5437
5706
|
function toBeLessThan() {
|
5438
5707
|
return {
|
5439
|
-
|
5440
5708
|
compare: function(actual, expected) {
|
5441
5709
|
return {
|
5442
5710
|
pass: actual < expected
|
@@ -5460,7 +5728,6 @@ getJasmineRequireObj().toBeLessThanOrEqual = function() {
|
|
5460
5728
|
*/
|
5461
5729
|
function toBeLessThanOrEqual() {
|
5462
5730
|
return {
|
5463
|
-
|
5464
5731
|
compare: function(actual, expected) {
|
5465
5732
|
return {
|
5466
5733
|
pass: actual <= expected
|
@@ -5485,13 +5752,15 @@ getJasmineRequireObj().toBeNaN = function(j$) {
|
|
5485
5752
|
return {
|
5486
5753
|
compare: function(actual) {
|
5487
5754
|
var result = {
|
5488
|
-
pass:
|
5755
|
+
pass: actual !== actual
|
5489
5756
|
};
|
5490
5757
|
|
5491
5758
|
if (result.pass) {
|
5492
5759
|
result.message = 'Expected actual not to be NaN.';
|
5493
5760
|
} else {
|
5494
|
-
result.message = function() {
|
5761
|
+
result.message = function() {
|
5762
|
+
return 'Expected ' + matchersUtil.pp(actual) + ' to be NaN.';
|
5763
|
+
};
|
5495
5764
|
}
|
5496
5765
|
|
5497
5766
|
return result;
|
@@ -5515,13 +5784,15 @@ getJasmineRequireObj().toBeNegativeInfinity = function(j$) {
|
|
5515
5784
|
return {
|
5516
5785
|
compare: function(actual) {
|
5517
5786
|
var result = {
|
5518
|
-
pass:
|
5787
|
+
pass: actual === Number.NEGATIVE_INFINITY
|
5519
5788
|
};
|
5520
5789
|
|
5521
5790
|
if (result.pass) {
|
5522
5791
|
result.message = 'Expected actual not to be -Infinity.';
|
5523
5792
|
} else {
|
5524
|
-
result.message = function() {
|
5793
|
+
result.message = function() {
|
5794
|
+
return 'Expected ' + matchersUtil.pp(actual) + ' to be -Infinity.';
|
5795
|
+
};
|
5525
5796
|
}
|
5526
5797
|
|
5527
5798
|
return result;
|
@@ -5567,13 +5838,15 @@ getJasmineRequireObj().toBePositiveInfinity = function(j$) {
|
|
5567
5838
|
return {
|
5568
5839
|
compare: function(actual) {
|
5569
5840
|
var result = {
|
5570
|
-
pass:
|
5841
|
+
pass: actual === Number.POSITIVE_INFINITY
|
5571
5842
|
};
|
5572
5843
|
|
5573
5844
|
if (result.pass) {
|
5574
5845
|
result.message = 'Expected actual not to be Infinity.';
|
5575
5846
|
} else {
|
5576
|
-
result.message = function() {
|
5847
|
+
result.message = function() {
|
5848
|
+
return 'Expected ' + matchersUtil.pp(actual) + ' to be Infinity.';
|
5849
|
+
};
|
5577
5850
|
}
|
5578
5851
|
|
5579
5852
|
return result;
|
@@ -5664,7 +5937,6 @@ getJasmineRequireObj().toContain = function() {
|
|
5664
5937
|
function toContain(matchersUtil) {
|
5665
5938
|
return {
|
5666
5939
|
compare: function(actual, expected) {
|
5667
|
-
|
5668
5940
|
return {
|
5669
5941
|
pass: matchersUtil.contains(actual, expected)
|
5670
5942
|
};
|
@@ -5691,7 +5963,7 @@ getJasmineRequireObj().toEqual = function(j$) {
|
|
5691
5963
|
var result = {
|
5692
5964
|
pass: false
|
5693
5965
|
},
|
5694
|
-
diffBuilder = j$.DiffBuilder({prettyPrinter: matchersUtil.pp});
|
5966
|
+
diffBuilder = j$.DiffBuilder({ prettyPrinter: matchersUtil.pp });
|
5695
5967
|
|
5696
5968
|
result.pass = matchersUtil.equals(actual, expected, diffBuilder);
|
5697
5969
|
|
@@ -5707,8 +5979,10 @@ getJasmineRequireObj().toEqual = function(j$) {
|
|
5707
5979
|
};
|
5708
5980
|
|
5709
5981
|
getJasmineRequireObj().toHaveBeenCalled = function(j$) {
|
5710
|
-
|
5711
|
-
|
5982
|
+
var getErrorMsg = j$.formatErrorMsg(
|
5983
|
+
'<toHaveBeenCalled>',
|
5984
|
+
'expect(<spyObj>).toHaveBeenCalled()'
|
5985
|
+
);
|
5712
5986
|
|
5713
5987
|
/**
|
5714
5988
|
* {@link expect} the actual (a {@link Spy}) to have been called.
|
@@ -5725,18 +5999,24 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) {
|
|
5725
5999
|
var result = {};
|
5726
6000
|
|
5727
6001
|
if (!j$.isSpy(actual)) {
|
5728
|
-
throw new Error(
|
6002
|
+
throw new Error(
|
6003
|
+
getErrorMsg(
|
6004
|
+
'Expected a spy, but got ' + matchersUtil.pp(actual) + '.'
|
6005
|
+
)
|
6006
|
+
);
|
5729
6007
|
}
|
5730
6008
|
|
5731
6009
|
if (arguments.length > 1) {
|
5732
|
-
throw new Error(
|
6010
|
+
throw new Error(
|
6011
|
+
getErrorMsg('Does not take arguments, use toHaveBeenCalledWith')
|
6012
|
+
);
|
5733
6013
|
}
|
5734
6014
|
|
5735
6015
|
result.pass = actual.calls.any();
|
5736
6016
|
|
5737
|
-
result.message = result.pass
|
5738
|
-
'Expected spy ' + actual.and.identity + ' not to have been called.'
|
5739
|
-
'Expected spy ' + actual.and.identity + ' to have been called.';
|
6017
|
+
result.message = result.pass
|
6018
|
+
? 'Expected spy ' + actual.and.identity + ' not to have been called.'
|
6019
|
+
: 'Expected spy ' + actual.and.identity + ' to have been called.';
|
5740
6020
|
|
5741
6021
|
return result;
|
5742
6022
|
}
|
@@ -5747,8 +6027,10 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) {
|
|
5747
6027
|
};
|
5748
6028
|
|
5749
6029
|
getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
|
5750
|
-
|
5751
|
-
|
6030
|
+
var getErrorMsg = j$.formatErrorMsg(
|
6031
|
+
'<toHaveBeenCalledBefore>',
|
6032
|
+
'expect(<spyObj>).toHaveBeenCalledBefore(<spyObj>)'
|
6033
|
+
);
|
5752
6034
|
|
5753
6035
|
/**
|
5754
6036
|
* {@link expect} the actual value (a {@link Spy}) to have been called before another {@link Spy}.
|
@@ -5763,20 +6045,30 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
|
|
5763
6045
|
return {
|
5764
6046
|
compare: function(firstSpy, latterSpy) {
|
5765
6047
|
if (!j$.isSpy(firstSpy)) {
|
5766
|
-
throw new Error(
|
6048
|
+
throw new Error(
|
6049
|
+
getErrorMsg(
|
6050
|
+
'Expected a spy, but got ' + matchersUtil.pp(firstSpy) + '.'
|
6051
|
+
)
|
6052
|
+
);
|
5767
6053
|
}
|
5768
6054
|
if (!j$.isSpy(latterSpy)) {
|
5769
|
-
throw new Error(
|
6055
|
+
throw new Error(
|
6056
|
+
getErrorMsg(
|
6057
|
+
'Expected a spy, but got ' + matchersUtil.pp(latterSpy) + '.'
|
6058
|
+
)
|
6059
|
+
);
|
5770
6060
|
}
|
5771
6061
|
|
5772
6062
|
var result = { pass: false };
|
5773
6063
|
|
5774
6064
|
if (!firstSpy.calls.count()) {
|
5775
|
-
result.message =
|
6065
|
+
result.message =
|
6066
|
+
'Expected spy ' + firstSpy.and.identity + ' to have been called.';
|
5776
6067
|
return result;
|
5777
6068
|
}
|
5778
6069
|
if (!latterSpy.calls.count()) {
|
5779
|
-
result.message =
|
6070
|
+
result.message =
|
6071
|
+
'Expected spy ' + latterSpy.and.identity + ' to have been called.';
|
5780
6072
|
return result;
|
5781
6073
|
}
|
5782
6074
|
|
@@ -5786,17 +6078,36 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
|
|
5786
6078
|
result.pass = latest1stSpyCall < first2ndSpyCall;
|
5787
6079
|
|
5788
6080
|
if (result.pass) {
|
5789
|
-
result.message =
|
6081
|
+
result.message =
|
6082
|
+
'Expected spy ' +
|
6083
|
+
firstSpy.and.identity +
|
6084
|
+
' to not have been called before spy ' +
|
6085
|
+
latterSpy.and.identity +
|
6086
|
+
', but it was';
|
5790
6087
|
} else {
|
5791
6088
|
var first1stSpyCall = firstSpy.calls.first().invocationOrder;
|
5792
6089
|
var latest2ndSpyCall = latterSpy.calls.mostRecent().invocationOrder;
|
5793
6090
|
|
5794
|
-
if(first1stSpyCall < first2ndSpyCall) {
|
5795
|
-
result.message =
|
6091
|
+
if (first1stSpyCall < first2ndSpyCall) {
|
6092
|
+
result.message =
|
6093
|
+
'Expected latest call to spy ' +
|
6094
|
+
firstSpy.and.identity +
|
6095
|
+
' to have been called before first call to spy ' +
|
6096
|
+
latterSpy.and.identity +
|
6097
|
+
' (no interleaved calls)';
|
5796
6098
|
} else if (latest2ndSpyCall > latest1stSpyCall) {
|
5797
|
-
result.message =
|
6099
|
+
result.message =
|
6100
|
+
'Expected first call to spy ' +
|
6101
|
+
latterSpy.and.identity +
|
6102
|
+
' to have been called after latest call to spy ' +
|
6103
|
+
firstSpy.and.identity +
|
6104
|
+
' (no interleaved calls)';
|
5798
6105
|
} else {
|
5799
|
-
result.message =
|
6106
|
+
result.message =
|
6107
|
+
'Expected spy ' +
|
6108
|
+
firstSpy.and.identity +
|
6109
|
+
' to have been called before spy ' +
|
6110
|
+
latterSpy.and.identity;
|
5800
6111
|
}
|
5801
6112
|
}
|
5802
6113
|
|
@@ -5808,9 +6119,11 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
|
|
5808
6119
|
return toHaveBeenCalledBefore;
|
5809
6120
|
};
|
5810
6121
|
|
5811
|
-
getJasmineRequireObj().toHaveBeenCalledOnceWith = function
|
5812
|
-
|
5813
|
-
|
6122
|
+
getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) {
|
6123
|
+
var getErrorMsg = j$.formatErrorMsg(
|
6124
|
+
'<toHaveBeenCalledOnceWith>',
|
6125
|
+
'expect(<spyObj>).toHaveBeenCalledOnceWith(...arguments)'
|
6126
|
+
);
|
5814
6127
|
|
5815
6128
|
/**
|
5816
6129
|
* {@link expect} the actual (a {@link Spy}) to have been called exactly once, and exactly with the particular arguments.
|
@@ -5823,31 +6136,44 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) {
|
|
5823
6136
|
*/
|
5824
6137
|
function toHaveBeenCalledOnceWith(util) {
|
5825
6138
|
return {
|
5826
|
-
compare: function
|
6139
|
+
compare: function() {
|
5827
6140
|
var args = Array.prototype.slice.call(arguments, 0),
|
5828
6141
|
actual = args[0],
|
5829
6142
|
expectedArgs = args.slice(1);
|
5830
6143
|
|
5831
6144
|
if (!j$.isSpy(actual)) {
|
5832
|
-
throw new Error(
|
6145
|
+
throw new Error(
|
6146
|
+
getErrorMsg('Expected a spy, but got ' + util.pp(actual) + '.')
|
6147
|
+
);
|
5833
6148
|
}
|
5834
6149
|
|
5835
|
-
var prettyPrintedCalls = actual.calls
|
5836
|
-
|
5837
|
-
|
6150
|
+
var prettyPrintedCalls = actual.calls
|
6151
|
+
.allArgs()
|
6152
|
+
.map(function(argsForCall) {
|
6153
|
+
return ' ' + util.pp(argsForCall);
|
6154
|
+
});
|
5838
6155
|
|
5839
|
-
if (
|
6156
|
+
if (
|
6157
|
+
actual.calls.count() === 1 &&
|
6158
|
+
util.contains(actual.calls.allArgs(), expectedArgs)
|
6159
|
+
) {
|
5840
6160
|
return {
|
5841
6161
|
pass: true,
|
5842
|
-
message:
|
5843
|
-
|
5844
|
-
|
5845
|
-
|
6162
|
+
message:
|
6163
|
+
'Expected spy ' +
|
6164
|
+
actual.and.identity +
|
6165
|
+
' to have been called 0 times, multiple times, or once, but with arguments different from:\n' +
|
6166
|
+
' ' +
|
6167
|
+
util.pp(expectedArgs) +
|
6168
|
+
'\n' +
|
6169
|
+
'But the actual call was:\n' +
|
6170
|
+
prettyPrintedCalls.join(',\n') +
|
6171
|
+
'.\n\n'
|
5846
6172
|
};
|
5847
6173
|
}
|
5848
6174
|
|
5849
6175
|
function getDiffs() {
|
5850
|
-
return actual.calls.allArgs().map(function
|
6176
|
+
return actual.calls.allArgs().map(function(argsForCall, callIx) {
|
5851
6177
|
var diffBuilder = new j$.DiffBuilder();
|
5852
6178
|
util.equals(argsForCall, expectedArgs, diffBuilder);
|
5853
6179
|
return diffBuilder.getMessage();
|
@@ -5859,17 +6185,32 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) {
|
|
5859
6185
|
case 0:
|
5860
6186
|
return 'But it was never called.\n\n';
|
5861
6187
|
case 1:
|
5862
|
-
return
|
6188
|
+
return (
|
6189
|
+
'But the actual call was:\n' +
|
6190
|
+
prettyPrintedCalls.join(',\n') +
|
6191
|
+
'.\n' +
|
6192
|
+
getDiffs().join('\n') +
|
6193
|
+
'\n\n'
|
6194
|
+
);
|
5863
6195
|
default:
|
5864
|
-
return
|
6196
|
+
return (
|
6197
|
+
'But the actual calls were:\n' +
|
6198
|
+
prettyPrintedCalls.join(',\n') +
|
6199
|
+
'.\n\n'
|
6200
|
+
);
|
5865
6201
|
}
|
5866
6202
|
}
|
5867
6203
|
|
5868
6204
|
return {
|
5869
6205
|
pass: false,
|
5870
|
-
message:
|
5871
|
-
|
5872
|
-
+
|
6206
|
+
message:
|
6207
|
+
'Expected spy ' +
|
6208
|
+
actual.and.identity +
|
6209
|
+
' to have been called only once, and with given args:\n' +
|
6210
|
+
' ' +
|
6211
|
+
util.pp(expectedArgs) +
|
6212
|
+
'\n' +
|
6213
|
+
butString()
|
5873
6214
|
};
|
5874
6215
|
}
|
5875
6216
|
};
|
@@ -5879,8 +6220,10 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) {
|
|
5879
6220
|
};
|
5880
6221
|
|
5881
6222
|
getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
5882
|
-
|
5883
|
-
|
6223
|
+
var getErrorMsg = j$.formatErrorMsg(
|
6224
|
+
'<toHaveBeenCalledTimes>',
|
6225
|
+
'expect(<spyObj>).toHaveBeenCalledTimes(<Number>)'
|
6226
|
+
);
|
5884
6227
|
|
5885
6228
|
/**
|
5886
6229
|
* {@link expect} the actual (a {@link Spy}) to have been called the specified number of times.
|
@@ -5895,23 +6238,43 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
|
5895
6238
|
return {
|
5896
6239
|
compare: function(actual, expected) {
|
5897
6240
|
if (!j$.isSpy(actual)) {
|
5898
|
-
throw new Error(
|
6241
|
+
throw new Error(
|
6242
|
+
getErrorMsg(
|
6243
|
+
'Expected a spy, but got ' + matchersUtil.pp(actual) + '.'
|
6244
|
+
)
|
6245
|
+
);
|
5899
6246
|
}
|
5900
6247
|
|
5901
6248
|
var args = Array.prototype.slice.call(arguments, 0),
|
5902
6249
|
result = { pass: false };
|
5903
6250
|
|
5904
6251
|
if (!j$.isNumber_(expected)) {
|
5905
|
-
throw new Error(
|
6252
|
+
throw new Error(
|
6253
|
+
getErrorMsg(
|
6254
|
+
'The expected times failed is a required argument and must be a number.'
|
6255
|
+
)
|
6256
|
+
);
|
5906
6257
|
}
|
5907
6258
|
|
5908
6259
|
actual = args[0];
|
5909
6260
|
var calls = actual.calls.count();
|
5910
6261
|
var timesMessage = expected === 1 ? 'once' : expected + ' times';
|
5911
6262
|
result.pass = calls === expected;
|
5912
|
-
result.message = result.pass
|
5913
|
-
'Expected spy ' +
|
5914
|
-
|
6263
|
+
result.message = result.pass
|
6264
|
+
? 'Expected spy ' +
|
6265
|
+
actual.and.identity +
|
6266
|
+
' not to have been called ' +
|
6267
|
+
timesMessage +
|
6268
|
+
'. It was called ' +
|
6269
|
+
calls +
|
6270
|
+
' times.'
|
6271
|
+
: 'Expected spy ' +
|
6272
|
+
actual.and.identity +
|
6273
|
+
' to have been called ' +
|
6274
|
+
timesMessage +
|
6275
|
+
'. It was called ' +
|
6276
|
+
calls +
|
6277
|
+
' times.';
|
5915
6278
|
return result;
|
5916
6279
|
}
|
5917
6280
|
};
|
@@ -5921,8 +6284,10 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
|
5921
6284
|
};
|
5922
6285
|
|
5923
6286
|
getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
|
5924
|
-
|
5925
|
-
|
6287
|
+
var getErrorMsg = j$.formatErrorMsg(
|
6288
|
+
'<toHaveBeenCalledWith>',
|
6289
|
+
'expect(<spyObj>).toHaveBeenCalledWith(...arguments)'
|
6290
|
+
);
|
5926
6291
|
|
5927
6292
|
/**
|
5928
6293
|
* {@link expect} the actual (a {@link Spy}) to have been called with particular arguments at least once.
|
@@ -5942,14 +6307,23 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
|
|
5942
6307
|
result = { pass: false };
|
5943
6308
|
|
5944
6309
|
if (!j$.isSpy(actual)) {
|
5945
|
-
throw new Error(
|
6310
|
+
throw new Error(
|
6311
|
+
getErrorMsg(
|
6312
|
+
'Expected a spy, but got ' + matchersUtil.pp(actual) + '.'
|
6313
|
+
)
|
6314
|
+
);
|
5946
6315
|
}
|
5947
6316
|
|
5948
6317
|
if (!actual.calls.any()) {
|
5949
6318
|
result.message = function() {
|
5950
|
-
return
|
5951
|
-
'
|
5952
|
-
|
6319
|
+
return (
|
6320
|
+
'Expected spy ' +
|
6321
|
+
actual.and.identity +
|
6322
|
+
' to have been called with:\n' +
|
6323
|
+
' ' +
|
6324
|
+
matchersUtil.pp(expectedArgs) +
|
6325
|
+
'\nbut it was never called.'
|
6326
|
+
);
|
5953
6327
|
};
|
5954
6328
|
return result;
|
5955
6329
|
}
|
@@ -5957,28 +6331,49 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
|
|
5957
6331
|
if (matchersUtil.contains(actual.calls.allArgs(), expectedArgs)) {
|
5958
6332
|
result.pass = true;
|
5959
6333
|
result.message = function() {
|
5960
|
-
return
|
5961
|
-
'
|
5962
|
-
|
6334
|
+
return (
|
6335
|
+
'Expected spy ' +
|
6336
|
+
actual.and.identity +
|
6337
|
+
' not to have been called with:\n' +
|
6338
|
+
' ' +
|
6339
|
+
matchersUtil.pp(expectedArgs) +
|
6340
|
+
'\nbut it was.'
|
6341
|
+
);
|
5963
6342
|
};
|
5964
6343
|
} else {
|
5965
6344
|
result.message = function() {
|
5966
|
-
var prettyPrintedCalls = actual.calls
|
5967
|
-
|
5968
|
-
|
5969
|
-
|
5970
|
-
|
5971
|
-
|
5972
|
-
|
5973
|
-
|
5974
|
-
|
5975
|
-
|
5976
|
-
|
5977
|
-
|
5978
|
-
|
6345
|
+
var prettyPrintedCalls = actual.calls
|
6346
|
+
.allArgs()
|
6347
|
+
.map(function(argsForCall) {
|
6348
|
+
return ' ' + matchersUtil.pp(argsForCall);
|
6349
|
+
});
|
6350
|
+
|
6351
|
+
var diffs = actual.calls
|
6352
|
+
.allArgs()
|
6353
|
+
.map(function(argsForCall, callIx) {
|
6354
|
+
var diffBuilder = new j$.DiffBuilder();
|
6355
|
+
matchersUtil.equals(argsForCall, expectedArgs, diffBuilder);
|
6356
|
+
return (
|
6357
|
+
'Call ' +
|
6358
|
+
callIx +
|
6359
|
+
':\n' +
|
6360
|
+
diffBuilder.getMessage().replace(/^/gm, ' ')
|
6361
|
+
);
|
6362
|
+
});
|
6363
|
+
|
6364
|
+
return (
|
6365
|
+
'Expected spy ' +
|
6366
|
+
actual.and.identity +
|
6367
|
+
' to have been called with:\n' +
|
6368
|
+
' ' +
|
6369
|
+
matchersUtil.pp(expectedArgs) +
|
6370
|
+
'\n' +
|
6371
|
+
'' +
|
5979
6372
|
'but actual calls were:\n' +
|
5980
|
-
prettyPrintedCalls.join(',\n') +
|
5981
|
-
|
6373
|
+
prettyPrintedCalls.join(',\n') +
|
6374
|
+
'.\n\n' +
|
6375
|
+
diffs.join('\n')
|
6376
|
+
);
|
5982
6377
|
};
|
5983
6378
|
}
|
5984
6379
|
|
@@ -6017,9 +6412,9 @@ getJasmineRequireObj().toHaveClass = function(j$) {
|
|
6017
6412
|
}
|
6018
6413
|
|
6019
6414
|
function isElement(maybeEl) {
|
6020
|
-
return
|
6021
|
-
maybeEl.classList &&
|
6022
|
-
|
6415
|
+
return (
|
6416
|
+
maybeEl && maybeEl.classList && j$.isFunction_(maybeEl.classList.contains)
|
6417
|
+
);
|
6023
6418
|
}
|
6024
6419
|
|
6025
6420
|
return toHaveClass;
|
@@ -6040,10 +6435,14 @@ getJasmineRequireObj().toHaveSize = function(j$) {
|
|
6040
6435
|
return {
|
6041
6436
|
compare: function(actual, expected) {
|
6042
6437
|
var result = {
|
6043
|
-
|
6044
|
-
|
6438
|
+
pass: false
|
6439
|
+
};
|
6045
6440
|
|
6046
|
-
if (
|
6441
|
+
if (
|
6442
|
+
j$.isA_('WeakSet', actual) ||
|
6443
|
+
j$.isWeakMap(actual) ||
|
6444
|
+
j$.isDataView(actual)
|
6445
|
+
) {
|
6047
6446
|
throw new Error('Cannot get size of ' + actual + '.');
|
6048
6447
|
}
|
6049
6448
|
|
@@ -6060,17 +6459,24 @@ getJasmineRequireObj().toHaveSize = function(j$) {
|
|
6060
6459
|
};
|
6061
6460
|
}
|
6062
6461
|
|
6063
|
-
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
6462
|
+
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // eslint-disable-line compat/compat
|
6064
6463
|
function isLength(value) {
|
6065
|
-
return (
|
6464
|
+
return (
|
6465
|
+
typeof value == 'number' &&
|
6466
|
+
value > -1 &&
|
6467
|
+
value % 1 === 0 &&
|
6468
|
+
value <= MAX_SAFE_INTEGER
|
6469
|
+
);
|
6066
6470
|
}
|
6067
6471
|
|
6068
6472
|
return toHaveSize;
|
6069
6473
|
};
|
6070
6474
|
|
6071
6475
|
getJasmineRequireObj().toMatch = function(j$) {
|
6072
|
-
|
6073
|
-
|
6476
|
+
var getErrorMsg = j$.formatErrorMsg(
|
6477
|
+
'<toMatch>',
|
6478
|
+
'expect(<expectation>).toMatch(<string> || <regexp>)'
|
6479
|
+
);
|
6074
6480
|
|
6075
6481
|
/**
|
6076
6482
|
* {@link expect} the actual value to match a regular expression
|
@@ -6102,8 +6508,10 @@ getJasmineRequireObj().toMatch = function(j$) {
|
|
6102
6508
|
};
|
6103
6509
|
|
6104
6510
|
getJasmineRequireObj().toThrow = function(j$) {
|
6105
|
-
|
6106
|
-
|
6511
|
+
var getErrorMsg = j$.formatErrorMsg(
|
6512
|
+
'<toThrow>',
|
6513
|
+
'expect(function() {<expectation>}).toThrow()'
|
6514
|
+
);
|
6107
6515
|
|
6108
6516
|
/**
|
6109
6517
|
* {@link expect} a function to `throw` something.
|
@@ -6140,16 +6548,36 @@ getJasmineRequireObj().toThrow = function(j$) {
|
|
6140
6548
|
|
6141
6549
|
if (arguments.length == 1) {
|
6142
6550
|
result.pass = true;
|
6143
|
-
result.message = function() {
|
6551
|
+
result.message = function() {
|
6552
|
+
return (
|
6553
|
+
'Expected function not to throw, but it threw ' +
|
6554
|
+
matchersUtil.pp(thrown) +
|
6555
|
+
'.'
|
6556
|
+
);
|
6557
|
+
};
|
6144
6558
|
|
6145
6559
|
return result;
|
6146
6560
|
}
|
6147
6561
|
|
6148
6562
|
if (matchersUtil.equals(thrown, expected)) {
|
6149
6563
|
result.pass = true;
|
6150
|
-
result.message = function() {
|
6564
|
+
result.message = function() {
|
6565
|
+
return (
|
6566
|
+
'Expected function not to throw ' +
|
6567
|
+
matchersUtil.pp(expected) +
|
6568
|
+
'.'
|
6569
|
+
);
|
6570
|
+
};
|
6151
6571
|
} else {
|
6152
|
-
result.message = function() {
|
6572
|
+
result.message = function() {
|
6573
|
+
return (
|
6574
|
+
'Expected function to throw ' +
|
6575
|
+
matchersUtil.pp(expected) +
|
6576
|
+
', but it threw ' +
|
6577
|
+
matchersUtil.pp(thrown) +
|
6578
|
+
'.'
|
6579
|
+
);
|
6580
|
+
};
|
6153
6581
|
}
|
6154
6582
|
|
6155
6583
|
return result;
|
@@ -6161,8 +6589,10 @@ getJasmineRequireObj().toThrow = function(j$) {
|
|
6161
6589
|
};
|
6162
6590
|
|
6163
6591
|
getJasmineRequireObj().toThrowError = function(j$) {
|
6164
|
-
|
6165
|
-
|
6592
|
+
var getErrorMsg = j$.formatErrorMsg(
|
6593
|
+
'<toThrowError>',
|
6594
|
+
'expect(function() {<expectation>}).toThrowError(<ErrorConstructor>, <message>)'
|
6595
|
+
);
|
6166
6596
|
|
6167
6597
|
/**
|
6168
6598
|
* {@link expect} a function to `throw` an `Error`.
|
@@ -6196,7 +6626,13 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
|
6196
6626
|
}
|
6197
6627
|
|
6198
6628
|
if (!j$.isError_(thrown)) {
|
6199
|
-
return fail(function() {
|
6629
|
+
return fail(function() {
|
6630
|
+
return (
|
6631
|
+
'Expected function to throw an Error, but it threw ' +
|
6632
|
+
matchersUtil.pp(thrown) +
|
6633
|
+
'.'
|
6634
|
+
);
|
6635
|
+
});
|
6200
6636
|
}
|
6201
6637
|
|
6202
6638
|
return errorMatcher.match(thrown);
|
@@ -6230,7 +6666,11 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
|
6230
6666
|
function anyMatcher() {
|
6231
6667
|
return {
|
6232
6668
|
match: function(error) {
|
6233
|
-
return pass(
|
6669
|
+
return pass(
|
6670
|
+
'Expected function not to throw an Error, but it threw ' +
|
6671
|
+
j$.fnNameFor(error) +
|
6672
|
+
'.'
|
6673
|
+
);
|
6234
6674
|
}
|
6235
6675
|
};
|
6236
6676
|
}
|
@@ -6238,9 +6678,13 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
|
6238
6678
|
function exactMatcher(expected, errorType) {
|
6239
6679
|
if (expected && !isStringOrRegExp(expected)) {
|
6240
6680
|
if (errorType) {
|
6241
|
-
throw new Error(
|
6681
|
+
throw new Error(
|
6682
|
+
getErrorMsg('Expected error message is not a string or RegExp.')
|
6683
|
+
);
|
6242
6684
|
} else {
|
6243
|
-
throw new Error(
|
6685
|
+
throw new Error(
|
6686
|
+
getErrorMsg('Expected is not an Error, string, or RegExp.')
|
6687
|
+
);
|
6244
6688
|
}
|
6245
6689
|
}
|
6246
6690
|
|
@@ -6252,11 +6696,15 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
|
6252
6696
|
}
|
6253
6697
|
}
|
6254
6698
|
|
6255
|
-
var errorTypeDescription = errorType
|
6699
|
+
var errorTypeDescription = errorType
|
6700
|
+
? j$.fnNameFor(errorType)
|
6701
|
+
: 'an exception';
|
6256
6702
|
|
6257
6703
|
function thrownDescription(thrown) {
|
6258
|
-
var thrownName = errorType
|
6259
|
-
|
6704
|
+
var thrownName = errorType
|
6705
|
+
? j$.fnNameFor(thrown.constructor)
|
6706
|
+
: 'an exception',
|
6707
|
+
thrownMessage = '';
|
6260
6708
|
|
6261
6709
|
if (expected) {
|
6262
6710
|
thrownMessage = ' with message ' + matchersUtil.pp(thrown.message);
|
@@ -6276,20 +6724,33 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
|
6276
6724
|
}
|
6277
6725
|
|
6278
6726
|
function matches(error) {
|
6279
|
-
return (
|
6280
|
-
(
|
6727
|
+
return (
|
6728
|
+
(errorType === null || error instanceof errorType) &&
|
6729
|
+
(expected === null || messageMatch(error.message))
|
6730
|
+
);
|
6281
6731
|
}
|
6282
6732
|
|
6283
6733
|
return {
|
6284
6734
|
match: function(thrown) {
|
6285
6735
|
if (matches(thrown)) {
|
6286
6736
|
return pass(function() {
|
6287
|
-
return
|
6737
|
+
return (
|
6738
|
+
'Expected function not to throw ' +
|
6739
|
+
errorTypeDescription +
|
6740
|
+
messageDescription() +
|
6741
|
+
'.'
|
6742
|
+
);
|
6288
6743
|
});
|
6289
6744
|
} else {
|
6290
6745
|
return fail(function() {
|
6291
|
-
return
|
6292
|
-
'
|
6746
|
+
return (
|
6747
|
+
'Expected function to throw ' +
|
6748
|
+
errorTypeDescription +
|
6749
|
+
messageDescription() +
|
6750
|
+
', but it threw ' +
|
6751
|
+
thrownDescription(thrown) +
|
6752
|
+
'.'
|
6753
|
+
);
|
6293
6754
|
});
|
6294
6755
|
}
|
6295
6756
|
}
|
@@ -6297,7 +6758,7 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
|
6297
6758
|
}
|
6298
6759
|
|
6299
6760
|
function isStringOrRegExp(potential) {
|
6300
|
-
return potential instanceof RegExp ||
|
6761
|
+
return potential instanceof RegExp || typeof potential == 'string';
|
6301
6762
|
}
|
6302
6763
|
|
6303
6764
|
function isAnErrorType(type) {
|
@@ -6329,7 +6790,10 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
|
6329
6790
|
};
|
6330
6791
|
|
6331
6792
|
getJasmineRequireObj().toThrowMatching = function(j$) {
|
6332
|
-
var usageError =
|
6793
|
+
var usageError = j$.formatErrorMsg(
|
6794
|
+
'<toThrowMatching>',
|
6795
|
+
'expect(function() {<expectation>}).toThrowMatching(<Predicate>)'
|
6796
|
+
);
|
6333
6797
|
|
6334
6798
|
/**
|
6335
6799
|
* {@link expect} a function to `throw` something matching a predicate.
|
@@ -6361,20 +6825,29 @@ getJasmineRequireObj().toThrowMatching = function(j$) {
|
|
6361
6825
|
}
|
6362
6826
|
|
6363
6827
|
if (predicate(thrown)) {
|
6364
|
-
return pass(
|
6828
|
+
return pass(
|
6829
|
+
'Expected function not to throw an exception matching a predicate.'
|
6830
|
+
);
|
6365
6831
|
} else {
|
6366
|
-
|
6367
|
-
|
6368
|
-
|
6369
|
-
|
6832
|
+
return fail(function() {
|
6833
|
+
return (
|
6834
|
+
'Expected function to throw an exception matching a predicate, ' +
|
6835
|
+
'but it threw ' +
|
6836
|
+
thrownDescription(thrown) +
|
6837
|
+
'.'
|
6838
|
+
);
|
6839
|
+
});
|
6370
6840
|
}
|
6371
6841
|
}
|
6372
6842
|
};
|
6373
6843
|
|
6374
6844
|
function thrownDescription(thrown) {
|
6375
6845
|
if (thrown && thrown.constructor) {
|
6376
|
-
return
|
6377
|
-
|
6846
|
+
return (
|
6847
|
+
j$.fnNameFor(thrown.constructor) +
|
6848
|
+
' with message ' +
|
6849
|
+
matchersUtil.pp(thrown.message)
|
6850
|
+
);
|
6378
6851
|
} else {
|
6379
6852
|
return matchersUtil.pp(thrown);
|
6380
6853
|
}
|
@@ -6911,6 +7384,8 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
|
|
6911
7384
|
};
|
6912
7385
|
|
6913
7386
|
getJasmineRequireObj().QueueRunner = function(j$) {
|
7387
|
+
var nextid = 1;
|
7388
|
+
|
6914
7389
|
function StopExecutionError() {}
|
6915
7390
|
StopExecutionError.prototype = new Error();
|
6916
7391
|
j$.StopExecutionError = StopExecutionError;
|
@@ -6930,6 +7405,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|
6930
7405
|
function emptyFn() {}
|
6931
7406
|
|
6932
7407
|
function QueueRunner(attrs) {
|
7408
|
+
this.id_ = nextid++;
|
6933
7409
|
var queueableFns = attrs.queueableFns || [];
|
6934
7410
|
this.queueableFns = queueableFns.concat(attrs.cleanupFns || []);
|
6935
7411
|
this.firstCleanupIx = queueableFns.length;
|
@@ -7032,7 +7508,8 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|
7032
7508
|
}),
|
7033
7509
|
errored = false,
|
7034
7510
|
queueableFn = self.queueableFns[iterativeIndex],
|
7035
|
-
timeoutId
|
7511
|
+
timeoutId,
|
7512
|
+
maybeThenable;
|
7036
7513
|
|
7037
7514
|
next.fail = function nextFail() {
|
7038
7515
|
self.fail.apply(null, arguments);
|
@@ -7060,7 +7537,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|
7060
7537
|
|
7061
7538
|
try {
|
7062
7539
|
if (queueableFn.fn.length === 0) {
|
7063
|
-
|
7540
|
+
maybeThenable = queueableFn.fn.call(self.userContext);
|
7064
7541
|
|
7065
7542
|
if (maybeThenable && j$.isFunction_(maybeThenable.then)) {
|
7066
7543
|
maybeThenable.then(next, onPromiseRejection);
|
@@ -7068,7 +7545,8 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|
7068
7545
|
return { completedSynchronously: false };
|
7069
7546
|
}
|
7070
7547
|
} else {
|
7071
|
-
queueableFn.fn.call(self.userContext, next);
|
7548
|
+
maybeThenable = queueableFn.fn.call(self.userContext, next);
|
7549
|
+
this.diagnoseConflictingAsync_(queueableFn.fn, maybeThenable);
|
7072
7550
|
completedSynchronously = false;
|
7073
7551
|
return { completedSynchronously: false };
|
7074
7552
|
}
|
@@ -7121,6 +7599,29 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|
7121
7599
|
});
|
7122
7600
|
};
|
7123
7601
|
|
7602
|
+
QueueRunner.prototype.diagnoseConflictingAsync_ = function(fn, retval) {
|
7603
|
+
if (retval && j$.isFunction_(retval.then)) {
|
7604
|
+
// Issue a warning that matches the user's code
|
7605
|
+
if (j$.isAsyncFunction_(fn)) {
|
7606
|
+
this.deprecated(
|
7607
|
+
'An asynchronous before/it/after ' +
|
7608
|
+
'function was defined with the async keyword but also took a ' +
|
7609
|
+
'done callback. This is not supported and will stop working in' +
|
7610
|
+
' the future. Either remove the done callback (recommended) or ' +
|
7611
|
+
'remove the async keyword.'
|
7612
|
+
);
|
7613
|
+
} else {
|
7614
|
+
this.deprecated(
|
7615
|
+
'An asynchronous before/it/after ' +
|
7616
|
+
'function took a done callback but also returned a promise. ' +
|
7617
|
+
'This is not supported and will stop working in the future. ' +
|
7618
|
+
'Either remove the done callback (recommended) or change the ' +
|
7619
|
+
'function to not return a promise.'
|
7620
|
+
);
|
7621
|
+
}
|
7622
|
+
}
|
7623
|
+
};
|
7624
|
+
|
7124
7625
|
return QueueRunner;
|
7125
7626
|
};
|
7126
7627
|
|
@@ -7552,7 +8053,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
|
|
7552
8053
|
* @since 3.6.0
|
7553
8054
|
* @function
|
7554
8055
|
* @param {Function} formatter - A function which takes a value to format and returns a string if it knows how to format it, and `undefined` otherwise.
|
7555
|
-
* @see
|
8056
|
+
* @see custom_object_formatters
|
7556
8057
|
*/
|
7557
8058
|
jasmine.addCustomObjectFormatter = function(formatter) {
|
7558
8059
|
return env.addCustomObjectFormatter(formatter);
|
@@ -7887,6 +8388,7 @@ getJasmineRequireObj().SpyFactory = function(j$) {
|
|
7887
8388
|
var properties = normalizeKeyValues(propertyNames);
|
7888
8389
|
for (var i = 0; i < properties.length; i++) {
|
7889
8390
|
descriptor = {
|
8391
|
+
enumerable: true,
|
7890
8392
|
get: self.createSpy(baseName + '.' + properties[i][0] + '.get'),
|
7891
8393
|
set: self.createSpy(baseName + '.' + properties[i][0] + '.set')
|
7892
8394
|
};
|
@@ -8308,7 +8810,13 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
|
|
8308
8810
|
* @param {Function} fn The function to invoke with the passed parameters.
|
8309
8811
|
*/
|
8310
8812
|
SpyStrategy.prototype.callFake = function(fn) {
|
8311
|
-
if (
|
8813
|
+
if (
|
8814
|
+
!(
|
8815
|
+
j$.isFunction_(fn) ||
|
8816
|
+
j$.isAsyncFunction_(fn) ||
|
8817
|
+
j$.isGeneratorFunction_(fn)
|
8818
|
+
)
|
8819
|
+
) {
|
8312
8820
|
throw new Error(
|
8313
8821
|
'Argument passed to callFake should be a function, got ' + fn
|
8314
8822
|
);
|
@@ -8961,5 +9469,5 @@ getJasmineRequireObj().UserContext = function(j$) {
|
|
8961
9469
|
};
|
8962
9470
|
|
8963
9471
|
getJasmineRequireObj().version = function() {
|
8964
|
-
return '3.
|
9472
|
+
return '3.7.1';
|
8965
9473
|
};
|