jasmine-core 3.6.0 → 3.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (c) 2008-2020 Pivotal Labs
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) ||
@@ -263,9 +267,21 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
263
267
  };
264
268
 
265
269
  j$.isError_ = function(value) {
270
+ if (!value) {
271
+ return false;
272
+ }
273
+
266
274
  if (value instanceof Error) {
267
275
  return true;
268
276
  }
277
+ if (
278
+ typeof window !== 'undefined' &&
279
+ typeof window.trustedTypes !== 'undefined'
280
+ ) {
281
+ return (
282
+ typeof value.stack === 'string' && typeof value.message === 'string'
283
+ );
284
+ }
269
285
  if (value && value.constructor && value.constructor.constructor) {
270
286
  var valueGlobal = value.constructor.constructor('return this');
271
287
  if (j$.isFunction_(valueGlobal)) {
@@ -325,6 +341,15 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
325
341
  );
326
342
  };
327
343
 
344
+ j$.isURL = function(obj) {
345
+ return (
346
+ obj !== null &&
347
+ typeof obj !== 'undefined' &&
348
+ typeof jasmineGlobal.URL !== 'undefined' &&
349
+ obj.constructor === jasmineGlobal.URL
350
+ );
351
+ };
352
+
328
353
  j$.isDataView = function(obj) {
329
354
  return (
330
355
  obj !== null &&
@@ -358,6 +383,19 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
358
383
  return matches ? matches[1] : '<anonymous>';
359
384
  };
360
385
 
386
+ j$.isPending_ = function(promise) {
387
+ var sentinel = {};
388
+ // eslint-disable-next-line compat/compat
389
+ return Promise.race([promise, Promise.resolve(sentinel)]).then(
390
+ function(result) {
391
+ return result === sentinel;
392
+ },
393
+ function() {
394
+ return false;
395
+ }
396
+ );
397
+ };
398
+
361
399
  /**
362
400
  * Get a matcher, usable in any {@link matchers|matcher} that uses Jasmine's equality (e.g. {@link matchers#toEqual|toEqual}, {@link matchers#toContain|toContain}, or {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}),
363
401
  * that will succeed if the actual value being compared is an instance of the specified class/constructor.
@@ -499,6 +537,14 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
499
537
  return new j$.SetContaining(sample);
500
538
  };
501
539
 
540
+ /**
541
+ * Determines whether the provided function is a Jasmine spy.
542
+ * @name jasmine.isSpy
543
+ * @since 2.0.0
544
+ * @function
545
+ * @param {Function} putativeSpy - The function to check.
546
+ * @return {Boolean}
547
+ */
502
548
  j$.isSpy = function(putativeSpy) {
503
549
  if (!putativeSpy) {
504
550
  return false;
@@ -519,16 +565,6 @@ getJasmineRequireObj().util = function(j$) {
519
565
  childClass.prototype = new Subclass();
520
566
  };
521
567
 
522
- util.htmlEscape = function(str) {
523
- if (!str) {
524
- return str;
525
- }
526
- return str
527
- .replace(/&/g, '&amp;')
528
- .replace(/</g, '&lt;')
529
- .replace(/>/g, '&gt;');
530
- };
531
-
532
568
  util.argsToArray = function(args) {
533
569
  var arrayOfArgs = [];
534
570
  for (var i = 0; i < args.length; i++) {
@@ -668,11 +704,27 @@ getJasmineRequireObj().util = function(j$) {
668
704
  };
669
705
 
670
706
  getJasmineRequireObj().Spec = function(j$) {
707
+ /**
708
+ * @interface Spec
709
+ * @see Configuration#specFilter
710
+ */
671
711
  function Spec(attrs) {
672
712
  this.expectationFactory = attrs.expectationFactory;
673
713
  this.asyncExpectationFactory = attrs.asyncExpectationFactory;
674
714
  this.resultCallback = attrs.resultCallback || function() {};
715
+ /**
716
+ * The unique ID of this spec.
717
+ * @name Spec#id
718
+ * @readonly
719
+ * @type {string}
720
+ */
675
721
  this.id = attrs.id;
722
+ /**
723
+ * The description passed to the {@link it} that created this spec.
724
+ * @name Spec#description
725
+ * @readonly
726
+ * @type {string}
727
+ */
676
728
  this.description = attrs.description || '';
677
729
  this.queueableFn = attrs.queueableFn;
678
730
  this.beforeAndAfterFns =
@@ -864,6 +916,12 @@ getJasmineRequireObj().Spec = function(j$) {
864
916
  return 'passed';
865
917
  };
866
918
 
919
+ /**
920
+ * The full description including all ancestors of this spec.
921
+ * @name Spec#getFullName
922
+ * @function
923
+ * @returns {string}
924
+ */
867
925
  Spec.prototype.getFullName = function() {
868
926
  return this.getSpecName(this);
869
927
  };
@@ -952,11 +1010,12 @@ getJasmineRequireObj().Order = function() {
952
1010
 
953
1011
  getJasmineRequireObj().Env = function(j$) {
954
1012
  /**
955
- * _Note:_ Do not construct this directly, Jasmine will make one during booting.
956
- * @name Env
1013
+ * @class Env
957
1014
  * @since 2.0.0
958
- * @classdesc The Jasmine environment
959
- * @constructor
1015
+ * @classdesc The Jasmine environment.<br>
1016
+ * _Note:_ Do not construct this directly. You can obtain the Env instance by
1017
+ * calling {@link jasmine.getEnv}.
1018
+ * @hideconstructor
960
1019
  */
961
1020
  function Env(options) {
962
1021
  options = options || {};
@@ -987,7 +1046,8 @@ getJasmineRequireObj().Env = function(j$) {
987
1046
 
988
1047
  /**
989
1048
  * This represents the available options to configure Jasmine.
990
- * Options that are not provided will use their default values
1049
+ * Options that are not provided will use their default values.
1050
+ * @see Env#configure
991
1051
  * @interface Configuration
992
1052
  * @since 3.3.0
993
1053
  */
@@ -1005,7 +1065,7 @@ getJasmineRequireObj().Env = function(j$) {
1005
1065
  * Null causes the seed to be determined randomly at the start of execution.
1006
1066
  * @name Configuration#seed
1007
1067
  * @since 3.3.0
1008
- * @type function
1068
+ * @type (number|string)
1009
1069
  * @default null
1010
1070
  */
1011
1071
  seed: null,
@@ -1015,8 +1075,17 @@ getJasmineRequireObj().Env = function(j$) {
1015
1075
  * @since 3.3.0
1016
1076
  * @type Boolean
1017
1077
  * @default false
1078
+ * @deprecated Use the `stopOnSpecFailure` config property instead.
1018
1079
  */
1019
1080
  failFast: false,
1081
+ /**
1082
+ * Whether to stop execution of the suite after the first spec failure
1083
+ * @name Configuration#stopOnSpecFailure
1084
+ * @since 3.9.0
1085
+ * @type Boolean
1086
+ * @default false
1087
+ */
1088
+ stopOnSpecFailure: false,
1020
1089
  /**
1021
1090
  * Whether to fail the spec if it ran no expectations. By default
1022
1091
  * a spec that ran no expectations is reported as passed. Setting this
@@ -1033,14 +1102,30 @@ getJasmineRequireObj().Env = function(j$) {
1033
1102
  * @since 3.3.0
1034
1103
  * @type Boolean
1035
1104
  * @default false
1105
+ * @deprecated Use the `stopSpecOnExpectationFailure` config property instead.
1036
1106
  */
1037
1107
  oneFailurePerSpec: false,
1108
+ /**
1109
+ * Whether to cause specs to only have one expectation failure.
1110
+ * @name Configuration#stopSpecOnExpectationFailure
1111
+ * @since 3.3.0
1112
+ * @type Boolean
1113
+ * @default false
1114
+ */
1115
+ stopSpecOnExpectationFailure: false,
1116
+ /**
1117
+ * A function that takes a spec and returns true if it should be executed
1118
+ * or false if it should be skipped.
1119
+ * @callback SpecFilter
1120
+ * @param {Spec} spec - The spec that the filter is being applied to.
1121
+ * @return boolean
1122
+ */
1038
1123
  /**
1039
1124
  * Function to use to filter specs
1040
1125
  * @name Configuration#specFilter
1041
1126
  * @since 3.3.0
1042
- * @type function
1043
- * @default true
1127
+ * @type SpecFilter
1128
+ * @default A function that always returns true.
1044
1129
  */
1045
1130
  specFilter: function() {
1046
1131
  return true;
@@ -1113,33 +1198,64 @@ getJasmineRequireObj().Env = function(j$) {
1113
1198
  * @function
1114
1199
  */
1115
1200
  this.configure = function(configuration) {
1116
- if (configuration.specFilter) {
1117
- config.specFilter = configuration.specFilter;
1118
- }
1119
-
1120
- if (configuration.hasOwnProperty('random')) {
1121
- config.random = !!configuration.random;
1122
- }
1201
+ var booleanProps = [
1202
+ 'random',
1203
+ 'failSpecWithNoExpectations',
1204
+ 'hideDisabled'
1205
+ ];
1206
+
1207
+ booleanProps.forEach(function(prop) {
1208
+ if (typeof configuration[prop] !== 'undefined') {
1209
+ config[prop] = !!configuration[prop];
1210
+ }
1211
+ });
1123
1212
 
1124
- if (configuration.hasOwnProperty('seed')) {
1125
- config.seed = configuration.seed;
1126
- }
1213
+ if (typeof configuration.failFast !== 'undefined') {
1214
+ if (typeof configuration.stopOnSpecFailure !== 'undefined') {
1215
+ if (configuration.stopOnSpecFailure !== configuration.failFast) {
1216
+ throw new Error(
1217
+ 'stopOnSpecFailure and failFast are aliases for ' +
1218
+ "each other. Don't set failFast if you also set stopOnSpecFailure."
1219
+ );
1220
+ }
1221
+ }
1127
1222
 
1128
- if (configuration.hasOwnProperty('failFast')) {
1129
1223
  config.failFast = configuration.failFast;
1224
+ config.stopOnSpecFailure = configuration.failFast;
1225
+ } else if (typeof configuration.stopOnSpecFailure !== 'undefined') {
1226
+ config.failFast = configuration.stopOnSpecFailure;
1227
+ config.stopOnSpecFailure = configuration.stopOnSpecFailure;
1130
1228
  }
1131
1229
 
1132
- if (configuration.hasOwnProperty('failSpecWithNoExpectations')) {
1133
- config.failSpecWithNoExpectations =
1134
- configuration.failSpecWithNoExpectations;
1135
- }
1230
+ if (typeof configuration.oneFailurePerSpec !== 'undefined') {
1231
+ if (typeof configuration.stopSpecOnExpectationFailure !== 'undefined') {
1232
+ if (
1233
+ configuration.stopSpecOnExpectationFailure !==
1234
+ configuration.oneFailurePerSpec
1235
+ ) {
1236
+ throw new Error(
1237
+ 'stopSpecOnExpectationFailure and oneFailurePerSpec are aliases for ' +
1238
+ "each other. Don't set oneFailurePerSpec if you also set stopSpecOnExpectationFailure."
1239
+ );
1240
+ }
1241
+ }
1136
1242
 
1137
- if (configuration.hasOwnProperty('oneFailurePerSpec')) {
1138
1243
  config.oneFailurePerSpec = configuration.oneFailurePerSpec;
1244
+ config.stopSpecOnExpectationFailure = configuration.oneFailurePerSpec;
1245
+ } else if (
1246
+ typeof configuration.stopSpecOnExpectationFailure !== 'undefined'
1247
+ ) {
1248
+ config.oneFailurePerSpec = configuration.stopSpecOnExpectationFailure;
1249
+ config.stopSpecOnExpectationFailure =
1250
+ configuration.stopSpecOnExpectationFailure;
1251
+ }
1252
+
1253
+ if (configuration.specFilter) {
1254
+ config.specFilter = configuration.specFilter;
1139
1255
  }
1140
1256
 
1141
- if (configuration.hasOwnProperty('hideDisabled')) {
1142
- config.hideDisabled = configuration.hideDisabled;
1257
+ if (typeof configuration.seed !== 'undefined') {
1258
+ config.seed = configuration.seed;
1143
1259
  }
1144
1260
 
1145
1261
  // Don't use hasOwnProperty to check for Promise existence because Promise
@@ -1376,6 +1492,9 @@ getJasmineRequireObj().Env = function(j$) {
1376
1492
  resources.customAsyncMatchers = j$.util.clone(
1377
1493
  runnableResources[parentRunnableId].customAsyncMatchers
1378
1494
  );
1495
+ resources.customObjectFormatters = j$.util.clone(
1496
+ runnableResources[parentRunnableId].customObjectFormatters
1497
+ );
1379
1498
  resources.defaultStrategyFn =
1380
1499
  runnableResources[parentRunnableId].defaultStrategyFn;
1381
1500
  }
@@ -1434,18 +1553,22 @@ getJasmineRequireObj().Env = function(j$) {
1434
1553
  * @since 2.3.0
1435
1554
  * @function
1436
1555
  * @param {Boolean} value Whether to throw when a expectation fails
1437
- * @deprecated Use the `oneFailurePerSpec` option with {@link Env#configure}
1556
+ * @deprecated Use the `stopSpecOnExpectationFailure` option with {@link Env#configure}
1438
1557
  */
1439
1558
  this.throwOnExpectationFailure = function(value) {
1440
1559
  this.deprecated(
1441
- 'Setting throwOnExpectationFailure directly on Env is deprecated and will be removed in a future version of Jasmine, please use the oneFailurePerSpec option in `configure`'
1560
+ 'Setting throwOnExpectationFailure directly on Env is deprecated and ' +
1561
+ 'will be removed in a future version of Jasmine. Please use the ' +
1562
+ 'stopSpecOnExpectationFailure option in `configure`.'
1442
1563
  );
1443
1564
  this.configure({ oneFailurePerSpec: !!value });
1444
1565
  };
1445
1566
 
1446
1567
  this.throwingExpectationFailures = function() {
1447
1568
  this.deprecated(
1448
- 'Getting throwingExpectationFailures directly from Env is deprecated and will be removed in a future version of Jasmine, please check the oneFailurePerSpec option from `configuration`'
1569
+ 'Getting throwingExpectationFailures directly from Env is deprecated ' +
1570
+ 'and will be removed in a future version of Jasmine. Please check ' +
1571
+ 'the stopSpecOnExpectationFailure option from `configuration`.'
1449
1572
  );
1450
1573
  return config.oneFailurePerSpec;
1451
1574
  };
@@ -1456,18 +1579,22 @@ getJasmineRequireObj().Env = function(j$) {
1456
1579
  * @since 2.7.0
1457
1580
  * @function
1458
1581
  * @param {Boolean} value Whether to stop suite execution when a spec fails
1459
- * @deprecated Use the `failFast` option with {@link Env#configure}
1582
+ * @deprecated Use the `stopOnSpecFailure` option with {@link Env#configure}
1460
1583
  */
1461
1584
  this.stopOnSpecFailure = function(value) {
1462
1585
  this.deprecated(
1463
- 'Setting stopOnSpecFailure directly is deprecated and will be removed in a future version of Jasmine, please use the failFast option in `configure`'
1586
+ 'Setting stopOnSpecFailure directly is deprecated and will be ' +
1587
+ 'removed in a future version of Jasmine. Please use the ' +
1588
+ 'stopOnSpecFailure option in `configure`.'
1464
1589
  );
1465
- this.configure({ failFast: !!value });
1590
+ this.configure({ stopOnSpecFailure: !!value });
1466
1591
  };
1467
1592
 
1468
1593
  this.stoppingOnSpecFailure = function() {
1469
1594
  this.deprecated(
1470
- 'Getting stoppingOnSpecFailure directly from Env is deprecated and will be removed in a future version of Jasmine, please check the failFast option from `configuration`'
1595
+ 'Getting stoppingOnSpecFailure directly from Env is deprecated and ' +
1596
+ 'will be removed in a future version of Jasmine. Please check the ' +
1597
+ 'stopOnSpecFailure option from `configuration`.'
1471
1598
  );
1472
1599
  return config.failFast;
1473
1600
  };
@@ -1523,6 +1650,7 @@ getJasmineRequireObj().Env = function(j$) {
1523
1650
  * @name Env#hideDisabled
1524
1651
  * @since 3.2.0
1525
1652
  * @function
1653
+ * @deprecated Use the `hideDisabled` option with {@link Env#configure}
1526
1654
  */
1527
1655
  this.hideDisabled = function(value) {
1528
1656
  this.deprecated(
@@ -1533,21 +1661,31 @@ getJasmineRequireObj().Env = function(j$) {
1533
1661
 
1534
1662
  this.deprecated = function(deprecation) {
1535
1663
  var runnable = currentRunnable() || topSuite;
1664
+ var context;
1665
+
1666
+ if (runnable === topSuite) {
1667
+ context = '';
1668
+ } else if (runnable === currentSuite()) {
1669
+ context = ' (in suite: ' + runnable.getFullName() + ')';
1670
+ } else {
1671
+ context = ' (in spec: ' + runnable.getFullName() + ')';
1672
+ }
1673
+
1536
1674
  runnable.addDeprecationWarning(deprecation);
1537
1675
  if (
1538
1676
  typeof console !== 'undefined' &&
1539
1677
  typeof console.error === 'function'
1540
1678
  ) {
1541
- console.error('DEPRECATION:', deprecation);
1679
+ console.error('DEPRECATION: ' + deprecation + context);
1542
1680
  }
1543
1681
  };
1544
1682
 
1545
1683
  var queueRunnerFactory = function(options, args) {
1546
1684
  var failFast = false;
1547
1685
  if (options.isLeaf) {
1548
- failFast = config.oneFailurePerSpec;
1686
+ failFast = config.stopSpecOnExpectationFailure;
1549
1687
  } else if (!options.isReporter) {
1550
- failFast = config.failFast;
1688
+ failFast = config.stopOnSpecFailure;
1551
1689
  }
1552
1690
  options.clearStack = options.clearStack || clearStack;
1553
1691
  options.timeout = {
@@ -1578,6 +1716,13 @@ getJasmineRequireObj().Env = function(j$) {
1578
1716
  defaultResourcesForRunnable(topSuite.id);
1579
1717
  currentDeclarationSuite = topSuite;
1580
1718
 
1719
+ /**
1720
+ * Provides the root suite, through which all suites and specs can be
1721
+ * accessed.
1722
+ * @function
1723
+ * @name Env#topSuite
1724
+ * @return {Suite} the root suite
1725
+ */
1581
1726
  this.topSuite = function() {
1582
1727
  return topSuite;
1583
1728
  };
@@ -1657,7 +1802,34 @@ getJasmineRequireObj().Env = function(j$) {
1657
1802
  queueRunnerFactory
1658
1803
  );
1659
1804
 
1660
- this.execute = function(runnablesToRun) {
1805
+ /**
1806
+ * Executes the specs.
1807
+ *
1808
+ * If called with no parameters or with a falsy value as the first parameter,
1809
+ * all specs will be executed except those that are excluded by a
1810
+ * [spec filter]{@link Configuration#specFilter} or other mechanism. If the
1811
+ * first parameter is a list of spec/suite IDs, only those specs/suites will
1812
+ * be run.
1813
+ *
1814
+ * Both parameters are optional, but a completion callback is only valid as
1815
+ * the second parameter. To specify a completion callback but not a list of
1816
+ * specs/suites to run, pass null or undefined as the first parameter.
1817
+ *
1818
+ * execute should not be called more than once.
1819
+ *
1820
+ * If the environment supports promises, execute will return a promise that
1821
+ * is resolved after the suite finishes executing. The promise will be
1822
+ * resolved (not rejected) as long as the suite runs to completion. Use a
1823
+ * {@link Reporter} to determine whether or not the suite passed.
1824
+ *
1825
+ * @name Env#execute
1826
+ * @since 2.0.0
1827
+ * @function
1828
+ * @param {(string[])=} runnablesToRun IDs of suites and/or specs to run
1829
+ * @param {Function=} onComplete Function that will be called after all specs have run
1830
+ * @return {Promise<undefined>}
1831
+ */
1832
+ this.execute = function(runnablesToRun, onComplete) {
1661
1833
  installGlobalErrors();
1662
1834
 
1663
1835
  if (!runnablesToRun) {
@@ -1715,61 +1887,86 @@ getJasmineRequireObj().Env = function(j$) {
1715
1887
  var jasmineTimer = new j$.Timer();
1716
1888
  jasmineTimer.start();
1717
1889
 
1718
- /**
1719
- * Information passed to the {@link Reporter#jasmineStarted} event.
1720
- * @typedef JasmineStartedInfo
1721
- * @property {Int} totalSpecsDefined - The total number of specs defined in this suite.
1722
- * @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
1723
- */
1724
- reporter.jasmineStarted(
1725
- {
1726
- totalSpecsDefined: totalSpecsDefined,
1727
- order: order
1728
- },
1729
- function() {
1730
- currentlyExecutingSuites.push(topSuite);
1731
-
1732
- processor.execute(function() {
1733
- clearResourcesForRunnable(topSuite.id);
1734
- currentlyExecutingSuites.pop();
1735
- var overallStatus, incompleteReason;
1736
-
1737
- if (hasFailures || topSuite.result.failedExpectations.length > 0) {
1738
- overallStatus = 'failed';
1739
- } else if (focusedRunnables.length > 0) {
1740
- overallStatus = 'incomplete';
1741
- incompleteReason = 'fit() or fdescribe() was found';
1742
- } else if (totalSpecsDefined === 0) {
1743
- overallStatus = 'incomplete';
1744
- incompleteReason = 'No specs found';
1745
- } else {
1746
- overallStatus = 'passed';
1890
+ var Promise = customPromise || global.Promise;
1891
+
1892
+ if (Promise) {
1893
+ return new Promise(function(resolve) {
1894
+ runAll(function() {
1895
+ if (onComplete) {
1896
+ onComplete();
1747
1897
  }
1748
1898
 
1749
- /**
1750
- * Information passed to the {@link Reporter#jasmineDone} event.
1751
- * @typedef JasmineDoneInfo
1752
- * @property {OverallStatus} overallStatus - The overall result of the suite: 'passed', 'failed', or 'incomplete'.
1753
- * @property {Int} totalTime - The total time (in ms) that it took to execute the suite
1754
- * @property {IncompleteReason} incompleteReason - Explanation of why the suite was incomplete.
1755
- * @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
1756
- * @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
1757
- * @property {Expectation[]} deprecationWarnings - List of deprecation warnings that occurred at the global level.
1758
- */
1759
- reporter.jasmineDone(
1760
- {
1761
- overallStatus: overallStatus,
1762
- totalTime: jasmineTimer.elapsed(),
1763
- incompleteReason: incompleteReason,
1764
- order: order,
1765
- failedExpectations: topSuite.result.failedExpectations,
1766
- deprecationWarnings: topSuite.result.deprecationWarnings
1767
- },
1768
- function() {}
1769
- );
1899
+ resolve();
1770
1900
  });
1771
- }
1772
- );
1901
+ });
1902
+ } else {
1903
+ runAll(function() {
1904
+ if (onComplete) {
1905
+ onComplete();
1906
+ }
1907
+ });
1908
+ }
1909
+
1910
+ function runAll(done) {
1911
+ /**
1912
+ * Information passed to the {@link Reporter#jasmineStarted} event.
1913
+ * @typedef JasmineStartedInfo
1914
+ * @property {Int} totalSpecsDefined - The total number of specs defined in this suite.
1915
+ * @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
1916
+ */
1917
+ reporter.jasmineStarted(
1918
+ {
1919
+ totalSpecsDefined: totalSpecsDefined,
1920
+ order: order
1921
+ },
1922
+ function() {
1923
+ currentlyExecutingSuites.push(topSuite);
1924
+
1925
+ processor.execute(function() {
1926
+ clearResourcesForRunnable(topSuite.id);
1927
+ currentlyExecutingSuites.pop();
1928
+ var overallStatus, incompleteReason;
1929
+
1930
+ if (
1931
+ hasFailures ||
1932
+ topSuite.result.failedExpectations.length > 0
1933
+ ) {
1934
+ overallStatus = 'failed';
1935
+ } else if (focusedRunnables.length > 0) {
1936
+ overallStatus = 'incomplete';
1937
+ incompleteReason = 'fit() or fdescribe() was found';
1938
+ } else if (totalSpecsDefined === 0) {
1939
+ overallStatus = 'incomplete';
1940
+ incompleteReason = 'No specs found';
1941
+ } else {
1942
+ overallStatus = 'passed';
1943
+ }
1944
+
1945
+ /**
1946
+ * Information passed to the {@link Reporter#jasmineDone} event.
1947
+ * @typedef JasmineDoneInfo
1948
+ * @property {OverallStatus} overallStatus - The overall result of the suite: 'passed', 'failed', or 'incomplete'.
1949
+ * @property {Int} totalTime - The total time (in ms) that it took to execute the suite
1950
+ * @property {IncompleteReason} incompleteReason - Explanation of why the suite was incomplete.
1951
+ * @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
1952
+ * @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
1953
+ * @property {Expectation[]} deprecationWarnings - List of deprecation warnings that occurred at the global level.
1954
+ */
1955
+ reporter.jasmineDone(
1956
+ {
1957
+ overallStatus: overallStatus,
1958
+ totalTime: jasmineTimer.elapsed(),
1959
+ incompleteReason: incompleteReason,
1960
+ order: order,
1961
+ failedExpectations: topSuite.result.failedExpectations,
1962
+ deprecationWarnings: topSuite.result.deprecationWarnings
1963
+ },
1964
+ done
1965
+ );
1966
+ });
1967
+ }
1968
+ );
1969
+ }
1773
1970
  };
1774
1971
 
1775
1972
  /**
@@ -1844,6 +2041,15 @@ getJasmineRequireObj().Env = function(j$) {
1844
2041
  }
1845
2042
  });
1846
2043
 
2044
+ /**
2045
+ * Configures whether Jasmine should allow the same function to be spied on
2046
+ * more than once during the execution of a spec. By default, spying on
2047
+ * a function that is already a spy will cause an error.
2048
+ * @name Env#allowRespy
2049
+ * @function
2050
+ * @since 2.5.0
2051
+ * @param {boolean} allow Whether to allow respying
2052
+ */
1847
2053
  this.allowRespy = function(allow) {
1848
2054
  spyRegistry.allowRespy(allow);
1849
2055
  };
@@ -2350,12 +2556,11 @@ getJasmineRequireObj().JsApiReporter = function(j$) {
2350
2556
  };
2351
2557
 
2352
2558
  getJasmineRequireObj().Any = function(j$) {
2353
-
2354
2559
  function Any(expectedObject) {
2355
2560
  if (typeof expectedObject === 'undefined') {
2356
2561
  throw new TypeError(
2357
2562
  'jasmine.any() expects to be passed a constructor function. ' +
2358
- 'Please pass one or use jasmine.anything() to match any object.'
2563
+ 'Please pass one or use jasmine.anything() to match any object.'
2359
2564
  );
2360
2565
  }
2361
2566
  this.expectedObject = expectedObject;
@@ -2400,7 +2605,6 @@ getJasmineRequireObj().Any = function(j$) {
2400
2605
  };
2401
2606
 
2402
2607
  getJasmineRequireObj().Anything = function(j$) {
2403
-
2404
2608
  function Anything() {}
2405
2609
 
2406
2610
  Anything.prototype.asymmetricMatch = function(other) {
@@ -2421,7 +2625,11 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
2421
2625
 
2422
2626
  ArrayContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
2423
2627
  if (!j$.isArray_(this.sample)) {
2424
- throw new Error('You must provide an array to arrayContaining, not ' + j$.pp(this.sample) + '.');
2628
+ throw new Error(
2629
+ 'You must provide an array to arrayContaining, not ' +
2630
+ j$.pp(this.sample) +
2631
+ '.'
2632
+ );
2425
2633
  }
2426
2634
 
2427
2635
  // If the actual parameter is not an array, we can fail immediately, since it couldn't
@@ -2441,22 +2649,28 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
2441
2649
  return true;
2442
2650
  };
2443
2651
 
2444
- ArrayContaining.prototype.jasmineToString = function (pp) {
2445
- return '<jasmine.arrayContaining(' + pp(this.sample) +')>';
2652
+ ArrayContaining.prototype.jasmineToString = function(pp) {
2653
+ return '<jasmine.arrayContaining(' + pp(this.sample) + ')>';
2446
2654
  };
2447
2655
 
2448
2656
  return ArrayContaining;
2449
2657
  };
2450
2658
 
2451
2659
  getJasmineRequireObj().ArrayWithExactContents = function(j$) {
2452
-
2453
2660
  function ArrayWithExactContents(sample) {
2454
2661
  this.sample = sample;
2455
2662
  }
2456
2663
 
2457
- ArrayWithExactContents.prototype.asymmetricMatch = function(other, matchersUtil) {
2664
+ ArrayWithExactContents.prototype.asymmetricMatch = function(
2665
+ other,
2666
+ matchersUtil
2667
+ ) {
2458
2668
  if (!j$.isArray_(this.sample)) {
2459
- throw new Error('You must provide an array to arrayWithExactContents, not ' + j$.pp(this.sample) + '.');
2669
+ throw new Error(
2670
+ 'You must provide an array to arrayWithExactContents, not ' +
2671
+ j$.pp(this.sample) +
2672
+ '.'
2673
+ );
2460
2674
  }
2461
2675
 
2462
2676
  if (this.sample.length !== other.length) {
@@ -2480,11 +2694,10 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$) {
2480
2694
  return ArrayWithExactContents;
2481
2695
  };
2482
2696
 
2483
- getJasmineRequireObj().Empty = function (j$) {
2484
-
2697
+ getJasmineRequireObj().Empty = function(j$) {
2485
2698
  function Empty() {}
2486
2699
 
2487
- Empty.prototype.asymmetricMatch = function (other) {
2700
+ Empty.prototype.asymmetricMatch = function(other) {
2488
2701
  if (j$.isString_(other) || j$.isArray_(other) || j$.isTypedArray_(other)) {
2489
2702
  return other.length === 0;
2490
2703
  }
@@ -2499,7 +2712,7 @@ getJasmineRequireObj().Empty = function (j$) {
2499
2712
  return false;
2500
2713
  };
2501
2714
 
2502
- Empty.prototype.jasmineToString = function () {
2715
+ Empty.prototype.jasmineToString = function() {
2503
2716
  return '<jasmine.empty>';
2504
2717
  };
2505
2718
 
@@ -2507,7 +2720,6 @@ getJasmineRequireObj().Empty = function (j$) {
2507
2720
  };
2508
2721
 
2509
2722
  getJasmineRequireObj().Falsy = function(j$) {
2510
-
2511
2723
  function Falsy() {}
2512
2724
 
2513
2725
  Falsy.prototype.asymmetricMatch = function(other) {
@@ -2524,7 +2736,9 @@ getJasmineRequireObj().Falsy = function(j$) {
2524
2736
  getJasmineRequireObj().MapContaining = function(j$) {
2525
2737
  function MapContaining(sample) {
2526
2738
  if (!j$.isMap(sample)) {
2527
- throw new Error('You must provide a map to `mapContaining`, not ' + j$.pp(sample));
2739
+ throw new Error(
2740
+ 'You must provide a map to `mapContaining`, not ' + j$.pp(sample)
2741
+ );
2528
2742
  }
2529
2743
 
2530
2744
  this.sample = sample;
@@ -2540,8 +2754,8 @@ getJasmineRequireObj().MapContaining = function(j$) {
2540
2754
  var hasMatch = false;
2541
2755
  j$.util.forEachBreakable(other, function(oBreakLoop, oValue, oKey) {
2542
2756
  if (
2543
- matchersUtil.equals(oKey, key)
2544
- && matchersUtil.equals(oValue, value)
2757
+ matchersUtil.equals(oKey, key) &&
2758
+ matchersUtil.equals(oValue, value)
2545
2759
  ) {
2546
2760
  hasMatch = true;
2547
2761
  oBreakLoop();
@@ -2563,11 +2777,10 @@ getJasmineRequireObj().MapContaining = function(j$) {
2563
2777
  return MapContaining;
2564
2778
  };
2565
2779
 
2566
- getJasmineRequireObj().NotEmpty = function (j$) {
2567
-
2780
+ getJasmineRequireObj().NotEmpty = function(j$) {
2568
2781
  function NotEmpty() {}
2569
2782
 
2570
- NotEmpty.prototype.asymmetricMatch = function (other) {
2783
+ NotEmpty.prototype.asymmetricMatch = function(other) {
2571
2784
  if (j$.isString_(other) || j$.isArray_(other) || j$.isTypedArray_(other)) {
2572
2785
  return other.length !== 0;
2573
2786
  }
@@ -2583,7 +2796,7 @@ getJasmineRequireObj().NotEmpty = function (j$) {
2583
2796
  return false;
2584
2797
  };
2585
2798
 
2586
- NotEmpty.prototype.jasmineToString = function () {
2799
+ NotEmpty.prototype.jasmineToString = function() {
2587
2800
  return '<jasmine.notEmpty>';
2588
2801
  };
2589
2802
 
@@ -2591,7 +2804,6 @@ getJasmineRequireObj().NotEmpty = function (j$) {
2591
2804
  };
2592
2805
 
2593
2806
  getJasmineRequireObj().ObjectContaining = function(j$) {
2594
-
2595
2807
  function ObjectContaining(sample) {
2596
2808
  this.sample = sample;
2597
2809
  }
@@ -2609,7 +2821,7 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
2609
2821
  }
2610
2822
 
2611
2823
  function hasProperty(obj, property) {
2612
- if (!obj || typeof(obj) !== 'object') {
2824
+ if (!obj || typeof obj !== 'object') {
2613
2825
  return false;
2614
2826
  }
2615
2827
 
@@ -2621,12 +2833,22 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
2621
2833
  }
2622
2834
 
2623
2835
  ObjectContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
2624
- if (typeof(this.sample) !== 'object') { throw new Error('You must provide an object to objectContaining, not \''+this.sample+'\'.'); }
2625
- if (typeof(other) !== 'object') { return false; }
2836
+ if (typeof this.sample !== 'object') {
2837
+ throw new Error(
2838
+ "You must provide an object to objectContaining, not '" +
2839
+ this.sample +
2840
+ "'."
2841
+ );
2842
+ }
2843
+ if (typeof other !== 'object') {
2844
+ return false;
2845
+ }
2626
2846
 
2627
2847
  for (var property in this.sample) {
2628
- if (!hasProperty(other, property) ||
2629
- !matchersUtil.equals(this.sample[property], other[property])) {
2848
+ if (
2849
+ !hasProperty(other, property) ||
2850
+ !matchersUtil.equals(this.sample[property], other[property])
2851
+ ) {
2630
2852
  return false;
2631
2853
  }
2632
2854
  }
@@ -2643,7 +2865,7 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
2643
2865
  }
2644
2866
 
2645
2867
  var filteredOther = {};
2646
- Object.keys(this.sample).forEach(function (k) {
2868
+ Object.keys(this.sample).forEach(function(k) {
2647
2869
  // eq short-circuits comparison of objects that have different key sets,
2648
2870
  // so include all keys even if undefined.
2649
2871
  filteredOther[k] = other[k];
@@ -2665,7 +2887,9 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
2665
2887
  getJasmineRequireObj().SetContaining = function(j$) {
2666
2888
  function SetContaining(sample) {
2667
2889
  if (!j$.isSet(sample)) {
2668
- throw new Error('You must provide a set to `setContaining`, not ' + j$.pp(sample));
2890
+ throw new Error(
2891
+ 'You must provide a set to `setContaining`, not ' + j$.pp(sample)
2892
+ );
2669
2893
  }
2670
2894
 
2671
2895
  this.sample = sample;
@@ -2703,7 +2927,6 @@ getJasmineRequireObj().SetContaining = function(j$) {
2703
2927
  };
2704
2928
 
2705
2929
  getJasmineRequireObj().StringMatching = function(j$) {
2706
-
2707
2930
  function StringMatching(expected) {
2708
2931
  if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) {
2709
2932
  throw new Error('Expected is not a String or a RegExp');
@@ -2724,7 +2947,6 @@ getJasmineRequireObj().StringMatching = function(j$) {
2724
2947
  };
2725
2948
 
2726
2949
  getJasmineRequireObj().Truthy = function(j$) {
2727
-
2728
2950
  function Truthy() {}
2729
2951
 
2730
2952
  Truthy.prototype.asymmetricMatch = function(other) {
@@ -2806,7 +3028,9 @@ getJasmineRequireObj().asymmetricEqualityTesterArgCompatShim = function(j$) {
2806
3028
 
2807
3029
  for (i = 0; i < props.length; i++) {
2808
3030
  k = props[i];
2809
- if (k !== 'length') {
3031
+ // Skip length (dealt with above), and anything that collides with
3032
+ // MatchesUtil e.g. an Array.prototype.contains method added by user code
3033
+ if (k !== 'length' && !self[k]) {
2810
3034
  copy(self, Array.prototype, k);
2811
3035
  }
2812
3036
  }
@@ -2895,6 +3119,18 @@ getJasmineRequireObj().CallTracker = function(j$) {
2895
3119
  return call ? call.args : [];
2896
3120
  };
2897
3121
 
3122
+ /**
3123
+ * Get the "this" object that was passed to a specific invocation of this spy.
3124
+ * @name Spy#calls#thisFor
3125
+ * @function
3126
+ * @param {Integer} index The 0-based invocation index.
3127
+ * @return {Object?}
3128
+ */
3129
+ this.thisFor = function(index) {
3130
+ var call = calls[index];
3131
+ return call ? call.object : undefined;
3132
+ };
3133
+
2898
3134
  /**
2899
3135
  * Get the raw calls array for this spy.
2900
3136
  * @name Spy#calls#all
@@ -3046,9 +3282,11 @@ getJasmineRequireObj().Clock = function() {
3046
3282
  typeof process.versions.node === 'string';
3047
3283
 
3048
3284
  /**
3049
- * _Note:_ Do not construct this directly, Jasmine will make one during booting. You can get the current clock with {@link jasmine.clock}.
3050
3285
  * @class Clock
3051
- * @classdesc Jasmine's mock clock is used when testing time dependent code.
3286
+ * @classdesc Jasmine's mock clock is used when testing time dependent code.<br>
3287
+ * _Note:_ Do not construct this directly. You can get the current clock with
3288
+ * {@link jasmine.clock}.
3289
+ * @hideconstructor
3052
3290
  */
3053
3291
  function Clock(global, delayedFunctionSchedulerFactory, mockDate) {
3054
3292
  var self = this,
@@ -3522,7 +3760,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
3522
3760
  stackTrace.style === 'webkit' ? '<Jasmine>' : ' at <Jasmine>';
3523
3761
 
3524
3762
  stackTrace.frames.forEach(function(frame) {
3525
- if (frame.file && frame.file !== jasmineFile) {
3763
+ if (frame.file !== jasmineFile) {
3526
3764
  result.push(frame.raw);
3527
3765
  } else if (result[result.length - 1] !== jasmineMarker) {
3528
3766
  result.push(jasmineMarker);
@@ -3604,7 +3842,35 @@ getJasmineRequireObj().Expectation = function(j$) {
3604
3842
  });
3605
3843
 
3606
3844
  /**
3607
- * Asynchronous matchers.
3845
+ * Asynchronous matchers that operate on an actual value which is a promise,
3846
+ * and return a promise.
3847
+ *
3848
+ * Most async matchers will wait indefinitely for the promise to be resolved
3849
+ * or rejected, resulting in a spec timeout if that never happens. If you
3850
+ * expect that the promise will already be resolved or rejected at the time
3851
+ * the matcher is called, you can use the {@link async-matchers#already}
3852
+ * modifier to get a faster failure with a more helpful message.
3853
+ *
3854
+ * Note: Specs must await the result of each async matcher, return the
3855
+ * promise returned by the matcher, or return a promise that's derived from
3856
+ * the one returned by the matcher. Otherwise the matcher will not be
3857
+ * evaluated before the spec completes.
3858
+ *
3859
+ * @example
3860
+ * // Good
3861
+ * await expectAsync(aPromise).toBeResolved();
3862
+ * @example
3863
+ * // Good
3864
+ * return expectAsync(aPromise).toBeResolved();
3865
+ * @example
3866
+ * // Good
3867
+ * return expectAsync(aPromise).toBeResolved()
3868
+ * .then(function() {
3869
+ * // more spec code
3870
+ * });
3871
+ * @example
3872
+ * // Bad
3873
+ * expectAsync(aPromise).toBeResolved();
3608
3874
  * @namespace async-matchers
3609
3875
  */
3610
3876
  function AsyncExpectation(options) {
@@ -3654,6 +3920,23 @@ getJasmineRequireObj().Expectation = function(j$) {
3654
3920
  }
3655
3921
  });
3656
3922
 
3923
+ /**
3924
+ * Fail as soon as possible if the actual is pending.
3925
+ * Otherwise evaluate the matcher.
3926
+ * @member
3927
+ * @name async-matchers#already
3928
+ * @type {async-matchers}
3929
+ * @example
3930
+ * await expectAsync(myPromise).already.toBeResolved();
3931
+ * @example
3932
+ * return expectAsync(myPromise).already.toBeResolved();
3933
+ */
3934
+ Object.defineProperty(AsyncExpectation.prototype, 'already', {
3935
+ get: function() {
3936
+ return addFilter(this, expectSettledPromiseFilter);
3937
+ }
3938
+ });
3939
+
3657
3940
  function wrapSyncCompare(name, matcherFactory) {
3658
3941
  return function() {
3659
3942
  var result = this.expector.compare(name, matcherFactory, arguments);
@@ -3732,6 +4015,27 @@ getJasmineRequireObj().Expectation = function(j$) {
3732
4015
  buildFailureMessage: negatedFailureMessage
3733
4016
  };
3734
4017
 
4018
+ var expectSettledPromiseFilter = {
4019
+ selectComparisonFunc: function(matcher) {
4020
+ return function(actual) {
4021
+ var matcherArgs = arguments;
4022
+
4023
+ return j$.isPending_(actual).then(function(isPending) {
4024
+ if (isPending) {
4025
+ return {
4026
+ pass: false,
4027
+ message:
4028
+ 'Expected a promise to be settled (via ' +
4029
+ 'expectAsync(...).already) but it was pending.'
4030
+ };
4031
+ } else {
4032
+ return matcher.compare.apply(null, matcherArgs);
4033
+ }
4034
+ });
4035
+ };
4036
+ }
4037
+ };
4038
+
3735
4039
  function ContextAddingFilter(message) {
3736
4040
  this.message = message;
3737
4041
  }
@@ -4027,7 +4331,28 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
4027
4331
  this.jasmineHandlers = {};
4028
4332
  this.installOne_ = function installOne_(errorType, jasmineMessage) {
4029
4333
  function taggedOnError(error) {
4030
- error.jasmineMessage = jasmineMessage + ': ' + error;
4334
+ var substituteMsg;
4335
+
4336
+ if (j$.isError_(error)) {
4337
+ error.jasmineMessage = jasmineMessage + ': ' + error;
4338
+ } else {
4339
+ if (error) {
4340
+ substituteMsg = jasmineMessage + ': ' + error;
4341
+ } else {
4342
+ substituteMsg = jasmineMessage + ' with no error or message';
4343
+ }
4344
+
4345
+ if (errorType === 'unhandledRejection') {
4346
+ substituteMsg +=
4347
+ '\n' +
4348
+ '(Tip: to get a useful stack trace, use ' +
4349
+ 'Promise.reject(new Error(...)) instead of Promise.reject(' +
4350
+ (error ? '...' : '') +
4351
+ ').)';
4352
+ }
4353
+
4354
+ error = new Error(substituteMsg);
4355
+ }
4031
4356
 
4032
4357
  var handler = handlers[handlers.length - 1];
4033
4358
 
@@ -4077,9 +4402,9 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
4077
4402
  if (j$.isError_(event.reason)) {
4078
4403
  event.reason.jasmineMessage =
4079
4404
  'Unhandled promise rejection: ' + event.reason;
4080
- onerror(event.reason);
4405
+ global.onerror(event.reason);
4081
4406
  } else {
4082
- onerror('Unhandled promise rejection: ' + event.reason);
4407
+ global.onerror('Unhandled promise rejection: ' + event.reason);
4083
4408
  }
4084
4409
  };
4085
4410
 
@@ -4106,7 +4431,11 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
4106
4431
  handlers.push(listener);
4107
4432
  };
4108
4433
 
4109
- this.popListener = function popListener() {
4434
+ this.popListener = function popListener(listener) {
4435
+ if (!listener) {
4436
+ throw new Error('popListener expects a listener');
4437
+ }
4438
+
4110
4439
  handlers.pop();
4111
4440
  };
4112
4441
  }
@@ -4117,7 +4446,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
4117
4446
  /* eslint-disable compat/compat */
4118
4447
  getJasmineRequireObj().toBePending = function(j$) {
4119
4448
  /**
4120
- * Expect a promise to be pending, ie. the promise is neither resolved nor rejected.
4449
+ * Expect a promise to be pending, i.e. the promise is neither resolved nor rejected.
4121
4450
  * @function
4122
4451
  * @async
4123
4452
  * @name async-matchers#toBePending
@@ -4133,8 +4462,12 @@ getJasmineRequireObj().toBePending = function(j$) {
4133
4462
  }
4134
4463
  var want = {};
4135
4464
  return Promise.race([actual, Promise.resolve(want)]).then(
4136
- function(got) { return {pass: want === got}; },
4137
- function() { return {pass: false}; }
4465
+ function(got) {
4466
+ return { pass: want === got };
4467
+ },
4468
+ function() {
4469
+ return { pass: false };
4470
+ }
4138
4471
  );
4139
4472
  }
4140
4473
  };
@@ -4160,8 +4493,12 @@ getJasmineRequireObj().toBeRejected = function(j$) {
4160
4493
  throw new Error('Expected toBeRejected to be called on a promise.');
4161
4494
  }
4162
4495
  return actual.then(
4163
- function() { return {pass: false}; },
4164
- function() { return {pass: true}; }
4496
+ function() {
4497
+ return { pass: false };
4498
+ },
4499
+ function() {
4500
+ return { pass: true };
4501
+ }
4165
4502
  );
4166
4503
  }
4167
4504
  };
@@ -4185,35 +4522,44 @@ getJasmineRequireObj().toBeRejectedWith = function(j$) {
4185
4522
  return {
4186
4523
  compare: function(actualPromise, expectedValue) {
4187
4524
  if (!j$.isPromiseLike(actualPromise)) {
4188
- throw new Error('Expected toBeRejectedWith to be called on a promise.');
4525
+ throw new Error(
4526
+ 'Expected toBeRejectedWith to be called on a promise.'
4527
+ );
4189
4528
  }
4190
4529
 
4191
4530
  function prefix(passed) {
4192
- return 'Expected a promise ' +
4531
+ return (
4532
+ 'Expected a promise ' +
4193
4533
  (passed ? 'not ' : '') +
4194
- 'to be rejected with ' + matchersUtil.pp(expectedValue);
4534
+ 'to be rejected with ' +
4535
+ matchersUtil.pp(expectedValue)
4536
+ );
4195
4537
  }
4196
4538
 
4197
4539
  return actualPromise.then(
4198
4540
  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
4541
  return {
4212
4542
  pass: false,
4213
- message: prefix(false) + ' but it was rejected with ' + matchersUtil.pp(actualValue) + '.'
4543
+ message: prefix(false) + ' but it was resolved.'
4214
4544
  };
4545
+ },
4546
+ function(actualValue) {
4547
+ if (matchersUtil.equals(actualValue, expectedValue)) {
4548
+ return {
4549
+ pass: true,
4550
+ message: prefix(true) + '.'
4551
+ };
4552
+ } else {
4553
+ return {
4554
+ pass: false,
4555
+ message:
4556
+ prefix(false) +
4557
+ ' but it was rejected with ' +
4558
+ matchersUtil.pp(actualValue) +
4559
+ '.'
4560
+ };
4561
+ }
4215
4562
  }
4216
- }
4217
4563
  );
4218
4564
  }
4219
4565
  };
@@ -4240,7 +4586,9 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
4240
4586
  return {
4241
4587
  compare: function(actualPromise, arg1, arg2) {
4242
4588
  if (!j$.isPromiseLike(actualPromise)) {
4243
- throw new Error('Expected toBeRejectedWithError to be called on a promise.');
4589
+ throw new Error(
4590
+ 'Expected toBeRejectedWithError to be called on a promise.'
4591
+ );
4244
4592
  }
4245
4593
 
4246
4594
  var expected = getExpectedFromArgs(arg1, arg2, matchersUtil);
@@ -4252,7 +4600,9 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
4252
4600
  message: 'Expected a promise to be rejected but it was resolved.'
4253
4601
  };
4254
4602
  },
4255
- function(actualValue) { return matchError(actualValue, expected, matchersUtil); }
4603
+ function(actualValue) {
4604
+ return matchError(actualValue, expected, matchersUtil);
4605
+ }
4256
4606
  );
4257
4607
  }
4258
4608
  };
@@ -4264,16 +4614,25 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
4264
4614
  }
4265
4615
 
4266
4616
  if (!(actual instanceof expected.error)) {
4267
- return fail(expected, 'rejected with type ' + j$.fnNameFor(actual.constructor));
4617
+ return fail(
4618
+ expected,
4619
+ 'rejected with type ' + j$.fnNameFor(actual.constructor)
4620
+ );
4268
4621
  }
4269
4622
 
4270
4623
  var actualMessage = actual.message;
4271
4624
 
4272
- if (actualMessage === expected.message || typeof expected.message === 'undefined') {
4625
+ if (
4626
+ actualMessage === expected.message ||
4627
+ typeof expected.message === 'undefined'
4628
+ ) {
4273
4629
  return pass(expected);
4274
4630
  }
4275
4631
 
4276
- if (expected.message instanceof RegExp && expected.message.test(actualMessage)) {
4632
+ if (
4633
+ expected.message instanceof RegExp &&
4634
+ expected.message.test(actualMessage)
4635
+ ) {
4277
4636
  return pass(expected);
4278
4637
  }
4279
4638
 
@@ -4283,18 +4642,25 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
4283
4642
  function pass(expected) {
4284
4643
  return {
4285
4644
  pass: true,
4286
- message: 'Expected a promise not to be rejected with ' + expected.printValue + ', but it was.'
4645
+ message:
4646
+ 'Expected a promise not to be rejected with ' +
4647
+ expected.printValue +
4648
+ ', but it was.'
4287
4649
  };
4288
4650
  }
4289
4651
 
4290
4652
  function fail(expected, message) {
4291
4653
  return {
4292
4654
  pass: false,
4293
- message: 'Expected a promise to be rejected with ' + expected.printValue + ' but it was ' + message + '.'
4655
+ message:
4656
+ 'Expected a promise to be rejected with ' +
4657
+ expected.printValue +
4658
+ ' but it was ' +
4659
+ message +
4660
+ '.'
4294
4661
  };
4295
4662
  }
4296
4663
 
4297
-
4298
4664
  function getExpectedFromArgs(arg1, arg2, matchersUtil) {
4299
4665
  var error, message;
4300
4666
 
@@ -4309,12 +4675,17 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
4309
4675
  return {
4310
4676
  error: error,
4311
4677
  message: message,
4312
- printValue: j$.fnNameFor(error) + (typeof message === 'undefined' ? '' : ': ' + matchersUtil.pp(message))
4678
+ printValue:
4679
+ j$.fnNameFor(error) +
4680
+ (typeof message === 'undefined' ? '' : ': ' + matchersUtil.pp(message))
4313
4681
  };
4314
4682
  }
4315
4683
 
4316
4684
  function isErrorConstructor(value) {
4317
- return typeof value === 'function' && (value === Error || j$.isError_(value.prototype));
4685
+ return (
4686
+ typeof value === 'function' &&
4687
+ (value === Error || j$.isError_(value.prototype))
4688
+ );
4318
4689
  }
4319
4690
  };
4320
4691
 
@@ -4330,7 +4701,7 @@ getJasmineRequireObj().toBeResolved = function(j$) {
4330
4701
  * @example
4331
4702
  * return expectAsync(aPromise).toBeResolved();
4332
4703
  */
4333
- return function toBeResolved() {
4704
+ return function toBeResolved(matchersUtil) {
4334
4705
  return {
4335
4706
  compare: function(actual) {
4336
4707
  if (!j$.isPromiseLike(actual)) {
@@ -4338,8 +4709,19 @@ getJasmineRequireObj().toBeResolved = function(j$) {
4338
4709
  }
4339
4710
 
4340
4711
  return actual.then(
4341
- function() { return {pass: true}; },
4342
- function() { return {pass: false}; }
4712
+ function() {
4713
+ return { pass: true };
4714
+ },
4715
+ function(e) {
4716
+ return {
4717
+ pass: false,
4718
+ message:
4719
+ 'Expected a promise to be resolved but it was ' +
4720
+ 'rejected with ' +
4721
+ matchersUtil.pp(e) +
4722
+ '.'
4723
+ };
4724
+ }
4343
4725
  );
4344
4726
  }
4345
4727
  };
@@ -4367,9 +4749,12 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
4367
4749
  }
4368
4750
 
4369
4751
  function prefix(passed) {
4370
- return 'Expected a promise ' +
4752
+ return (
4753
+ 'Expected a promise ' +
4371
4754
  (passed ? 'not ' : '') +
4372
- 'to be resolved to ' + matchersUtil.pp(expectedValue);
4755
+ 'to be resolved to ' +
4756
+ matchersUtil.pp(expectedValue)
4757
+ );
4373
4758
  }
4374
4759
 
4375
4760
  return actualPromise.then(
@@ -4382,14 +4767,22 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
4382
4767
  } else {
4383
4768
  return {
4384
4769
  pass: false,
4385
- message: prefix(false) + ' but it was resolved to ' + matchersUtil.pp(actualValue) + '.'
4770
+ message:
4771
+ prefix(false) +
4772
+ ' but it was resolved to ' +
4773
+ matchersUtil.pp(actualValue) +
4774
+ '.'
4386
4775
  };
4387
4776
  }
4388
4777
  },
4389
- function() {
4778
+ function(e) {
4390
4779
  return {
4391
4780
  pass: false,
4392
- message: prefix(false) + ' but it was rejected.'
4781
+ message:
4782
+ prefix(false) +
4783
+ ' but it was rejected with ' +
4784
+ matchersUtil.pp(e) +
4785
+ '.'
4393
4786
  };
4394
4787
  }
4395
4788
  );
@@ -4398,7 +4791,7 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
4398
4791
  };
4399
4792
  };
4400
4793
 
4401
- getJasmineRequireObj().DiffBuilder = function (j$) {
4794
+ getJasmineRequireObj().DiffBuilder = function(j$) {
4402
4795
  return function DiffBuilder(config) {
4403
4796
  var prettyPrinter = (config || {}).prettyPrinter || j$.makePrettyPrinter(),
4404
4797
  mismatches = new j$.MismatchTree(),
@@ -4407,21 +4800,28 @@ getJasmineRequireObj().DiffBuilder = function (j$) {
4407
4800
  expectedRoot = undefined;
4408
4801
 
4409
4802
  return {
4410
- setRoots: function (actual, expected) {
4803
+ setRoots: function(actual, expected) {
4411
4804
  actualRoot = actual;
4412
4805
  expectedRoot = expected;
4413
4806
  },
4414
4807
 
4415
- recordMismatch: function (formatter) {
4808
+ recordMismatch: function(formatter) {
4416
4809
  mismatches.add(path, formatter);
4417
4810
  },
4418
4811
 
4419
- getMessage: function () {
4812
+ getMessage: function() {
4420
4813
  var messages = [];
4421
4814
 
4422
- mismatches.traverse(function (path, isLeaf, formatter) {
4423
- var actualCustom, expectedCustom, useCustom,
4424
- derefResult = dereferencePath(path, actualRoot, expectedRoot, prettyPrinter),
4815
+ mismatches.traverse(function(path, isLeaf, formatter) {
4816
+ var actualCustom,
4817
+ expectedCustom,
4818
+ useCustom,
4819
+ derefResult = dereferencePath(
4820
+ path,
4821
+ actualRoot,
4822
+ expectedRoot,
4823
+ prettyPrinter
4824
+ ),
4425
4825
  actual = derefResult.actual,
4426
4826
  expected = derefResult.expected;
4427
4827
 
@@ -4432,15 +4832,22 @@ getJasmineRequireObj().DiffBuilder = function (j$) {
4432
4832
 
4433
4833
  actualCustom = prettyPrinter.customFormat_(actual);
4434
4834
  expectedCustom = prettyPrinter.customFormat_(expected);
4435
- useCustom = !(j$.util.isUndefined(actualCustom) && j$.util.isUndefined(expectedCustom));
4835
+ useCustom = !(
4836
+ j$.util.isUndefined(actualCustom) &&
4837
+ j$.util.isUndefined(expectedCustom)
4838
+ );
4436
4839
 
4437
4840
  if (useCustom) {
4438
- messages.push(wrapPrettyPrinted(actualCustom, expectedCustom, path));
4841
+ messages.push(
4842
+ wrapPrettyPrinted(actualCustom, expectedCustom, path)
4843
+ );
4439
4844
  return false; // don't recurse further
4440
4845
  }
4441
4846
 
4442
4847
  if (isLeaf) {
4443
- messages.push(defaultFormatter(actual, expected, path, prettyPrinter));
4848
+ messages.push(
4849
+ defaultFormatter(actual, expected, path, prettyPrinter)
4850
+ );
4444
4851
  }
4445
4852
 
4446
4853
  return true;
@@ -4449,7 +4856,7 @@ getJasmineRequireObj().DiffBuilder = function (j$) {
4449
4856
  return messages.join('\n');
4450
4857
  },
4451
4858
 
4452
- withPath: function (pathComponent, block) {
4859
+ withPath: function(pathComponent, block) {
4453
4860
  var oldPath = path;
4454
4861
  path = path.add(pathComponent);
4455
4862
  block();
@@ -4458,22 +4865,32 @@ getJasmineRequireObj().DiffBuilder = function (j$) {
4458
4865
  };
4459
4866
 
4460
4867
  function defaultFormatter(actual, expected, path, prettyPrinter) {
4461
- return wrapPrettyPrinted(prettyPrinter(actual), prettyPrinter(expected), path);
4868
+ return wrapPrettyPrinted(
4869
+ prettyPrinter(actual),
4870
+ prettyPrinter(expected),
4871
+ path
4872
+ );
4462
4873
  }
4463
4874
 
4464
4875
  function wrapPrettyPrinted(actual, expected, path) {
4465
- return 'Expected ' +
4466
- path + (path.depth() ? ' = ' : '') +
4876
+ return (
4877
+ 'Expected ' +
4878
+ path +
4879
+ (path.depth() ? ' = ' : '') +
4467
4880
  actual +
4468
4881
  ' to equal ' +
4469
4882
  expected +
4470
- '.';
4883
+ '.'
4884
+ );
4471
4885
  }
4472
4886
  };
4473
4887
 
4474
4888
  function dereferencePath(objectPath, actual, expected, pp) {
4475
4889
  function handleAsymmetricExpected() {
4476
- if (j$.isAsymmetricEqualityTester_(expected) && j$.isFunction_(expected.valuesForDiff_)) {
4890
+ if (
4891
+ j$.isAsymmetricEqualityTester_(expected) &&
4892
+ j$.isFunction_(expected.valuesForDiff_)
4893
+ ) {
4477
4894
  var asymmetricResult = expected.valuesForDiff_(actual, pp);
4478
4895
  expected = asymmetricResult.self;
4479
4896
  actual = asymmetricResult.other;
@@ -4489,20 +4906,19 @@ getJasmineRequireObj().DiffBuilder = function (j$) {
4489
4906
  handleAsymmetricExpected();
4490
4907
  }
4491
4908
 
4492
- return {actual: actual, expected: expected};
4909
+ return { actual: actual, expected: expected };
4493
4910
  }
4494
-
4495
4911
  };
4496
4912
 
4497
4913
  getJasmineRequireObj().MatchersUtil = function(j$) {
4498
4914
  // TODO: convert all uses of j$.pp to use the injected pp
4499
4915
 
4500
4916
  /**
4917
+ * @class MatchersUtil
4918
+ * @classdesc Utilities for use in implementing matchers.<br>
4501
4919
  * _Note:_ Do not construct this directly. Jasmine will construct one and
4502
4920
  * pass it to matchers and asymmetric equality testers.
4503
- * @name MatchersUtil
4504
- * @classdesc Utilities for use in implementing matchers
4505
- * @constructor
4921
+ * @hideconstructor
4506
4922
  */
4507
4923
  function MatchersUtil(options) {
4508
4924
  options = options || {};
@@ -4517,7 +4933,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4517
4933
  * @return {string} The pretty-printed value
4518
4934
  */
4519
4935
  this.pp = options.pp || function() {};
4520
- };
4936
+ }
4521
4937
 
4522
4938
  /**
4523
4939
  * Determines whether `haystack` contains `needle`, using the same comparison
@@ -4535,9 +4951,10 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4535
4951
  return haystack.has(needle);
4536
4952
  }
4537
4953
 
4538
- if ((Object.prototype.toString.apply(haystack) === '[object Array]') ||
4539
- (!!haystack && !haystack.indexOf))
4540
- {
4954
+ if (
4955
+ Object.prototype.toString.apply(haystack) === '[object Array]' ||
4956
+ (!!haystack && !haystack.indexOf)
4957
+ ) {
4541
4958
  for (var i = 0; i < haystack.length; i++) {
4542
4959
  if (this.equals(haystack[i], needle, customTesters)) {
4543
4960
  return true;
@@ -4556,9 +4973,12 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4556
4973
  isNot = args[1],
4557
4974
  actual = args[2],
4558
4975
  expected = args.slice(3),
4559
- englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
4976
+ englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) {
4977
+ return ' ' + s.toLowerCase();
4978
+ });
4560
4979
 
4561
- var message = 'Expected ' +
4980
+ var message =
4981
+ 'Expected ' +
4562
4982
  self.pp(actual) +
4563
4983
  (isNot ? ' not ' : ' ') +
4564
4984
  englishyPredicate;
@@ -4575,20 +4995,41 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4575
4995
  return message + '.';
4576
4996
  };
4577
4997
 
4578
- MatchersUtil.prototype.asymmetricDiff_ = function(a, b, aStack, bStack, customTesters, diffBuilder) {
4998
+ MatchersUtil.prototype.asymmetricDiff_ = function(
4999
+ a,
5000
+ b,
5001
+ aStack,
5002
+ bStack,
5003
+ customTesters,
5004
+ diffBuilder
5005
+ ) {
4579
5006
  if (j$.isFunction_(b.valuesForDiff_)) {
4580
5007
  var values = b.valuesForDiff_(a, this.pp);
4581
- this.eq_(values.other, values.self, aStack, bStack, customTesters, diffBuilder);
5008
+ this.eq_(
5009
+ values.other,
5010
+ values.self,
5011
+ aStack,
5012
+ bStack,
5013
+ customTesters,
5014
+ diffBuilder
5015
+ );
4582
5016
  } else {
4583
5017
  diffBuilder.recordMismatch();
4584
5018
  }
4585
5019
  };
4586
5020
 
4587
- MatchersUtil.prototype.asymmetricMatch_ = function(a, b, aStack, bStack, customTesters, diffBuilder) {
5021
+ MatchersUtil.prototype.asymmetricMatch_ = function(
5022
+ a,
5023
+ b,
5024
+ aStack,
5025
+ bStack,
5026
+ customTesters,
5027
+ diffBuilder
5028
+ ) {
4588
5029
  var asymmetricA = j$.isAsymmetricEqualityTester_(a),
4589
- asymmetricB = j$.isAsymmetricEqualityTester_(b),
4590
- shim,
4591
- result;
5030
+ asymmetricB = j$.isAsymmetricEqualityTester_(b),
5031
+ shim,
5032
+ result;
4592
5033
 
4593
5034
  if (asymmetricA === asymmetricB) {
4594
5035
  return undefined;
@@ -4623,7 +5064,12 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4623
5064
  * @param [customTesters] An array of custom equality testers
4624
5065
  * @returns {boolean} True if the values are equal
4625
5066
  */
4626
- MatchersUtil.prototype.equals = function(a, b, customTestersOrDiffBuilder, diffBuilderOrNothing) {
5067
+ MatchersUtil.prototype.equals = function(
5068
+ a,
5069
+ b,
5070
+ customTestersOrDiffBuilder,
5071
+ diffBuilderOrNothing
5072
+ ) {
4627
5073
  var customTesters, diffBuilder;
4628
5074
 
4629
5075
  if (isDiffBuilder(customTestersOrDiffBuilder)) {
@@ -4642,10 +5088,26 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4642
5088
 
4643
5089
  // Equality function lovingly adapted from isEqual in
4644
5090
  // [Underscore](http://underscorejs.org)
4645
- MatchersUtil.prototype.eq_ = function(a, b, aStack, bStack, customTesters, diffBuilder) {
4646
- var result = true, self = this, i;
4647
-
4648
- var asymmetricResult = this.asymmetricMatch_(a, b, aStack, bStack, customTesters, diffBuilder);
5091
+ MatchersUtil.prototype.eq_ = function(
5092
+ a,
5093
+ b,
5094
+ aStack,
5095
+ bStack,
5096
+ customTesters,
5097
+ diffBuilder
5098
+ ) {
5099
+ var result = true,
5100
+ self = this,
5101
+ i;
5102
+
5103
+ var asymmetricResult = this.asymmetricMatch_(
5104
+ a,
5105
+ b,
5106
+ aStack,
5107
+ bStack,
5108
+ customTesters,
5109
+ diffBuilder
5110
+ );
4649
5111
  if (!j$.util.isUndefined(asymmetricResult)) {
4650
5112
  return asymmetricResult;
4651
5113
  }
@@ -4703,7 +5165,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4703
5165
  case '[object Number]':
4704
5166
  // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
4705
5167
  // other numeric values.
4706
- result = a != +a ? b != +b : (a === 0 && b === 0 ? 1 / a == 1 / b : a == +b);
5168
+ result =
5169
+ a != +a ? b != +b : a === 0 && b === 0 ? 1 / a == 1 / b : a == +b;
4707
5170
  if (!result) {
4708
5171
  diffBuilder.recordMismatch();
4709
5172
  }
@@ -4718,12 +5181,25 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4718
5181
  diffBuilder.recordMismatch();
4719
5182
  }
4720
5183
  return result;
5184
+ case '[object ArrayBuffer]':
5185
+ // If we have an instance of ArrayBuffer the Uint8Array ctor
5186
+ // will be defined as well
5187
+ return self.eq_(
5188
+ new Uint8Array(a), // eslint-disable-line compat/compat
5189
+ new Uint8Array(b), // eslint-disable-line compat/compat
5190
+ aStack,
5191
+ bStack,
5192
+ customTesters,
5193
+ diffBuilder
5194
+ );
4721
5195
  // RegExps are compared by their source patterns and flags.
4722
5196
  case '[object RegExp]':
4723
- return a.source == b.source &&
5197
+ return (
5198
+ a.source == b.source &&
4724
5199
  a.global == b.global &&
4725
5200
  a.multiline == b.multiline &&
4726
- a.ignoreCase == b.ignoreCase;
5201
+ a.ignoreCase == b.ignoreCase
5202
+ );
4727
5203
  }
4728
5204
  if (typeof a != 'object' || typeof b != 'object') {
4729
5205
  diffBuilder.recordMismatch();
@@ -4757,7 +5233,9 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4757
5233
  while (length--) {
4758
5234
  // Linear search. Performance is inversely proportional to the number of
4759
5235
  // unique nested structures.
4760
- if (aStack[length] == a) { return bStack[length] == b; }
5236
+ if (aStack[length] == a) {
5237
+ return bStack[length] == b;
5238
+ }
4761
5239
  }
4762
5240
  // Add the first object to the stack of traversed objects.
4763
5241
  aStack.push(a);
@@ -4779,10 +5257,20 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4779
5257
  for (i = 0; i < aLength || i < bLength; i++) {
4780
5258
  diffBuilder.withPath(i, function() {
4781
5259
  if (i >= bLength) {
4782
- diffBuilder.recordMismatch(actualArrayIsLongerFormatter.bind(null, self.pp));
5260
+ diffBuilder.recordMismatch(
5261
+ actualArrayIsLongerFormatter.bind(null, self.pp)
5262
+ );
4783
5263
  result = false;
4784
5264
  } else {
4785
- result = self.eq_(i < aLength ? a[i] : void 0, i < bLength ? b[i] : void 0, aStack, bStack, customTesters, diffBuilder) && result;
5265
+ result =
5266
+ self.eq_(
5267
+ i < aLength ? a[i] : void 0,
5268
+ i < bLength ? b[i] : void 0,
5269
+ aStack,
5270
+ bStack,
5271
+ customTesters,
5272
+ diffBuilder
5273
+ ) && result;
4786
5274
  }
4787
5275
  });
4788
5276
  }
@@ -4797,11 +5285,11 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4797
5285
 
4798
5286
  var keysA = [];
4799
5287
  var keysB = [];
4800
- a.forEach( function( valueA, keyA ) {
4801
- keysA.push( keyA );
5288
+ a.forEach(function(valueA, keyA) {
5289
+ keysA.push(keyA);
4802
5290
  });
4803
- b.forEach( function( valueB, keyB ) {
4804
- keysB.push( keyB );
5291
+ b.forEach(function(valueB, keyB) {
5292
+ keysB.push(keyB);
4805
5293
  });
4806
5294
 
4807
5295
  // For both sets of keys, check they map to equal values in both maps.
@@ -4822,13 +5310,30 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4822
5310
  // Only use the cmpKey when one of the keys is asymmetric and the corresponding key matches,
4823
5311
  // otherwise explicitly look up the mapKey in the other Map since we want keys with unique
4824
5312
  // obj identity (that are otherwise equal) to not match.
4825
- if (j$.isAsymmetricEqualityTester_(mapKey) || j$.isAsymmetricEqualityTester_(cmpKey) &&
4826
- this.eq_(mapKey, cmpKey, aStack, bStack, customTesters, j$.NullDiffBuilder())) {
5313
+ if (
5314
+ j$.isAsymmetricEqualityTester_(mapKey) ||
5315
+ (j$.isAsymmetricEqualityTester_(cmpKey) &&
5316
+ this.eq_(
5317
+ mapKey,
5318
+ cmpKey,
5319
+ aStack,
5320
+ bStack,
5321
+ customTesters,
5322
+ j$.NullDiffBuilder()
5323
+ ))
5324
+ ) {
4827
5325
  mapValueB = b.get(cmpKey);
4828
5326
  } else {
4829
5327
  mapValueB = b.get(mapKey);
4830
5328
  }
4831
- result = this.eq_(mapValueA, mapValueB, aStack, bStack, customTesters, j$.NullDiffBuilder());
5329
+ result = this.eq_(
5330
+ mapValueA,
5331
+ mapValueB,
5332
+ aStack,
5333
+ bStack,
5334
+ customTesters,
5335
+ j$.NullDiffBuilder()
5336
+ );
4832
5337
  }
4833
5338
  }
4834
5339
 
@@ -4843,12 +5348,12 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4843
5348
  }
4844
5349
 
4845
5350
  var valuesA = [];
4846
- a.forEach( function( valueA ) {
4847
- valuesA.push( valueA );
5351
+ a.forEach(function(valueA) {
5352
+ valuesA.push(valueA);
4848
5353
  });
4849
5354
  var valuesB = [];
4850
- b.forEach( function( valueB ) {
4851
- valuesB.push( valueB );
5355
+ b.forEach(function(valueB) {
5356
+ valuesB.push(valueB);
4852
5357
  });
4853
5358
 
4854
5359
  // For both sets, check they are all contained in the other set
@@ -4872,7 +5377,14 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4872
5377
  otherValue = otherValues[l];
4873
5378
  prevStackSize = baseStack.length;
4874
5379
  // compare by value equality
4875
- found = this.eq_(baseValue, otherValue, baseStack, otherStack, customTesters, j$.NullDiffBuilder());
5380
+ found = this.eq_(
5381
+ baseValue,
5382
+ otherValue,
5383
+ baseStack,
5384
+ otherStack,
5385
+ customTesters,
5386
+ j$.NullDiffBuilder()
5387
+ );
4876
5388
  if (!found && prevStackSize !== baseStack.length) {
4877
5389
  baseStack.splice(prevStackSize);
4878
5390
  otherStack.splice(prevStackSize);
@@ -4886,28 +5398,40 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4886
5398
  diffBuilder.recordMismatch();
4887
5399
  return false;
4888
5400
  }
5401
+ } else if (j$.isURL(a) && j$.isURL(b)) {
5402
+ // URLs have no enumrable properties, so the default object comparison
5403
+ // would consider any two URLs to be equal.
5404
+ return a.toString() === b.toString();
4889
5405
  } else {
4890
-
4891
5406
  // Objects with different constructors are not equivalent, but `Object`s
4892
5407
  // or `Array`s from different frames are.
4893
- var aCtor = a.constructor, bCtor = b.constructor;
4894
- if (aCtor !== bCtor &&
4895
- isFunction(aCtor) && isFunction(bCtor) &&
4896
- a instanceof aCtor && b instanceof bCtor &&
4897
- !(aCtor instanceof aCtor && bCtor instanceof bCtor)) {
4898
-
4899
- diffBuilder.recordMismatch(constructorsAreDifferentFormatter.bind(null, this.pp));
5408
+ var aCtor = a.constructor,
5409
+ bCtor = b.constructor;
5410
+ if (
5411
+ aCtor !== bCtor &&
5412
+ isFunction(aCtor) &&
5413
+ isFunction(bCtor) &&
5414
+ a instanceof aCtor &&
5415
+ b instanceof bCtor &&
5416
+ !(aCtor instanceof aCtor && bCtor instanceof bCtor)
5417
+ ) {
5418
+ diffBuilder.recordMismatch(
5419
+ constructorsAreDifferentFormatter.bind(null, this.pp)
5420
+ );
4900
5421
  return false;
4901
5422
  }
4902
5423
  }
4903
5424
 
4904
5425
  // Deep compare objects.
4905
- var aKeys = keys(a, className == '[object Array]'), key;
5426
+ var aKeys = keys(a, className == '[object Array]'),
5427
+ key;
4906
5428
  size = aKeys.length;
4907
5429
 
4908
5430
  // Ensure that both objects contain the same number of properties before comparing deep equality.
4909
5431
  if (keys(b, className == '[object Array]').length !== size) {
4910
- diffBuilder.recordMismatch(objectKeysAreDifferentFormatter.bind(null, this.pp));
5432
+ diffBuilder.recordMismatch(
5433
+ objectKeysAreDifferentFormatter.bind(null, this.pp)
5434
+ );
4911
5435
  return false;
4912
5436
  }
4913
5437
 
@@ -4915,13 +5439,17 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4915
5439
  key = aKeys[i];
4916
5440
  // Deep compare each member
4917
5441
  if (!j$.util.has(b, key)) {
4918
- diffBuilder.recordMismatch(objectKeysAreDifferentFormatter.bind(null, this.pp));
5442
+ diffBuilder.recordMismatch(
5443
+ objectKeysAreDifferentFormatter.bind(null, this.pp)
5444
+ );
4919
5445
  result = false;
4920
5446
  continue;
4921
5447
  }
4922
5448
 
4923
5449
  diffBuilder.withPath(key, function() {
4924
- if(!self.eq_(a[key], b[key], aStack, bStack, customTesters, diffBuilder)) {
5450
+ if (
5451
+ !self.eq_(a[key], b[key], aStack, bStack, customTesters, diffBuilder)
5452
+ ) {
4925
5453
  result = false;
4926
5454
  }
4927
5455
  });
@@ -4939,23 +5467,24 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4939
5467
  };
4940
5468
 
4941
5469
  function keys(obj, isArray) {
4942
- var allKeys = Object.keys ? Object.keys(obj) :
4943
- (function(o) {
5470
+ var allKeys = Object.keys
5471
+ ? Object.keys(obj)
5472
+ : (function(o) {
4944
5473
  var keys = [];
4945
5474
  for (var key in o) {
4946
- if (j$.util.has(o, key)) {
4947
- keys.push(key);
4948
- }
5475
+ if (j$.util.has(o, key)) {
5476
+ keys.push(key);
5477
+ }
4949
5478
  }
4950
5479
  return keys;
4951
- })(obj);
5480
+ })(obj);
4952
5481
 
4953
5482
  if (!isArray) {
4954
5483
  return allKeys;
4955
5484
  }
4956
5485
 
4957
5486
  if (allKeys.length === 0) {
4958
- return allKeys;
5487
+ return allKeys;
4959
5488
  }
4960
5489
 
4961
5490
  var extraKeys = [];
@@ -4974,21 +5503,25 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4974
5503
 
4975
5504
  function objectKeysAreDifferentFormatter(pp, actual, expected, path) {
4976
5505
  var missingProperties = j$.util.objectDifference(expected, actual),
4977
- extraProperties = j$.util.objectDifference(actual, expected),
4978
- missingPropertiesMessage = formatKeyValuePairs(pp, missingProperties),
4979
- extraPropertiesMessage = formatKeyValuePairs(pp, extraProperties),
4980
- messages = [];
5506
+ extraProperties = j$.util.objectDifference(actual, expected),
5507
+ missingPropertiesMessage = formatKeyValuePairs(pp, missingProperties),
5508
+ extraPropertiesMessage = formatKeyValuePairs(pp, extraProperties),
5509
+ messages = [];
4981
5510
 
4982
5511
  if (!path.depth()) {
4983
5512
  path = 'object';
4984
5513
  }
4985
5514
 
4986
5515
  if (missingPropertiesMessage.length) {
4987
- messages.push('Expected ' + path + ' to have properties' + missingPropertiesMessage);
5516
+ messages.push(
5517
+ 'Expected ' + path + ' to have properties' + missingPropertiesMessage
5518
+ );
4988
5519
  }
4989
5520
 
4990
5521
  if (extraPropertiesMessage.length) {
4991
- messages.push('Expected ' + path + ' not to have properties' + extraPropertiesMessage);
5522
+ messages.push(
5523
+ 'Expected ' + path + ' not to have properties' + extraPropertiesMessage
5524
+ );
4992
5525
  }
4993
5526
 
4994
5527
  return messages.join('\n');
@@ -4999,17 +5532,25 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
4999
5532
  path = 'object';
5000
5533
  }
5001
5534
 
5002
- return 'Expected ' +
5003
- path + ' to be a kind of ' +
5535
+ return (
5536
+ 'Expected ' +
5537
+ path +
5538
+ ' to be a kind of ' +
5004
5539
  j$.fnNameFor(expected.constructor) +
5005
- ', but was ' + pp(actual) + '.';
5540
+ ', but was ' +
5541
+ pp(actual) +
5542
+ '.'
5543
+ );
5006
5544
  }
5007
5545
 
5008
5546
  function actualArrayIsLongerFormatter(pp, actual, expected, path) {
5009
- return 'Unexpected ' +
5010
- path + (path.depth() ? ' = ' : '') +
5547
+ return (
5548
+ 'Unexpected ' +
5549
+ path +
5550
+ (path.depth() ? ' = ' : '') +
5011
5551
  pp(actual) +
5012
- ' in array.';
5552
+ ' in array.'
5553
+ );
5013
5554
  }
5014
5555
 
5015
5556
  function formatKeyValuePairs(pp, obj) {
@@ -5027,8 +5568,32 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
5027
5568
  return MatchersUtil;
5028
5569
  };
5029
5570
 
5030
- getJasmineRequireObj().MismatchTree = function (j$) {
5031
-
5571
+ /**
5572
+ * @interface AsymmetricEqualityTester
5573
+ * @classdesc An asymmetric equality tester is an object that can match multiple
5574
+ * objects. Examples include jasmine.any() and jasmine.stringMatching().
5575
+ * User-defined asymmetric equality testers can also be defined and used in
5576
+ * expectations.
5577
+ * @see custom_asymmetric_equality_testers
5578
+ * @since 2.0.0
5579
+ */
5580
+ /**
5581
+ * Determines whether a value matches this tester
5582
+ * @function
5583
+ * @name AsymmetricEqualityTester#asymmetricMatch
5584
+ * @param value {any} The value to test
5585
+ * @param matchersUtil {MatchersUtil} utilities for testing equality, etc
5586
+ * @return {Boolean}
5587
+ */
5588
+ /**
5589
+ * Returns a string representation of this tester to use in matcher failure messages
5590
+ * @function
5591
+ * @name AsymmetricEqualityTester#jasmineToString
5592
+ * @param pp {function} Function that takes a value and returns a pretty-printed representation
5593
+ * @return {String}
5594
+ */
5595
+
5596
+ getJasmineRequireObj().MismatchTree = function(j$) {
5032
5597
  /*
5033
5598
  To be able to apply custom object formatters at all possible levels of an
5034
5599
  object graph, DiffBuilder needs to be able to know not just where the
@@ -5043,7 +5608,7 @@ getJasmineRequireObj().MismatchTree = function (j$) {
5043
5608
  this.isMismatch = false;
5044
5609
  }
5045
5610
 
5046
- MismatchTree.prototype.add = function (path, formatter) {
5611
+ MismatchTree.prototype.add = function(path, formatter) {
5047
5612
  var key, child;
5048
5613
 
5049
5614
  if (path.depth() === 0) {
@@ -5063,8 +5628,9 @@ getJasmineRequireObj().MismatchTree = function (j$) {
5063
5628
  }
5064
5629
  };
5065
5630
 
5066
- MismatchTree.prototype.traverse = function (visit) {
5067
- var i, hasChildren = this.children.length > 0;
5631
+ MismatchTree.prototype.traverse = function(visit) {
5632
+ var i,
5633
+ hasChildren = this.children.length > 0;
5068
5634
 
5069
5635
  if (this.isMismatch || hasChildren) {
5070
5636
  if (visit(this.path, !hasChildren, this.formatter)) {
@@ -5089,7 +5655,6 @@ getJasmineRequireObj().MismatchTree = function (j$) {
5089
5655
  return MismatchTree;
5090
5656
  };
5091
5657
 
5092
-
5093
5658
  getJasmineRequireObj().nothing = function() {
5094
5659
  /**
5095
5660
  * {@link expect} nothing explicitly.
@@ -5158,7 +5723,7 @@ getJasmineRequireObj().ObjectPath = function(j$) {
5158
5723
  return '.' + prop;
5159
5724
  }
5160
5725
 
5161
- return '[\'' + prop + '\']';
5726
+ return "['" + prop + "']";
5162
5727
  }
5163
5728
 
5164
5729
  function map(array, fn) {
@@ -5206,7 +5771,8 @@ getJasmineRequireObj().toBe = function(j$) {
5206
5771
  * expect(thing).toBe(realThing);
5207
5772
  */
5208
5773
  function toBe(matchersUtil) {
5209
- var tip = ' Tip: To check for deep equality, use .toEqual() instead of .toBe().';
5774
+ var tip =
5775
+ ' Tip: To check for deep equality, use .toEqual() instead of .toBe().';
5210
5776
 
5211
5777
  return {
5212
5778
  compare: function(actual, expected) {
@@ -5215,7 +5781,13 @@ getJasmineRequireObj().toBe = function(j$) {
5215
5781
  };
5216
5782
 
5217
5783
  if (typeof expected === 'object') {
5218
- result.message = matchersUtil.buildFailureMessage('toBe', result.pass, actual, expected) + tip;
5784
+ result.message =
5785
+ matchersUtil.buildFailureMessage(
5786
+ 'toBe',
5787
+ result.pass,
5788
+ actual,
5789
+ expected
5790
+ ) + tip;
5219
5791
  }
5220
5792
 
5221
5793
  return result;
@@ -5245,8 +5817,13 @@ getJasmineRequireObj().toBeCloseTo = function() {
5245
5817
  }
5246
5818
 
5247
5819
  if (expected === null || actual === null) {
5248
- throw new Error('Cannot use toBeCloseTo with null. Arguments evaluated to: ' +
5249
- 'expect(' + actual + ').toBeCloseTo(' + expected + ').'
5820
+ throw new Error(
5821
+ 'Cannot use toBeCloseTo with null. Arguments evaluated to: ' +
5822
+ 'expect(' +
5823
+ actual +
5824
+ ').toBeCloseTo(' +
5825
+ expected +
5826
+ ').'
5250
5827
  );
5251
5828
  }
5252
5829
 
@@ -5277,7 +5854,7 @@ getJasmineRequireObj().toBeDefined = function() {
5277
5854
  return {
5278
5855
  compare: function(actual) {
5279
5856
  return {
5280
- pass: (void 0 !== actual)
5857
+ pass: void 0 !== actual
5281
5858
  };
5282
5859
  }
5283
5860
  };
@@ -5353,7 +5930,6 @@ getJasmineRequireObj().toBeGreaterThan = function() {
5353
5930
  return toBeGreaterThan;
5354
5931
  };
5355
5932
 
5356
-
5357
5933
  getJasmineRequireObj().toBeGreaterThanOrEqual = function() {
5358
5934
  /**
5359
5935
  * {@link expect} the actual value to be greater than or equal to the expected value.
@@ -5378,7 +5954,10 @@ getJasmineRequireObj().toBeGreaterThanOrEqual = function() {
5378
5954
  };
5379
5955
 
5380
5956
  getJasmineRequireObj().toBeInstanceOf = function(j$) {
5381
- var usageError = j$.formatErrorMsg('<toBeInstanceOf>', 'expect(value).toBeInstanceOf(<ConstructorFunction>)');
5957
+ var usageError = j$.formatErrorMsg(
5958
+ '<toBeInstanceOf>',
5959
+ 'expect(value).toBeInstanceOf(<ConstructorFunction>)'
5960
+ );
5382
5961
 
5383
5962
  /**
5384
5963
  * {@link expect} the actual to be an instance of the expected class
@@ -5394,27 +5973,42 @@ getJasmineRequireObj().toBeInstanceOf = function(j$) {
5394
5973
  function toBeInstanceOf(matchersUtil) {
5395
5974
  return {
5396
5975
  compare: function(actual, expected) {
5397
- var actualType = actual && actual.constructor ? j$.fnNameFor(actual.constructor) : matchersUtil.pp(actual),
5398
- expectedType = expected ? j$.fnNameFor(expected) : matchersUtil.pp(expected),
5399
- expectedMatcher,
5400
- pass;
5976
+ var actualType =
5977
+ actual && actual.constructor
5978
+ ? j$.fnNameFor(actual.constructor)
5979
+ : matchersUtil.pp(actual),
5980
+ expectedType = expected
5981
+ ? j$.fnNameFor(expected)
5982
+ : matchersUtil.pp(expected),
5983
+ expectedMatcher,
5984
+ pass;
5401
5985
 
5402
5986
  try {
5403
- expectedMatcher = new j$.Any(expected);
5404
- pass = expectedMatcher.asymmetricMatch(actual);
5987
+ expectedMatcher = new j$.Any(expected);
5988
+ pass = expectedMatcher.asymmetricMatch(actual);
5405
5989
  } catch (error) {
5406
- throw new Error(usageError('Expected value is not a constructor function'));
5990
+ throw new Error(
5991
+ usageError('Expected value is not a constructor function')
5992
+ );
5407
5993
  }
5408
5994
 
5409
5995
  if (pass) {
5410
5996
  return {
5411
5997
  pass: true,
5412
- message: 'Expected instance of ' + actualType + ' not to be an instance of ' + expectedType
5998
+ message:
5999
+ 'Expected instance of ' +
6000
+ actualType +
6001
+ ' not to be an instance of ' +
6002
+ expectedType
5413
6003
  };
5414
6004
  } else {
5415
6005
  return {
5416
6006
  pass: false,
5417
- message: 'Expected instance of ' + actualType + ' to be an instance of ' + expectedType
6007
+ message:
6008
+ 'Expected instance of ' +
6009
+ actualType +
6010
+ ' to be an instance of ' +
6011
+ expectedType
5418
6012
  };
5419
6013
  }
5420
6014
  }
@@ -5436,7 +6030,6 @@ getJasmineRequireObj().toBeLessThan = function() {
5436
6030
  */
5437
6031
  function toBeLessThan() {
5438
6032
  return {
5439
-
5440
6033
  compare: function(actual, expected) {
5441
6034
  return {
5442
6035
  pass: actual < expected
@@ -5460,7 +6053,6 @@ getJasmineRequireObj().toBeLessThanOrEqual = function() {
5460
6053
  */
5461
6054
  function toBeLessThanOrEqual() {
5462
6055
  return {
5463
-
5464
6056
  compare: function(actual, expected) {
5465
6057
  return {
5466
6058
  pass: actual <= expected
@@ -5485,13 +6077,15 @@ getJasmineRequireObj().toBeNaN = function(j$) {
5485
6077
  return {
5486
6078
  compare: function(actual) {
5487
6079
  var result = {
5488
- pass: (actual !== actual)
6080
+ pass: actual !== actual
5489
6081
  };
5490
6082
 
5491
6083
  if (result.pass) {
5492
6084
  result.message = 'Expected actual not to be NaN.';
5493
6085
  } else {
5494
- result.message = function() { return 'Expected ' + matchersUtil.pp(actual) + ' to be NaN.'; };
6086
+ result.message = function() {
6087
+ return 'Expected ' + matchersUtil.pp(actual) + ' to be NaN.';
6088
+ };
5495
6089
  }
5496
6090
 
5497
6091
  return result;
@@ -5515,13 +6109,15 @@ getJasmineRequireObj().toBeNegativeInfinity = function(j$) {
5515
6109
  return {
5516
6110
  compare: function(actual) {
5517
6111
  var result = {
5518
- pass: (actual === Number.NEGATIVE_INFINITY)
6112
+ pass: actual === Number.NEGATIVE_INFINITY
5519
6113
  };
5520
6114
 
5521
6115
  if (result.pass) {
5522
6116
  result.message = 'Expected actual not to be -Infinity.';
5523
6117
  } else {
5524
- result.message = function() { return 'Expected ' + matchersUtil.pp(actual) + ' to be -Infinity.'; };
6118
+ result.message = function() {
6119
+ return 'Expected ' + matchersUtil.pp(actual) + ' to be -Infinity.';
6120
+ };
5525
6121
  }
5526
6122
 
5527
6123
  return result;
@@ -5567,13 +6163,15 @@ getJasmineRequireObj().toBePositiveInfinity = function(j$) {
5567
6163
  return {
5568
6164
  compare: function(actual) {
5569
6165
  var result = {
5570
- pass: (actual === Number.POSITIVE_INFINITY)
6166
+ pass: actual === Number.POSITIVE_INFINITY
5571
6167
  };
5572
6168
 
5573
6169
  if (result.pass) {
5574
6170
  result.message = 'Expected actual not to be Infinity.';
5575
6171
  } else {
5576
- result.message = function() { return 'Expected ' + matchersUtil.pp(actual) + ' to be Infinity.'; };
6172
+ result.message = function() {
6173
+ return 'Expected ' + matchersUtil.pp(actual) + ' to be Infinity.';
6174
+ };
5577
6175
  }
5578
6176
 
5579
6177
  return result;
@@ -5664,7 +6262,6 @@ getJasmineRequireObj().toContain = function() {
5664
6262
  function toContain(matchersUtil) {
5665
6263
  return {
5666
6264
  compare: function(actual, expected) {
5667
-
5668
6265
  return {
5669
6266
  pass: matchersUtil.contains(actual, expected)
5670
6267
  };
@@ -5691,7 +6288,7 @@ getJasmineRequireObj().toEqual = function(j$) {
5691
6288
  var result = {
5692
6289
  pass: false
5693
6290
  },
5694
- diffBuilder = j$.DiffBuilder({prettyPrinter: matchersUtil.pp});
6291
+ diffBuilder = j$.DiffBuilder({ prettyPrinter: matchersUtil.pp });
5695
6292
 
5696
6293
  result.pass = matchersUtil.equals(actual, expected, diffBuilder);
5697
6294
 
@@ -5707,8 +6304,10 @@ getJasmineRequireObj().toEqual = function(j$) {
5707
6304
  };
5708
6305
 
5709
6306
  getJasmineRequireObj().toHaveBeenCalled = function(j$) {
5710
-
5711
- var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalled>', 'expect(<spyObj>).toHaveBeenCalled()');
6307
+ var getErrorMsg = j$.formatErrorMsg(
6308
+ '<toHaveBeenCalled>',
6309
+ 'expect(<spyObj>).toHaveBeenCalled()'
6310
+ );
5712
6311
 
5713
6312
  /**
5714
6313
  * {@link expect} the actual (a {@link Spy}) to have been called.
@@ -5725,18 +6324,24 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) {
5725
6324
  var result = {};
5726
6325
 
5727
6326
  if (!j$.isSpy(actual)) {
5728
- throw new Error(getErrorMsg('Expected a spy, but got ' + matchersUtil.pp(actual) + '.'));
6327
+ throw new Error(
6328
+ getErrorMsg(
6329
+ 'Expected a spy, but got ' + matchersUtil.pp(actual) + '.'
6330
+ )
6331
+ );
5729
6332
  }
5730
6333
 
5731
6334
  if (arguments.length > 1) {
5732
- throw new Error(getErrorMsg('Does not take arguments, use toHaveBeenCalledWith'));
6335
+ throw new Error(
6336
+ getErrorMsg('Does not take arguments, use toHaveBeenCalledWith')
6337
+ );
5733
6338
  }
5734
6339
 
5735
6340
  result.pass = actual.calls.any();
5736
6341
 
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.';
6342
+ result.message = result.pass
6343
+ ? 'Expected spy ' + actual.and.identity + ' not to have been called.'
6344
+ : 'Expected spy ' + actual.and.identity + ' to have been called.';
5740
6345
 
5741
6346
  return result;
5742
6347
  }
@@ -5747,8 +6352,10 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) {
5747
6352
  };
5748
6353
 
5749
6354
  getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
5750
-
5751
- var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalledBefore>', 'expect(<spyObj>).toHaveBeenCalledBefore(<spyObj>)');
6355
+ var getErrorMsg = j$.formatErrorMsg(
6356
+ '<toHaveBeenCalledBefore>',
6357
+ 'expect(<spyObj>).toHaveBeenCalledBefore(<spyObj>)'
6358
+ );
5752
6359
 
5753
6360
  /**
5754
6361
  * {@link expect} the actual value (a {@link Spy}) to have been called before another {@link Spy}.
@@ -5763,20 +6370,30 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
5763
6370
  return {
5764
6371
  compare: function(firstSpy, latterSpy) {
5765
6372
  if (!j$.isSpy(firstSpy)) {
5766
- throw new Error(getErrorMsg('Expected a spy, but got ' + matchersUtil.pp(firstSpy) + '.'));
6373
+ throw new Error(
6374
+ getErrorMsg(
6375
+ 'Expected a spy, but got ' + matchersUtil.pp(firstSpy) + '.'
6376
+ )
6377
+ );
5767
6378
  }
5768
6379
  if (!j$.isSpy(latterSpy)) {
5769
- throw new Error(getErrorMsg('Expected a spy, but got ' + matchersUtil.pp(latterSpy) + '.'));
6380
+ throw new Error(
6381
+ getErrorMsg(
6382
+ 'Expected a spy, but got ' + matchersUtil.pp(latterSpy) + '.'
6383
+ )
6384
+ );
5770
6385
  }
5771
6386
 
5772
6387
  var result = { pass: false };
5773
6388
 
5774
6389
  if (!firstSpy.calls.count()) {
5775
- result.message = 'Expected spy ' + firstSpy.and.identity + ' to have been called.';
6390
+ result.message =
6391
+ 'Expected spy ' + firstSpy.and.identity + ' to have been called.';
5776
6392
  return result;
5777
6393
  }
5778
6394
  if (!latterSpy.calls.count()) {
5779
- result.message = 'Expected spy ' + latterSpy.and.identity + ' to have been called.';
6395
+ result.message =
6396
+ 'Expected spy ' + latterSpy.and.identity + ' to have been called.';
5780
6397
  return result;
5781
6398
  }
5782
6399
 
@@ -5786,17 +6403,36 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
5786
6403
  result.pass = latest1stSpyCall < first2ndSpyCall;
5787
6404
 
5788
6405
  if (result.pass) {
5789
- result.message = 'Expected spy ' + firstSpy.and.identity + ' to not have been called before spy ' + latterSpy.and.identity + ', but it was';
6406
+ result.message =
6407
+ 'Expected spy ' +
6408
+ firstSpy.and.identity +
6409
+ ' to not have been called before spy ' +
6410
+ latterSpy.and.identity +
6411
+ ', but it was';
5790
6412
  } else {
5791
6413
  var first1stSpyCall = firstSpy.calls.first().invocationOrder;
5792
6414
  var latest2ndSpyCall = latterSpy.calls.mostRecent().invocationOrder;
5793
6415
 
5794
- if(first1stSpyCall < first2ndSpyCall) {
5795
- result.message = 'Expected latest call to spy ' + firstSpy.and.identity + ' to have been called before first call to spy ' + latterSpy.and.identity + ' (no interleaved calls)';
6416
+ if (first1stSpyCall < first2ndSpyCall) {
6417
+ result.message =
6418
+ 'Expected latest call to spy ' +
6419
+ firstSpy.and.identity +
6420
+ ' to have been called before first call to spy ' +
6421
+ latterSpy.and.identity +
6422
+ ' (no interleaved calls)';
5796
6423
  } else if (latest2ndSpyCall > latest1stSpyCall) {
5797
- result.message = 'Expected first call to spy ' + latterSpy.and.identity + ' to have been called after latest call to spy ' + firstSpy.and.identity + ' (no interleaved calls)';
6424
+ result.message =
6425
+ 'Expected first call to spy ' +
6426
+ latterSpy.and.identity +
6427
+ ' to have been called after latest call to spy ' +
6428
+ firstSpy.and.identity +
6429
+ ' (no interleaved calls)';
5798
6430
  } else {
5799
- result.message = 'Expected spy ' + firstSpy.and.identity + ' to have been called before spy ' + latterSpy.and.identity;
6431
+ result.message =
6432
+ 'Expected spy ' +
6433
+ firstSpy.and.identity +
6434
+ ' to have been called before spy ' +
6435
+ latterSpy.and.identity;
5800
6436
  }
5801
6437
  }
5802
6438
 
@@ -5808,9 +6444,11 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
5808
6444
  return toHaveBeenCalledBefore;
5809
6445
  };
5810
6446
 
5811
- getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) {
5812
-
5813
- var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalledOnceWith>', 'expect(<spyObj>).toHaveBeenCalledOnceWith(...arguments)');
6447
+ getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) {
6448
+ var getErrorMsg = j$.formatErrorMsg(
6449
+ '<toHaveBeenCalledOnceWith>',
6450
+ 'expect(<spyObj>).toHaveBeenCalledOnceWith(...arguments)'
6451
+ );
5814
6452
 
5815
6453
  /**
5816
6454
  * {@link expect} the actual (a {@link Spy}) to have been called exactly once, and exactly with the particular arguments.
@@ -5823,31 +6461,44 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) {
5823
6461
  */
5824
6462
  function toHaveBeenCalledOnceWith(util) {
5825
6463
  return {
5826
- compare: function () {
6464
+ compare: function() {
5827
6465
  var args = Array.prototype.slice.call(arguments, 0),
5828
6466
  actual = args[0],
5829
6467
  expectedArgs = args.slice(1);
5830
6468
 
5831
6469
  if (!j$.isSpy(actual)) {
5832
- throw new Error(getErrorMsg('Expected a spy, but got ' + j$.pp(actual) + '.'));
6470
+ throw new Error(
6471
+ getErrorMsg('Expected a spy, but got ' + util.pp(actual) + '.')
6472
+ );
5833
6473
  }
5834
6474
 
5835
- var prettyPrintedCalls = actual.calls.allArgs().map(function (argsForCall) {
5836
- return ' ' + j$.pp(argsForCall);
5837
- });
6475
+ var prettyPrintedCalls = actual.calls
6476
+ .allArgs()
6477
+ .map(function(argsForCall) {
6478
+ return ' ' + util.pp(argsForCall);
6479
+ });
5838
6480
 
5839
- if (actual.calls.count() === 1 && util.contains(actual.calls.allArgs(), expectedArgs)) {
6481
+ if (
6482
+ actual.calls.count() === 1 &&
6483
+ util.contains(actual.calls.allArgs(), expectedArgs)
6484
+ ) {
5840
6485
  return {
5841
6486
  pass: true,
5842
- message: 'Expected spy ' + actual.and.identity + ' to have been called 0 times, multiple times, or once, but with arguments different from:\n'
5843
- + ' ' + j$.pp(expectedArgs) + '\n'
5844
- + 'But the actual call was:\n'
5845
- + prettyPrintedCalls.join(',\n') + '.\n\n'
6487
+ message:
6488
+ 'Expected spy ' +
6489
+ actual.and.identity +
6490
+ ' to have been called 0 times, multiple times, or once, but with arguments different from:\n' +
6491
+ ' ' +
6492
+ util.pp(expectedArgs) +
6493
+ '\n' +
6494
+ 'But the actual call was:\n' +
6495
+ prettyPrintedCalls.join(',\n') +
6496
+ '.\n\n'
5846
6497
  };
5847
6498
  }
5848
6499
 
5849
6500
  function getDiffs() {
5850
- return actual.calls.allArgs().map(function (argsForCall, callIx) {
6501
+ return actual.calls.allArgs().map(function(argsForCall, callIx) {
5851
6502
  var diffBuilder = new j$.DiffBuilder();
5852
6503
  util.equals(argsForCall, expectedArgs, diffBuilder);
5853
6504
  return diffBuilder.getMessage();
@@ -5859,17 +6510,32 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) {
5859
6510
  case 0:
5860
6511
  return 'But it was never called.\n\n';
5861
6512
  case 1:
5862
- return 'But the actual call was:\n' + prettyPrintedCalls.join(',\n') + '.\n' + getDiffs().join('\n') + '\n\n';
6513
+ return (
6514
+ 'But the actual call was:\n' +
6515
+ prettyPrintedCalls.join(',\n') +
6516
+ '.\n' +
6517
+ getDiffs().join('\n') +
6518
+ '\n\n'
6519
+ );
5863
6520
  default:
5864
- return 'But the actual calls were:\n' + prettyPrintedCalls.join(',\n') + '.\n\n';
6521
+ return (
6522
+ 'But the actual calls were:\n' +
6523
+ prettyPrintedCalls.join(',\n') +
6524
+ '.\n\n'
6525
+ );
5865
6526
  }
5866
6527
  }
5867
6528
 
5868
6529
  return {
5869
6530
  pass: false,
5870
- message: 'Expected spy ' + actual.and.identity + ' to have been called only once, and with given args:\n'
5871
- + ' ' + j$.pp(expectedArgs) + '\n'
5872
- + butString()
6531
+ message:
6532
+ 'Expected spy ' +
6533
+ actual.and.identity +
6534
+ ' to have been called only once, and with given args:\n' +
6535
+ ' ' +
6536
+ util.pp(expectedArgs) +
6537
+ '\n' +
6538
+ butString()
5873
6539
  };
5874
6540
  }
5875
6541
  };
@@ -5879,8 +6545,10 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) {
5879
6545
  };
5880
6546
 
5881
6547
  getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
5882
-
5883
- var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalledTimes>', 'expect(<spyObj>).toHaveBeenCalledTimes(<Number>)');
6548
+ var getErrorMsg = j$.formatErrorMsg(
6549
+ '<toHaveBeenCalledTimes>',
6550
+ 'expect(<spyObj>).toHaveBeenCalledTimes(<Number>)'
6551
+ );
5884
6552
 
5885
6553
  /**
5886
6554
  * {@link expect} the actual (a {@link Spy}) to have been called the specified number of times.
@@ -5895,23 +6563,43 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
5895
6563
  return {
5896
6564
  compare: function(actual, expected) {
5897
6565
  if (!j$.isSpy(actual)) {
5898
- throw new Error(getErrorMsg('Expected a spy, but got ' + matchersUtil.pp(actual) + '.'));
6566
+ throw new Error(
6567
+ getErrorMsg(
6568
+ 'Expected a spy, but got ' + matchersUtil.pp(actual) + '.'
6569
+ )
6570
+ );
5899
6571
  }
5900
6572
 
5901
6573
  var args = Array.prototype.slice.call(arguments, 0),
5902
6574
  result = { pass: false };
5903
6575
 
5904
6576
  if (!j$.isNumber_(expected)) {
5905
- throw new Error(getErrorMsg('The expected times failed is a required argument and must be a number.'));
6577
+ throw new Error(
6578
+ getErrorMsg(
6579
+ 'The expected times failed is a required argument and must be a number.'
6580
+ )
6581
+ );
5906
6582
  }
5907
6583
 
5908
6584
  actual = args[0];
5909
6585
  var calls = actual.calls.count();
5910
6586
  var timesMessage = expected === 1 ? 'once' : expected + ' times';
5911
6587
  result.pass = calls === expected;
5912
- result.message = result.pass ?
5913
- 'Expected spy ' + actual.and.identity + ' not to have been called ' + timesMessage + '. It was called ' + calls + ' times.' :
5914
- 'Expected spy ' + actual.and.identity + ' to have been called ' + timesMessage + '. It was called ' + calls + ' times.';
6588
+ result.message = result.pass
6589
+ ? 'Expected spy ' +
6590
+ actual.and.identity +
6591
+ ' not to have been called ' +
6592
+ timesMessage +
6593
+ '. It was called ' +
6594
+ calls +
6595
+ ' times.'
6596
+ : 'Expected spy ' +
6597
+ actual.and.identity +
6598
+ ' to have been called ' +
6599
+ timesMessage +
6600
+ '. It was called ' +
6601
+ calls +
6602
+ ' times.';
5915
6603
  return result;
5916
6604
  }
5917
6605
  };
@@ -5921,8 +6609,10 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
5921
6609
  };
5922
6610
 
5923
6611
  getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
5924
-
5925
- var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalledWith>', 'expect(<spyObj>).toHaveBeenCalledWith(...arguments)');
6612
+ var getErrorMsg = j$.formatErrorMsg(
6613
+ '<toHaveBeenCalledWith>',
6614
+ 'expect(<spyObj>).toHaveBeenCalledWith(...arguments)'
6615
+ );
5926
6616
 
5927
6617
  /**
5928
6618
  * {@link expect} the actual (a {@link Spy}) to have been called with particular arguments at least once.
@@ -5942,14 +6632,23 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
5942
6632
  result = { pass: false };
5943
6633
 
5944
6634
  if (!j$.isSpy(actual)) {
5945
- throw new Error(getErrorMsg('Expected a spy, but got ' + matchersUtil.pp(actual) + '.'));
6635
+ throw new Error(
6636
+ getErrorMsg(
6637
+ 'Expected a spy, but got ' + matchersUtil.pp(actual) + '.'
6638
+ )
6639
+ );
5946
6640
  }
5947
6641
 
5948
6642
  if (!actual.calls.any()) {
5949
6643
  result.message = function() {
5950
- return 'Expected spy ' + actual.and.identity + ' to have been called with:\n' +
5951
- ' ' + matchersUtil.pp(expectedArgs) +
5952
- '\nbut it was never called.';
6644
+ return (
6645
+ 'Expected spy ' +
6646
+ actual.and.identity +
6647
+ ' to have been called with:\n' +
6648
+ ' ' +
6649
+ matchersUtil.pp(expectedArgs) +
6650
+ '\nbut it was never called.'
6651
+ );
5953
6652
  };
5954
6653
  return result;
5955
6654
  }
@@ -5957,28 +6656,49 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
5957
6656
  if (matchersUtil.contains(actual.calls.allArgs(), expectedArgs)) {
5958
6657
  result.pass = true;
5959
6658
  result.message = function() {
5960
- return 'Expected spy ' + actual.and.identity + ' not to have been called with:\n' +
5961
- ' ' + matchersUtil.pp(expectedArgs) +
5962
- '\nbut it was.';
6659
+ return (
6660
+ 'Expected spy ' +
6661
+ actual.and.identity +
6662
+ ' not to have been called with:\n' +
6663
+ ' ' +
6664
+ matchersUtil.pp(expectedArgs) +
6665
+ '\nbut it was.'
6666
+ );
5963
6667
  };
5964
6668
  } else {
5965
6669
  result.message = function() {
5966
- var prettyPrintedCalls = actual.calls.allArgs().map(function(argsForCall) {
5967
- return ' ' + matchersUtil.pp(argsForCall);
5968
- });
5969
-
5970
- var diffs = actual.calls.allArgs().map(function(argsForCall, callIx) {
5971
- var diffBuilder = new j$.DiffBuilder();
5972
- matchersUtil.equals(argsForCall, expectedArgs, diffBuilder);
5973
- return 'Call ' + callIx + ':\n' +
5974
- diffBuilder.getMessage().replace(/^/mg, ' ');
5975
- });
5976
-
5977
- return 'Expected spy ' + actual.and.identity + ' to have been called with:\n' +
5978
- ' ' + matchersUtil.pp(expectedArgs) + '\n' + '' +
6670
+ var prettyPrintedCalls = actual.calls
6671
+ .allArgs()
6672
+ .map(function(argsForCall) {
6673
+ return ' ' + matchersUtil.pp(argsForCall);
6674
+ });
6675
+
6676
+ var diffs = actual.calls
6677
+ .allArgs()
6678
+ .map(function(argsForCall, callIx) {
6679
+ var diffBuilder = new j$.DiffBuilder();
6680
+ matchersUtil.equals(argsForCall, expectedArgs, diffBuilder);
6681
+ return (
6682
+ 'Call ' +
6683
+ callIx +
6684
+ ':\n' +
6685
+ diffBuilder.getMessage().replace(/^/gm, ' ')
6686
+ );
6687
+ });
6688
+
6689
+ return (
6690
+ 'Expected spy ' +
6691
+ actual.and.identity +
6692
+ ' to have been called with:\n' +
6693
+ ' ' +
6694
+ matchersUtil.pp(expectedArgs) +
6695
+ '\n' +
6696
+ '' +
5979
6697
  'but actual calls were:\n' +
5980
- prettyPrintedCalls.join(',\n') + '.\n\n' +
5981
- diffs.join('\n');
6698
+ prettyPrintedCalls.join(',\n') +
6699
+ '.\n\n' +
6700
+ diffs.join('\n')
6701
+ );
5982
6702
  };
5983
6703
  }
5984
6704
 
@@ -6017,9 +6737,9 @@ getJasmineRequireObj().toHaveClass = function(j$) {
6017
6737
  }
6018
6738
 
6019
6739
  function isElement(maybeEl) {
6020
- return maybeEl &&
6021
- maybeEl.classList &&
6022
- j$.isFunction_(maybeEl.classList.contains);
6740
+ return (
6741
+ maybeEl && maybeEl.classList && j$.isFunction_(maybeEl.classList.contains)
6742
+ );
6023
6743
  }
6024
6744
 
6025
6745
  return toHaveClass;
@@ -6040,10 +6760,14 @@ getJasmineRequireObj().toHaveSize = function(j$) {
6040
6760
  return {
6041
6761
  compare: function(actual, expected) {
6042
6762
  var result = {
6043
- pass: false
6044
- };
6763
+ pass: false
6764
+ };
6045
6765
 
6046
- if (j$.isA_('WeakSet', actual) || j$.isWeakMap(actual) || j$.isDataView(actual)) {
6766
+ if (
6767
+ j$.isA_('WeakSet', actual) ||
6768
+ j$.isWeakMap(actual) ||
6769
+ j$.isDataView(actual)
6770
+ ) {
6047
6771
  throw new Error('Cannot get size of ' + actual + '.');
6048
6772
  }
6049
6773
 
@@ -6060,17 +6784,24 @@ getJasmineRequireObj().toHaveSize = function(j$) {
6060
6784
  };
6061
6785
  }
6062
6786
 
6063
- var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // eslint-disable-line compat/compat
6787
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // eslint-disable-line compat/compat
6064
6788
  function isLength(value) {
6065
- return (typeof value == 'number') && value > -1 && value % 1 === 0 && value <= MAX_SAFE_INTEGER;
6789
+ return (
6790
+ typeof value == 'number' &&
6791
+ value > -1 &&
6792
+ value % 1 === 0 &&
6793
+ value <= MAX_SAFE_INTEGER
6794
+ );
6066
6795
  }
6067
6796
 
6068
6797
  return toHaveSize;
6069
6798
  };
6070
6799
 
6071
6800
  getJasmineRequireObj().toMatch = function(j$) {
6072
-
6073
- var getErrorMsg = j$.formatErrorMsg('<toMatch>', 'expect(<expectation>).toMatch(<string> || <regexp>)');
6801
+ var getErrorMsg = j$.formatErrorMsg(
6802
+ '<toMatch>',
6803
+ 'expect(<expectation>).toMatch(<string> || <regexp>)'
6804
+ );
6074
6805
 
6075
6806
  /**
6076
6807
  * {@link expect} the actual value to match a regular expression
@@ -6102,8 +6833,10 @@ getJasmineRequireObj().toMatch = function(j$) {
6102
6833
  };
6103
6834
 
6104
6835
  getJasmineRequireObj().toThrow = function(j$) {
6105
-
6106
- var getErrorMsg = j$.formatErrorMsg('<toThrow>', 'expect(function() {<expectation>}).toThrow()');
6836
+ var getErrorMsg = j$.formatErrorMsg(
6837
+ '<toThrow>',
6838
+ 'expect(function() {<expectation>}).toThrow()'
6839
+ );
6107
6840
 
6108
6841
  /**
6109
6842
  * {@link expect} a function to `throw` something.
@@ -6140,16 +6873,36 @@ getJasmineRequireObj().toThrow = function(j$) {
6140
6873
 
6141
6874
  if (arguments.length == 1) {
6142
6875
  result.pass = true;
6143
- result.message = function() { return 'Expected function not to throw, but it threw ' + matchersUtil.pp(thrown) + '.'; };
6876
+ result.message = function() {
6877
+ return (
6878
+ 'Expected function not to throw, but it threw ' +
6879
+ matchersUtil.pp(thrown) +
6880
+ '.'
6881
+ );
6882
+ };
6144
6883
 
6145
6884
  return result;
6146
6885
  }
6147
6886
 
6148
6887
  if (matchersUtil.equals(thrown, expected)) {
6149
6888
  result.pass = true;
6150
- result.message = function() { return 'Expected function not to throw ' + matchersUtil.pp(expected) + '.'; };
6889
+ result.message = function() {
6890
+ return (
6891
+ 'Expected function not to throw ' +
6892
+ matchersUtil.pp(expected) +
6893
+ '.'
6894
+ );
6895
+ };
6151
6896
  } else {
6152
- result.message = function() { return 'Expected function to throw ' + matchersUtil.pp(expected) + ', but it threw ' + matchersUtil.pp(thrown) + '.'; };
6897
+ result.message = function() {
6898
+ return (
6899
+ 'Expected function to throw ' +
6900
+ matchersUtil.pp(expected) +
6901
+ ', but it threw ' +
6902
+ matchersUtil.pp(thrown) +
6903
+ '.'
6904
+ );
6905
+ };
6153
6906
  }
6154
6907
 
6155
6908
  return result;
@@ -6161,8 +6914,10 @@ getJasmineRequireObj().toThrow = function(j$) {
6161
6914
  };
6162
6915
 
6163
6916
  getJasmineRequireObj().toThrowError = function(j$) {
6164
-
6165
- var getErrorMsg = j$.formatErrorMsg('<toThrowError>', 'expect(function() {<expectation>}).toThrowError(<ErrorConstructor>, <message>)');
6917
+ var getErrorMsg = j$.formatErrorMsg(
6918
+ '<toThrowError>',
6919
+ 'expect(function() {<expectation>}).toThrowError(<ErrorConstructor>, <message>)'
6920
+ );
6166
6921
 
6167
6922
  /**
6168
6923
  * {@link expect} a function to `throw` an `Error`.
@@ -6196,7 +6951,13 @@ getJasmineRequireObj().toThrowError = function(j$) {
6196
6951
  }
6197
6952
 
6198
6953
  if (!j$.isError_(thrown)) {
6199
- return fail(function() { return 'Expected function to throw an Error, but it threw ' + matchersUtil.pp(thrown) + '.'; });
6954
+ return fail(function() {
6955
+ return (
6956
+ 'Expected function to throw an Error, but it threw ' +
6957
+ matchersUtil.pp(thrown) +
6958
+ '.'
6959
+ );
6960
+ });
6200
6961
  }
6201
6962
 
6202
6963
  return errorMatcher.match(thrown);
@@ -6230,7 +6991,11 @@ getJasmineRequireObj().toThrowError = function(j$) {
6230
6991
  function anyMatcher() {
6231
6992
  return {
6232
6993
  match: function(error) {
6233
- return pass('Expected function not to throw an Error, but it threw ' + j$.fnNameFor(error) + '.');
6994
+ return pass(
6995
+ 'Expected function not to throw an Error, but it threw ' +
6996
+ j$.fnNameFor(error) +
6997
+ '.'
6998
+ );
6234
6999
  }
6235
7000
  };
6236
7001
  }
@@ -6238,9 +7003,13 @@ getJasmineRequireObj().toThrowError = function(j$) {
6238
7003
  function exactMatcher(expected, errorType) {
6239
7004
  if (expected && !isStringOrRegExp(expected)) {
6240
7005
  if (errorType) {
6241
- throw new Error(getErrorMsg('Expected error message is not a string or RegExp.'));
7006
+ throw new Error(
7007
+ getErrorMsg('Expected error message is not a string or RegExp.')
7008
+ );
6242
7009
  } else {
6243
- throw new Error(getErrorMsg('Expected is not an Error, string, or RegExp.'));
7010
+ throw new Error(
7011
+ getErrorMsg('Expected is not an Error, string, or RegExp.')
7012
+ );
6244
7013
  }
6245
7014
  }
6246
7015
 
@@ -6252,11 +7021,15 @@ getJasmineRequireObj().toThrowError = function(j$) {
6252
7021
  }
6253
7022
  }
6254
7023
 
6255
- var errorTypeDescription = errorType ? j$.fnNameFor(errorType) : 'an exception';
7024
+ var errorTypeDescription = errorType
7025
+ ? j$.fnNameFor(errorType)
7026
+ : 'an exception';
6256
7027
 
6257
7028
  function thrownDescription(thrown) {
6258
- var thrownName = errorType ? j$.fnNameFor(thrown.constructor) : 'an exception',
6259
- thrownMessage = '';
7029
+ var thrownName = errorType
7030
+ ? j$.fnNameFor(thrown.constructor)
7031
+ : 'an exception',
7032
+ thrownMessage = '';
6260
7033
 
6261
7034
  if (expected) {
6262
7035
  thrownMessage = ' with message ' + matchersUtil.pp(thrown.message);
@@ -6276,20 +7049,33 @@ getJasmineRequireObj().toThrowError = function(j$) {
6276
7049
  }
6277
7050
 
6278
7051
  function matches(error) {
6279
- return (errorType === null || error instanceof errorType) &&
6280
- (expected === null || messageMatch(error.message));
7052
+ return (
7053
+ (errorType === null || error instanceof errorType) &&
7054
+ (expected === null || messageMatch(error.message))
7055
+ );
6281
7056
  }
6282
7057
 
6283
7058
  return {
6284
7059
  match: function(thrown) {
6285
7060
  if (matches(thrown)) {
6286
7061
  return pass(function() {
6287
- return 'Expected function not to throw ' + errorTypeDescription + messageDescription() + '.';
7062
+ return (
7063
+ 'Expected function not to throw ' +
7064
+ errorTypeDescription +
7065
+ messageDescription() +
7066
+ '.'
7067
+ );
6288
7068
  });
6289
7069
  } else {
6290
7070
  return fail(function() {
6291
- return 'Expected function to throw ' + errorTypeDescription + messageDescription() +
6292
- ', but it threw ' + thrownDescription(thrown) + '.';
7071
+ return (
7072
+ 'Expected function to throw ' +
7073
+ errorTypeDescription +
7074
+ messageDescription() +
7075
+ ', but it threw ' +
7076
+ thrownDescription(thrown) +
7077
+ '.'
7078
+ );
6293
7079
  });
6294
7080
  }
6295
7081
  }
@@ -6297,7 +7083,7 @@ getJasmineRequireObj().toThrowError = function(j$) {
6297
7083
  }
6298
7084
 
6299
7085
  function isStringOrRegExp(potential) {
6300
- return potential instanceof RegExp || (typeof potential == 'string');
7086
+ return potential instanceof RegExp || typeof potential == 'string';
6301
7087
  }
6302
7088
 
6303
7089
  function isAnErrorType(type) {
@@ -6329,7 +7115,10 @@ getJasmineRequireObj().toThrowError = function(j$) {
6329
7115
  };
6330
7116
 
6331
7117
  getJasmineRequireObj().toThrowMatching = function(j$) {
6332
- var usageError = j$.formatErrorMsg('<toThrowMatching>', 'expect(function() {<expectation>}).toThrowMatching(<Predicate>)');
7118
+ var usageError = j$.formatErrorMsg(
7119
+ '<toThrowMatching>',
7120
+ 'expect(function() {<expectation>}).toThrowMatching(<Predicate>)'
7121
+ );
6333
7122
 
6334
7123
  /**
6335
7124
  * {@link expect} a function to `throw` something matching a predicate.
@@ -6361,20 +7150,29 @@ getJasmineRequireObj().toThrowMatching = function(j$) {
6361
7150
  }
6362
7151
 
6363
7152
  if (predicate(thrown)) {
6364
- return pass('Expected function not to throw an exception matching a predicate.');
7153
+ return pass(
7154
+ 'Expected function not to throw an exception matching a predicate.'
7155
+ );
6365
7156
  } else {
6366
- return fail(function() {
6367
- return 'Expected function to throw an exception matching a predicate, ' +
6368
- 'but it threw ' + thrownDescription(thrown) + '.';
6369
- });
7157
+ return fail(function() {
7158
+ return (
7159
+ 'Expected function to throw an exception matching a predicate, ' +
7160
+ 'but it threw ' +
7161
+ thrownDescription(thrown) +
7162
+ '.'
7163
+ );
7164
+ });
6370
7165
  }
6371
7166
  }
6372
7167
  };
6373
7168
 
6374
7169
  function thrownDescription(thrown) {
6375
7170
  if (thrown && thrown.constructor) {
6376
- return j$.fnNameFor(thrown.constructor) + ' with message ' +
6377
- matchersUtil.pp(thrown.message);
7171
+ return (
7172
+ j$.fnNameFor(thrown.constructor) +
7173
+ ' with message ' +
7174
+ matchersUtil.pp(thrown.message)
7175
+ );
6378
7176
  } else {
6379
7177
  return matchersUtil.pp(thrown);
6380
7178
  }
@@ -6911,6 +7709,8 @@ getJasmineRequireObj().makePrettyPrinter = function(j$) {
6911
7709
  };
6912
7710
 
6913
7711
  getJasmineRequireObj().QueueRunner = function(j$) {
7712
+ var nextid = 1;
7713
+
6914
7714
  function StopExecutionError() {}
6915
7715
  StopExecutionError.prototype = new Error();
6916
7716
  j$.StopExecutionError = StopExecutionError;
@@ -6930,6 +7730,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
6930
7730
  function emptyFn() {}
6931
7731
 
6932
7732
  function QueueRunner(attrs) {
7733
+ this.id_ = nextid++;
6933
7734
  var queueableFns = attrs.queueableFns || [];
6934
7735
  this.queueableFns = queueableFns.concat(attrs.cleanupFns || []);
6935
7736
  this.firstCleanupIx = queueableFns.length;
@@ -7032,7 +7833,8 @@ getJasmineRequireObj().QueueRunner = function(j$) {
7032
7833
  }),
7033
7834
  errored = false,
7034
7835
  queueableFn = self.queueableFns[iterativeIndex],
7035
- timeoutId;
7836
+ timeoutId,
7837
+ maybeThenable;
7036
7838
 
7037
7839
  next.fail = function nextFail() {
7038
7840
  self.fail.apply(null, arguments);
@@ -7060,7 +7862,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
7060
7862
 
7061
7863
  try {
7062
7864
  if (queueableFn.fn.length === 0) {
7063
- var maybeThenable = queueableFn.fn.call(self.userContext);
7865
+ maybeThenable = queueableFn.fn.call(self.userContext);
7064
7866
 
7065
7867
  if (maybeThenable && j$.isFunction_(maybeThenable.then)) {
7066
7868
  maybeThenable.then(next, onPromiseRejection);
@@ -7068,7 +7870,8 @@ getJasmineRequireObj().QueueRunner = function(j$) {
7068
7870
  return { completedSynchronously: false };
7069
7871
  }
7070
7872
  } else {
7071
- queueableFn.fn.call(self.userContext, next);
7873
+ maybeThenable = queueableFn.fn.call(self.userContext, next);
7874
+ this.diagnoseConflictingAsync_(queueableFn.fn, maybeThenable);
7072
7875
  completedSynchronously = false;
7073
7876
  return { completedSynchronously: false };
7074
7877
  }
@@ -7121,6 +7924,29 @@ getJasmineRequireObj().QueueRunner = function(j$) {
7121
7924
  });
7122
7925
  };
7123
7926
 
7927
+ QueueRunner.prototype.diagnoseConflictingAsync_ = function(fn, retval) {
7928
+ if (retval && j$.isFunction_(retval.then)) {
7929
+ // Issue a warning that matches the user's code
7930
+ if (j$.isAsyncFunction_(fn)) {
7931
+ this.deprecated(
7932
+ 'An asynchronous before/it/after ' +
7933
+ 'function was defined with the async keyword but also took a ' +
7934
+ 'done callback. This is not supported and will stop working in' +
7935
+ ' the future. Either remove the done callback (recommended) or ' +
7936
+ 'remove the async keyword.'
7937
+ );
7938
+ } else {
7939
+ this.deprecated(
7940
+ 'An asynchronous before/it/after ' +
7941
+ 'function took a done callback but also returned a promise. ' +
7942
+ 'This is not supported and will stop working in the future. ' +
7943
+ 'Either remove the done callback (recommended) or change the ' +
7944
+ 'function to not return a promise.'
7945
+ );
7946
+ }
7947
+ }
7948
+ };
7949
+
7124
7950
  return QueueRunner;
7125
7951
  };
7126
7952
 
@@ -7486,10 +8312,11 @@ getJasmineRequireObj().interface = function(jasmine, env) {
7486
8312
  * @function
7487
8313
  * @global
7488
8314
  * @param {Object} obj - The object upon which to install the {@link Spy}s
8315
+ * @param {boolean} includeNonEnumerable - Whether or not to add spies to non-enumerable properties
7489
8316
  * @returns {Object} the spied object
7490
8317
  */
7491
- spyOnAllFunctions: function(obj) {
7492
- return env.spyOnAllFunctions(obj);
8318
+ spyOnAllFunctions: function(obj, includeNonEnumerable) {
8319
+ return env.spyOnAllFunctions(obj, includeNonEnumerable);
7493
8320
  },
7494
8321
 
7495
8322
  jsApiReporter: new jasmine.JsApiReporter({
@@ -7552,7 +8379,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
7552
8379
  * @since 3.6.0
7553
8380
  * @function
7554
8381
  * @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 custom_object_formatter
8382
+ * @see custom_object_formatters
7556
8383
  */
7557
8384
  jasmine.addCustomObjectFormatter = function(formatter) {
7558
8385
  return env.addCustomObjectFormatter(formatter);
@@ -7644,9 +8471,11 @@ getJasmineRequireObj().Spy = function(j$) {
7644
8471
  });
7645
8472
 
7646
8473
  /**
7647
- * _Note:_ Do not construct this directly, use {@link spyOn}, {@link spyOnProperty}, {@link jasmine.createSpy}, or {@link jasmine.createSpyObj}
7648
- * @constructor
7649
- * @name Spy
8474
+ * @classdesc _Note:_ Do not construct this directly. Use {@link spyOn},
8475
+ * {@link spyOnProperty}, {@link jasmine.createSpy}, or
8476
+ * {@link jasmine.createSpyObj} instead.
8477
+ * @class Spy
8478
+ * @hideconstructor
7650
8479
  */
7651
8480
  function Spy(
7652
8481
  name,
@@ -7675,6 +8504,7 @@ getJasmineRequireObj().Spy = function(j$) {
7675
8504
  * @property {object} object - `this` context for the invocation.
7676
8505
  * @property {number} invocationOrder - Order of the invocation.
7677
8506
  * @property {Array} args - The arguments passed for this invocation.
8507
+ * @property returnValue - The value that was returned from this invocation.
7678
8508
  */
7679
8509
  var callData = {
7680
8510
  object: context,
@@ -7887,6 +8717,7 @@ getJasmineRequireObj().SpyFactory = function(j$) {
7887
8717
  var properties = normalizeKeyValues(propertyNames);
7888
8718
  for (var i = 0; i < properties.length; i++) {
7889
8719
  descriptor = {
8720
+ enumerable: true,
7890
8721
  get: self.createSpy(baseName + '.' + properties[i][0] + '.get'),
7891
8722
  set: self.createSpy(baseName + '.' + properties[i][0] + '.set')
7892
8723
  };
@@ -8089,7 +8920,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
8089
8920
  return spy;
8090
8921
  };
8091
8922
 
8092
- this.spyOnAllFunctions = function(obj) {
8923
+ this.spyOnAllFunctions = function(obj, includeNonEnumerable) {
8093
8924
  if (j$.util.isUndefined(obj)) {
8094
8925
  throw new Error(
8095
8926
  'spyOnAllFunctions could not find an object to spy upon'
@@ -8097,30 +8928,27 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
8097
8928
  }
8098
8929
 
8099
8930
  var pointer = obj,
8100
- props = [],
8101
- prop,
8102
- descriptor;
8931
+ propsToSpyOn = [],
8932
+ properties,
8933
+ propertiesToSkip = [];
8103
8934
 
8104
- while (pointer) {
8105
- for (prop in pointer) {
8106
- if (
8107
- Object.prototype.hasOwnProperty.call(pointer, prop) &&
8108
- pointer[prop] instanceof Function
8109
- ) {
8110
- descriptor = Object.getOwnPropertyDescriptor(pointer, prop);
8111
- if (
8112
- (descriptor.writable || descriptor.set) &&
8113
- descriptor.configurable
8114
- ) {
8115
- props.push(prop);
8116
- }
8117
- }
8118
- }
8935
+ while (
8936
+ pointer &&
8937
+ (!includeNonEnumerable || pointer !== Object.prototype)
8938
+ ) {
8939
+ properties = getProps(pointer, includeNonEnumerable);
8940
+ properties = properties.filter(function(prop) {
8941
+ return propertiesToSkip.indexOf(prop) === -1;
8942
+ });
8943
+ propertiesToSkip = propertiesToSkip.concat(properties);
8944
+ propsToSpyOn = propsToSpyOn.concat(
8945
+ getSpyableFunctionProps(pointer, properties)
8946
+ );
8119
8947
  pointer = Object.getPrototypeOf(pointer);
8120
8948
  }
8121
8949
 
8122
- for (var i = 0; i < props.length; i++) {
8123
- this.spyOn(obj, props[i]);
8950
+ for (var i = 0; i < propsToSpyOn.length; i++) {
8951
+ this.spyOn(obj, propsToSpyOn[i]);
8124
8952
  }
8125
8953
 
8126
8954
  return obj;
@@ -8135,6 +8963,50 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
8135
8963
  };
8136
8964
  }
8137
8965
 
8966
+ function getProps(obj, includeNonEnumerable) {
8967
+ var enumerableProperties = Object.keys(obj);
8968
+
8969
+ if (!includeNonEnumerable) {
8970
+ return enumerableProperties;
8971
+ }
8972
+
8973
+ return Object.getOwnPropertyNames(obj).filter(function(prop) {
8974
+ return (
8975
+ prop !== 'constructor' ||
8976
+ enumerableProperties.indexOf('constructor') > -1
8977
+ );
8978
+ });
8979
+ }
8980
+
8981
+ function getSpyableFunctionProps(obj, propertiesToCheck) {
8982
+ var props = [],
8983
+ prop;
8984
+ for (var i = 0; i < propertiesToCheck.length; i++) {
8985
+ prop = propertiesToCheck[i];
8986
+ if (
8987
+ Object.prototype.hasOwnProperty.call(obj, prop) &&
8988
+ isSpyableProp(obj, prop)
8989
+ ) {
8990
+ props.push(prop);
8991
+ }
8992
+ }
8993
+ return props;
8994
+ }
8995
+
8996
+ function isSpyableProp(obj, prop) {
8997
+ var value, descriptor;
8998
+ try {
8999
+ value = obj[prop];
9000
+ } catch (e) {
9001
+ return false;
9002
+ }
9003
+ if (value instanceof Function) {
9004
+ descriptor = Object.getOwnPropertyDescriptor(obj, prop);
9005
+ return (descriptor.writable || descriptor.set) && descriptor.configurable;
9006
+ }
9007
+ return false;
9008
+ }
9009
+
8138
9010
  return SpyRegistry;
8139
9011
  };
8140
9012
 
@@ -8308,7 +9180,13 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
8308
9180
  * @param {Function} fn The function to invoke with the passed parameters.
8309
9181
  */
8310
9182
  SpyStrategy.prototype.callFake = function(fn) {
8311
- if (!(j$.isFunction_(fn) || j$.isAsyncFunction_(fn))) {
9183
+ if (
9184
+ !(
9185
+ j$.isFunction_(fn) ||
9186
+ j$.isAsyncFunction_(fn) ||
9187
+ j$.isGeneratorFunction_(fn)
9188
+ )
9189
+ ) {
8312
9190
  throw new Error(
8313
9191
  'Argument passed to callFake should be a function, got ' + fn
8314
9192
  );
@@ -8461,10 +9339,32 @@ getJasmineRequireObj().StackTrace = function(j$) {
8461
9339
  };
8462
9340
 
8463
9341
  getJasmineRequireObj().Suite = function(j$) {
9342
+ /**
9343
+ * @interface Suite
9344
+ * @see Env#topSuite
9345
+ */
8464
9346
  function Suite(attrs) {
8465
9347
  this.env = attrs.env;
9348
+ /**
9349
+ * The unique ID of this suite.
9350
+ * @name Suite#id
9351
+ * @readonly
9352
+ * @type {string}
9353
+ */
8466
9354
  this.id = attrs.id;
9355
+ /**
9356
+ * The parent of this suite, or null if this is the top suite.
9357
+ * @name Suite#parentSuite
9358
+ * @readonly
9359
+ * @type {Suite}
9360
+ */
8467
9361
  this.parentSuite = attrs.parentSuite;
9362
+ /**
9363
+ * The description passed to the {@link describe} that created this suite.
9364
+ * @name Suite#description
9365
+ * @readonly
9366
+ * @type {string}
9367
+ */
8468
9368
  this.description = attrs.description;
8469
9369
  this.expectationFactory = attrs.expectationFactory;
8470
9370
  this.asyncExpectationFactory = attrs.asyncExpectationFactory;
@@ -8478,6 +9378,11 @@ getJasmineRequireObj().Suite = function(j$) {
8478
9378
 
8479
9379
  this.timer = attrs.timer || new j$.Timer();
8480
9380
 
9381
+ /**
9382
+ * The suite's children.
9383
+ * @name Suite#children
9384
+ * @type {Array.<(Spec|Suite)>}
9385
+ */
8481
9386
  this.children = [];
8482
9387
 
8483
9388
  /**
@@ -8515,6 +9420,12 @@ getJasmineRequireObj().Suite = function(j$) {
8515
9420
  return this.asyncExpectationFactory(actual, this);
8516
9421
  };
8517
9422
 
9423
+ /**
9424
+ * The full description including all ancestors of this suite.
9425
+ * @name Suite#getFullName
9426
+ * @function
9427
+ * @returns {string}
9428
+ */
8518
9429
  Suite.prototype.getFullName = function() {
8519
9430
  var fullName = [];
8520
9431
  for (
@@ -8961,5 +9872,5 @@ getJasmineRequireObj().UserContext = function(j$) {
8961
9872
  };
8962
9873
 
8963
9874
  getJasmineRequireObj().version = function() {
8964
- return '3.6.0';
9875
+ return '3.9.0';
8965
9876
  };