jasmine-core 2.7.0 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5517bbc48f6454b1ca988b0597b95cbb01150b1
4
- data.tar.gz: ba02fd49a073847ef3d322715dfbc99707090f4f
3
+ metadata.gz: af3fdbce40dc44c9c0129b5ddd5137720bcf9319
4
+ data.tar.gz: d22c15e0965fc94de0bb67e9efbc4fbe2bd403b6
5
5
  SHA512:
6
- metadata.gz: 65a948e7728d15413d2a01f59c95977bb3b989a8082490eddb82935134e67345a34c7bce3f20c5d6f1e93b8d02d4e29d48c066709c732df23ed0bf5438211261
7
- data.tar.gz: ccdf26d3da662633660c0c925fab57aa77bde6c490f79869ed625dd8fc42c86f44156a4d1cf19fd0783382a586fbaaa1466e250efbe0a93a95b5a7e2eaff3f55
6
+ metadata.gz: a8b6b5234a6935dbeeab646a474153c81954e677d43f95a34dba63f6d2e8e2e7a8a163abbd7c5b3d563180eba1bd15a199187f2342575bb31993eb84d574ad67
7
+ data.tar.gz: 32b6e96b74c6e630f849dd68ca813b4bf8edef110251079b55cfe2c4ef031613c70a496f03cb7b3e2dcec678f10baf7d0a9e297e5310a96353357882958b4492
@@ -63,6 +63,7 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
63
63
  j$.matchersUtil = jRequire.matchersUtil(j$);
64
64
  j$.ObjectContaining = jRequire.ObjectContaining(j$);
65
65
  j$.ArrayContaining = jRequire.ArrayContaining(j$);
66
+ j$.ArrayWithExactContents = jRequire.ArrayWithExactContents(j$);
66
67
  j$.pp = jRequire.pp(j$);
67
68
  j$.QueueRunner = jRequire.QueueRunner(j$);
68
69
  j$.ReportDispatcher = jRequire.ReportDispatcher();
@@ -92,6 +93,7 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
92
93
 
93
94
  getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
94
95
  var availableMatchers = [
96
+ 'nothing',
95
97
  'toBe',
96
98
  'toBeCloseTo',
97
99
  'toBeDefined',
@@ -191,6 +193,18 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
191
193
  return j$.isA_('AsyncFunction', value);
192
194
  };
193
195
 
196
+ j$.isTypedArray_ = function(value) {
197
+ return j$.isA_('Float32Array', value) ||
198
+ j$.isA_('Float64Array', value) ||
199
+ j$.isA_('Int16Array', value) ||
200
+ j$.isA_('Int32Array', value) ||
201
+ j$.isA_('Int8Array', value) ||
202
+ j$.isA_('Uint16Array', value) ||
203
+ j$.isA_('Uint32Array', value) ||
204
+ j$.isA_('Uint8Array', value) ||
205
+ j$.isA_('Uint8ClampedArray', value);
206
+ };
207
+
194
208
  j$.isA_ = function(typeName, value) {
195
209
  return j$.getType_(value) === '[object ' + typeName + ']';
196
210
  };
@@ -208,7 +222,9 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
208
222
  return func.name;
209
223
  }
210
224
 
211
- var matches = func.toString().match(/^\s*function\s*(\w*)\s*\(/);
225
+ var matches = func.toString().match(/^\s*function\s*(\w*)\s*\(/) ||
226
+ func.toString().match(/^\s*\[object\s*(\w*)Constructor\]/);
227
+
212
228
  return matches ? matches[1] : '<anonymous>';
213
229
  };
214
230
 
@@ -266,6 +282,17 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
266
282
  return new j$.ArrayContaining(sample);
267
283
  };
268
284
 
285
+ /**
286
+ * 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}),
287
+ * that will succeed if the actual value is an `Array` that contains all of the elements in the sample in any order.
288
+ * @name jasmine.arrayWithExactContents
289
+ * @function
290
+ * @param {Array} sample
291
+ */
292
+ j$.arrayWithExactContents = function(sample) {
293
+ return new j$.ArrayWithExactContents(sample);
294
+ };
295
+
269
296
  /**
270
297
  * Create a bare {@link Spy} object. This won't be installed anywhere and will not have any implementation behind it.
271
298
  * @name jasmine.createSpy
@@ -436,6 +463,16 @@ getJasmineRequireObj().Spec = function(j$) {
436
463
  this.pend();
437
464
  }
438
465
 
466
+ /**
467
+ * @typedef SpecResult
468
+ * @property {Int} id - The unique id of this spec.
469
+ * @property {String} description - The description passed to the {@link it} that created this spec.
470
+ * @property {String} fullName - The full description including all ancestors of this spec.
471
+ * @property {Expectation[]} failedExpectations - The list of expectations that failed during execution of this spec.
472
+ * @property {Expectation[]} passedExpectations - The list of expectations that passed during execution of this spec.
473
+ * @property {String} pendingReason - If the spec is {@link pending}, this will be the reason.
474
+ * @property {String} status - Once the spec has completed, this string represents the pass/fail status of this spec.
475
+ */
439
476
  this.result = {
440
477
  id: this.id,
441
478
  description: this.description,
@@ -664,12 +701,56 @@ getJasmineRequireObj().Env = function(j$) {
664
701
  return currentSpec || currentSuite();
665
702
  };
666
703
 
704
+ /**
705
+ * This represents the available reporter callback for an object passed to {@link Env#addReporter}.
706
+ * @interface Reporter
707
+ */
667
708
  var reporter = new j$.ReportDispatcher([
709
+ /**
710
+ * `jasmineStarted` is called after all of the specs have been loaded, but just before execution starts.
711
+ * @function
712
+ * @name Reporter#jasmineStarted
713
+ * @param {JasmineStartedInfo} suiteInfo Information about the full Jasmine suite that is being run
714
+ */
668
715
  'jasmineStarted',
716
+ /**
717
+ * When the entire suite has finished execution `jasmineDone` is called
718
+ * @function
719
+ * @name Reporter#jasmineDone
720
+ * @param {JasmineDoneInfo} suiteInfo Information about the full Jasmine suite that just finished running.
721
+ */
669
722
  'jasmineDone',
723
+ /**
724
+ * `suiteStarted` is invoked when a `describe` starts to run
725
+ * @function
726
+ * @name Reporter#suiteStarted
727
+ * @param {SuiteResult} result Information about the individual {@link describe} being run
728
+ */
670
729
  'suiteStarted',
730
+ /**
731
+ * `suiteDone` is invoked when all of the child specs and suites for a given suite have been run
732
+ *
733
+ * While jasmine doesn't require any specific functions, not defining a `suiteDone` will make it impossible for a reporter to know when a suite has failures in an `afterAll`.
734
+ * @function
735
+ * @name Reporter#suiteDone
736
+ * @param {SuiteResult} result
737
+ */
671
738
  'suiteDone',
739
+ /**
740
+ * `specStarted` is invoked when an `it` starts to run (including associated `beforeEach` functions)
741
+ * @function
742
+ * @name Reporter#specStarted
743
+ * @param {SpecResult} result Information about the individual {@link it} being run
744
+ */
672
745
  'specStarted',
746
+ /**
747
+ * `specDone` is invoked when an `it` and its associated `beforeEach` and `afterEach` functions have been run.
748
+ *
749
+ * While jasmine doesn't require any specific functions, not defining a `specDone` will make it impossible for a reporter to know when a spec has failed.
750
+ * @function
751
+ * @name Reporter#specDone
752
+ * @param {SpecResult} result
753
+ */
673
754
  'specDone'
674
755
  ]);
675
756
 
@@ -885,6 +966,12 @@ getJasmineRequireObj().Env = function(j$) {
885
966
  throw new Error('Invalid order: would cause a beforeAll or afterAll to be run multiple times');
886
967
  }
887
968
 
969
+ /**
970
+ * Information passed to the {@link Reporter#jasmineStarted} event.
971
+ * @typedef JasmineStartedInfo
972
+ * @property {Int} totalSpecsDefined - The total number of specs defined in this suite.
973
+ * @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
974
+ */
888
975
  reporter.jasmineStarted({
889
976
  totalSpecsDefined: totalSpecsDefined,
890
977
  order: order
@@ -898,6 +985,12 @@ getJasmineRequireObj().Env = function(j$) {
898
985
  currentlyExecutingSuites.pop();
899
986
  globalErrors.uninstall();
900
987
 
988
+ /**
989
+ * Information passed to the {@link Reporter#jasmineDone} event.
990
+ * @typedef JasmineDoneInfo
991
+ * @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
992
+ * @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
993
+ */
901
994
  reporter.jasmineDone({
902
995
  order: order,
903
996
  failedExpectations: topSuite.result.failedExpectations
@@ -909,6 +1002,7 @@ getJasmineRequireObj().Env = function(j$) {
909
1002
  * Add a custom reporter to the Jasmine environment.
910
1003
  * @name Env#addReporter
911
1004
  * @function
1005
+ * @param {Reporter} reporterToAdd The reporter to be added.
912
1006
  * @see custom_reporter
913
1007
  */
914
1008
  this.addReporter = function(reporterToAdd) {
@@ -1215,11 +1309,10 @@ getJasmineRequireObj().JsApiReporter = function() {
1215
1309
  };
1216
1310
 
1217
1311
  /**
1218
- * _Note:_ Do not construct this directly, use the global `jsApiReporter` to retrieve the instantiated object.
1219
- *
1220
1312
  * @name jsApiReporter
1221
- * @classdesc Reporter added by default in `boot.js` to record results for retrieval in javascript code.
1313
+ * @classdesc {@link Reporter} added by default in `boot.js` to record results for retrieval in javascript code. An instance is made available as `jsApiReporter` on the global object.
1222
1314
  * @class
1315
+ * @hideconstructor
1223
1316
  */
1224
1317
  function JsApiReporter(options) {
1225
1318
  var timer = options.timer || noopTimer,
@@ -1273,7 +1366,7 @@ getJasmineRequireObj().JsApiReporter = function() {
1273
1366
  * @function
1274
1367
  * @param {Number} index - The position in the suites list to start from.
1275
1368
  * @param {Number} length - Maximum number of suite results to return.
1276
- * @return {Object[]}
1369
+ * @return {SuiteResult[]}
1277
1370
  */
1278
1371
  this.suiteResults = function(index, length) {
1279
1372
  return suites.slice(index, index + length);
@@ -1288,7 +1381,7 @@ getJasmineRequireObj().JsApiReporter = function() {
1288
1381
  * Get all of the suites in a single object, with their `id` as the key.
1289
1382
  * @name jsApiReporter#suites
1290
1383
  * @function
1291
- * @return {Object}
1384
+ * @return {Object} - Map of suite id to {@link SuiteResult}
1292
1385
  */
1293
1386
  this.suites = function() {
1294
1387
  return suites_hash;
@@ -1308,7 +1401,7 @@ getJasmineRequireObj().JsApiReporter = function() {
1308
1401
  * @function
1309
1402
  * @param {Number} index - The position in the specs list to start from.
1310
1403
  * @param {Number} length - Maximum number of specs results to return.
1311
- * @return {Object[]}
1404
+ * @return {SpecResult[]}
1312
1405
  */
1313
1406
  this.specResults = function(index, length) {
1314
1407
  return specs.slice(index, index + length);
@@ -1318,7 +1411,7 @@ getJasmineRequireObj().JsApiReporter = function() {
1318
1411
  * Get all spec results.
1319
1412
  * @name jsApiReporter#specs
1320
1413
  * @function
1321
- * @return {Object[]}
1414
+ * @return {SpecResult[]}
1322
1415
  */
1323
1416
  this.specs = function() {
1324
1417
  return specs;
@@ -1403,8 +1496,9 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
1403
1496
  }
1404
1497
 
1405
1498
  ArrayContaining.prototype.asymmetricMatch = function(other, customTesters) {
1406
- var className = Object.prototype.toString.call(this.sample);
1407
- if (className !== '[object Array]') { throw new Error('You must provide an array to arrayContaining, not \'' + this.sample + '\'.'); }
1499
+ if (!j$.isArray_(this.sample)) {
1500
+ throw new Error('You must provide an array to arrayContaining, not ' + j$.pp(this.sample) + '.');
1501
+ }
1408
1502
 
1409
1503
  for (var i = 0; i < this.sample.length; i++) {
1410
1504
  var item = this.sample[i];
@@ -1423,6 +1517,38 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
1423
1517
  return ArrayContaining;
1424
1518
  };
1425
1519
 
1520
+ getJasmineRequireObj().ArrayWithExactContents = function(j$) {
1521
+
1522
+ function ArrayWithExactContents(sample) {
1523
+ this.sample = sample;
1524
+ }
1525
+
1526
+ ArrayWithExactContents.prototype.asymmetricMatch = function(other, customTesters) {
1527
+ if (!j$.isArray_(this.sample)) {
1528
+ throw new Error('You must provide an array to arrayWithExactContents, not ' + j$.pp(this.sample) + '.');
1529
+ }
1530
+
1531
+ if (this.sample.length !== other.length) {
1532
+ return false;
1533
+ }
1534
+
1535
+ for (var i = 0; i < this.sample.length; i++) {
1536
+ var item = this.sample[i];
1537
+ if (!j$.matchersUtil.contains(other, item, customTesters)) {
1538
+ return false;
1539
+ }
1540
+ }
1541
+
1542
+ return true;
1543
+ };
1544
+
1545
+ ArrayWithExactContents.prototype.jasmineToString = function() {
1546
+ return '<jasmine.arrayWithExactContents ' + j$.pp(this.sample) + '>';
1547
+ };
1548
+
1549
+ return ArrayWithExactContents;
1550
+ };
1551
+
1426
1552
  getJasmineRequireObj().ObjectContaining = function(j$) {
1427
1553
 
1428
1554
  function ObjectContaining(sample) {
@@ -1507,10 +1633,13 @@ getJasmineRequireObj().CallTracker = function(j$) {
1507
1633
  var clonedArgs = [];
1508
1634
  var argsAsArray = j$.util.argsToArray(context.args);
1509
1635
  for(var i = 0; i < argsAsArray.length; i++) {
1510
- if(Object.prototype.toString.apply(argsAsArray[i]).match(/^\[object/)) {
1511
- clonedArgs.push(j$.util.clone(argsAsArray[i]));
1512
- } else {
1636
+ var str = Object.prototype.toString.apply(argsAsArray[i]),
1637
+ primitives = /^\[object (Boolean|String|RegExp|Number)/;
1638
+
1639
+ if (argsAsArray[i] == null || str.match(primitives)) {
1513
1640
  clonedArgs.push(argsAsArray[i]);
1641
+ } else {
1642
+ clonedArgs.push(j$.util.clone(argsAsArray[i]));
1514
1643
  }
1515
1644
  }
1516
1645
  context.args = clonedArgs;
@@ -2164,6 +2293,15 @@ getJasmineRequireObj().buildExpectationResult = function() {
2164
2293
  var messageFormatter = options.messageFormatter || function() {},
2165
2294
  stackFormatter = options.stackFormatter || function() {};
2166
2295
 
2296
+ /**
2297
+ * @typedef Expectation
2298
+ * @property {String} matcherName - The name of the matcher that was executed for this expectation.
2299
+ * @property {String} message - The failure message for the expectation.
2300
+ * @property {String} stack - The stack trace for the failure if available.
2301
+ * @property {Boolean} passed - Whether the expectation passed or failed.
2302
+ * @property {Object} expected - If the expectation failed, what was the expected value.
2303
+ * @property {Object} actual - If the expectation failed, what actual value was produced.
2304
+ */
2167
2305
  var result = {
2168
2306
  matcherName: options.matcherName,
2169
2307
  message: message(),
@@ -2374,13 +2512,17 @@ getJasmineRequireObj().matchersUtil = function(j$) {
2374
2512
 
2375
2513
  if (asymmetricA) {
2376
2514
  result = a.asymmetricMatch(b, customTesters);
2377
- diffBuilder.record(a, b);
2515
+ if (!result) {
2516
+ diffBuilder.record(a, b);
2517
+ }
2378
2518
  return result;
2379
2519
  }
2380
2520
 
2381
2521
  if (asymmetricB) {
2382
2522
  result = b.asymmetricMatch(a, customTesters);
2383
- diffBuilder.record(a, b);
2523
+ if (!result) {
2524
+ diffBuilder.record(a, b);
2525
+ }
2384
2526
  return result;
2385
2527
  }
2386
2528
  }
@@ -2533,35 +2675,84 @@ getJasmineRequireObj().matchersUtil = function(j$) {
2533
2675
  // Recursively compare objects and arrays.
2534
2676
  // Compare array lengths to determine if a deep comparison is necessary.
2535
2677
  if (className == '[object Array]') {
2536
- size = a.length;
2537
- if (size !== b.length) {
2678
+ var aLength = a.length;
2679
+ var bLength = b.length;
2680
+
2681
+ diffBuilder.withPath('length', function() {
2682
+ if (aLength !== bLength) {
2683
+ diffBuilder.record(aLength, bLength);
2684
+ result = false;
2685
+ }
2686
+ });
2687
+
2688
+ for (i = 0; i < aLength || i < bLength; i++) {
2689
+ diffBuilder.withPath(i, function() {
2690
+ result = eq(i < aLength ? a[i] : void 0, i < bLength ? b[i] : void 0, aStack, bStack, customTesters, diffBuilder) && result;
2691
+ });
2692
+ }
2693
+ if (!result) {
2694
+ return false;
2695
+ }
2696
+ } else if (className == '[object Map]') {
2697
+ if (a.size != b.size) {
2538
2698
  diffBuilder.record(a, b);
2539
2699
  return false;
2540
2700
  }
2541
2701
 
2542
- for (i = 0; i < size; i++) {
2543
- diffBuilder.withPath(i, function() {
2544
- result = eq(a[i], b[i], aStack, bStack, customTesters, diffBuilder) && result;
2545
- });
2702
+ // For both sets of keys, check they map to equal values in both maps
2703
+ var mapKeys = [a.keys(), b.keys()];
2704
+ var mapIter, mapKeyIt, mapKey;
2705
+ for (i = 0; result && i < mapKeys.length; i++) {
2706
+ mapIter = mapKeys[i];
2707
+ mapKeyIt = mapIter.next();
2708
+ while (result && !mapKeyIt.done) {
2709
+ mapKey = mapKeyIt.value;
2710
+ result = eq(a.get(mapKey), b.get(mapKey), aStack, bStack, customTesters, j$.NullDiffBuilder());
2711
+ mapKeyIt = mapIter.next();
2712
+ }
2546
2713
  }
2714
+
2547
2715
  if (!result) {
2716
+ diffBuilder.record(a, b);
2548
2717
  return false;
2549
2718
  }
2550
- } else if (className == '[object Set]' || className == '[object Map]') {
2719
+ } else if (className == '[object Set]') {
2551
2720
  if (a.size != b.size) {
2552
2721
  diffBuilder.record(a, b);
2553
2722
  return false;
2554
2723
  }
2555
- var iterA = a.entries(), iterB = b.entries();
2556
- var valA, valB;
2557
- do {
2558
- valA = iterA.next();
2559
- valB = iterB.next();
2560
- if (!eq(valA.value, valB.value, aStack, bStack, customTesters, j$.NullDiffBuilder())) {
2561
- diffBuilder.record(a, b);
2562
- return false;
2724
+
2725
+ // For both sets, check they are all contained in the other set
2726
+ var setPairs = [[a, b], [b, a]];
2727
+ var baseIter, baseValueIt, baseValue;
2728
+ var otherSet, otherIter, otherValueIt, otherValue, found;
2729
+ for (i = 0; result && i < setPairs.length; i++) {
2730
+ baseIter = setPairs[i][0].values();
2731
+ otherSet = setPairs[i][1];
2732
+ // For each value in the base set...
2733
+ baseValueIt = baseIter.next();
2734
+ while (result && !baseValueIt.done) {
2735
+ baseValue = baseValueIt.value;
2736
+ // ... test that it is present in the other set
2737
+ otherIter = otherSet.values();
2738
+ otherValueIt = otherIter.next();
2739
+ // Optimisation: start looking for value by object identity
2740
+ found = otherSet.has(baseValue);
2741
+ // If not found, compare by value equality
2742
+ while (!found && !otherValueIt.done) {
2743
+ otherValue = otherValueIt.value;
2744
+ found = eq(baseValue, otherValue, aStack, bStack, customTesters, j$.NullDiffBuilder());
2745
+ otherValueIt = otherIter.next();
2746
+ }
2747
+ result = result && found;
2748
+ baseValueIt = baseIter.next();
2563
2749
  }
2564
- } while (!valA.done && !valB.done);
2750
+ }
2751
+
2752
+ if (!result) {
2753
+ diffBuilder.record(a, b);
2754
+ return false;
2755
+ }
2565
2756
  } else {
2566
2757
 
2567
2758
  // Objects with different constructors are not equivalent, but `Object`s
@@ -2694,6 +2885,27 @@ getJasmineRequireObj().matchersUtil = function(j$) {
2694
2885
  }
2695
2886
  };
2696
2887
 
2888
+ getJasmineRequireObj().nothing = function() {
2889
+ /**
2890
+ * {@link expect} nothing explicitly.
2891
+ * @function
2892
+ * @name matchers#nothing
2893
+ * @example
2894
+ * expect().nothing();
2895
+ */
2896
+ function nothing() {
2897
+ return {
2898
+ compare: function() {
2899
+ return {
2900
+ pass: true
2901
+ };
2902
+ }
2903
+ };
2904
+ }
2905
+
2906
+ return nothing;
2907
+ };
2908
+
2697
2909
  getJasmineRequireObj().NullDiffBuilder = function(j$) {
2698
2910
  return function() {
2699
2911
  return {
@@ -3716,6 +3928,8 @@ getJasmineRequireObj().pp = function(j$) {
3716
3928
  this.emitSet(value);
3717
3929
  } else if (j$.getType_(value) == '[object Map]') {
3718
3930
  this.emitMap(value);
3931
+ } else if (j$.isTypedArray_(value)) {
3932
+ this.emitTypedArray(value);
3719
3933
  } else if (value.toString && typeof value === 'object' && !j$.isArray_(value) && hasCustomToString(value)) {
3720
3934
  this.emitScalar(value.toString());
3721
3935
  } else if (j$.util.arrayContains(this.seen, value)) {
@@ -3886,6 +4100,18 @@ getJasmineRequireObj().pp = function(j$) {
3886
4100
  this.append(' })');
3887
4101
  };
3888
4102
 
4103
+ StringPrettyPrinter.prototype.emitTypedArray = function(arr) {
4104
+ var constructorName = j$.fnNameFor(arr.constructor),
4105
+ limitedArray = Array.prototype.slice.call(arr, 0, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH),
4106
+ itemsString = Array.prototype.join.call(limitedArray, ', ');
4107
+
4108
+ if (limitedArray.length !== arr.length) {
4109
+ itemsString += ', ...';
4110
+ }
4111
+
4112
+ this.append(constructorName + ' [ ' + itemsString + ' ]');
4113
+ };
4114
+
3889
4115
  StringPrettyPrinter.prototype.formatProperty = function(obj, property, isGetter) {
3890
4116
  this.append(property);
3891
4117
  this.append(': ');
@@ -4149,6 +4375,16 @@ getJasmineRequireObj().ReportDispatcher = function() {
4149
4375
 
4150
4376
  getJasmineRequireObj().interface = function(jasmine, env) {
4151
4377
  var jasmineInterface = {
4378
+ /**
4379
+ * Callback passed to parts of the Jasmine base interface.
4380
+ *
4381
+ * By default Jasmine assumes this function completes synchronously.
4382
+ * If you have code that you need to test asynchronously, you can declare that you receive a `done` callback, return a Promise, or use the `async` keyword if it is supported in your environment.
4383
+ * @callback implementationCallback
4384
+ * @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
4385
+ * @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
4386
+ */
4387
+
4152
4388
  /**
4153
4389
  * Create a group of specs (often called a suite).
4154
4390
  *
@@ -4157,7 +4393,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
4157
4393
  * @function
4158
4394
  * @global
4159
4395
  * @param {String} description Textual description of the group
4160
- * @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites a specs
4396
+ * @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites and specs
4161
4397
  */
4162
4398
  describe: function(description, specDefinitions) {
4163
4399
  return env.describe(description, specDefinitions);
@@ -4171,7 +4407,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
4171
4407
  * @function
4172
4408
  * @global
4173
4409
  * @param {String} description Textual description of the group
4174
- * @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites a specs
4410
+ * @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites and specs
4175
4411
  */
4176
4412
  xdescribe: function(description, specDefinitions) {
4177
4413
  return env.xdescribe(description, specDefinitions);
@@ -4186,7 +4422,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
4186
4422
  * @function
4187
4423
  * @global
4188
4424
  * @param {String} description Textual description of the group
4189
- * @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites a specs
4425
+ * @param {Function} specDefinitions Function for Jasmine to invoke that will define inner suites and specs
4190
4426
  */
4191
4427
  fdescribe: function(description, specDefinitions) {
4192
4428
  return env.fdescribe(description, specDefinitions);
@@ -4200,7 +4436,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
4200
4436
  * @function
4201
4437
  * @global
4202
4438
  * @param {String} description Textual description of what this spec is checking
4203
- * @param {Function} [testFunction] Function that contains the code of your test. If not provided the test will be `pending`.
4439
+ * @param {implementationCallback} [testFunction] Function that contains the code of your test. If not provided the test will be `pending`.
4204
4440
  * @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async spec.
4205
4441
  */
4206
4442
  it: function() {
@@ -4215,7 +4451,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
4215
4451
  * @function
4216
4452
  * @global
4217
4453
  * @param {String} description Textual description of what this spec is checking.
4218
- * @param {Function} [testFunction] Function that contains the code of your test. Will not be executed.
4454
+ * @param {implementationCallback} [testFunction] Function that contains the code of your test. Will not be executed.
4219
4455
  */
4220
4456
  xit: function() {
4221
4457
  return env.xit.apply(env, arguments);
@@ -4229,7 +4465,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
4229
4465
  * @function
4230
4466
  * @global
4231
4467
  * @param {String} description Textual description of what this spec is checking.
4232
- * @param {Function} testFunction Function that contains the code of your test.
4468
+ * @param {implementationCallback} testFunction Function that contains the code of your test.
4233
4469
  * @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async spec.
4234
4470
  */
4235
4471
  fit: function() {
@@ -4241,7 +4477,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
4241
4477
  * @name beforeEach
4242
4478
  * @function
4243
4479
  * @global
4244
- * @param {Function} [function] Function that contains the code to setup your specs.
4480
+ * @param {implementationCallback} [function] Function that contains the code to setup your specs.
4245
4481
  * @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async beforeEach.
4246
4482
  */
4247
4483
  beforeEach: function() {
@@ -4253,7 +4489,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
4253
4489
  * @name afterEach
4254
4490
  * @function
4255
4491
  * @global
4256
- * @param {Function} [function] Function that contains the code to teardown your specs.
4492
+ * @param {implementationCallback} [function] Function that contains the code to teardown your specs.
4257
4493
  * @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async afterEach.
4258
4494
  */
4259
4495
  afterEach: function() {
@@ -4267,7 +4503,7 @@ getJasmineRequireObj().interface = function(jasmine, env) {
4267
4503
  * @name beforeAll
4268
4504
  * @function
4269
4505
  * @global
4270
- * @param {Function} [function] Function that contains the code to setup your specs.
4506
+ * @param {implementationCallback} [function] Function that contains the code to setup your specs.
4271
4507
  * @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async beforeAll.
4272
4508
  */
4273
4509
  beforeAll: function() {
@@ -4275,13 +4511,13 @@ getJasmineRequireObj().interface = function(jasmine, env) {
4275
4511
  },
4276
4512
 
4277
4513
  /**
4278
- * Run some shared teardown once before all of the specs in the {@link describe} are run.
4514
+ * Run some shared teardown once after all of the specs in the {@link describe} are run.
4279
4515
  *
4280
4516
  * _Note:_ Be careful, sharing the teardown from a afterAll makes it easy to accidentally leak state between your specs so that they erroneously pass or fail.
4281
4517
  * @name afterAll
4282
4518
  * @function
4283
4519
  * @global
4284
- * @param {Function} [function] Function that contains the code to teardown your specs.
4520
+ * @param {implementationCallback} [function] Function that contains the code to teardown your specs.
4285
4521
  * @param {Int} [timeout={@link jasmine.DEFAULT_TIMEOUT_INTERVAL}] Custom timeout for an async afterAll.
4286
4522
  */
4287
4523
  afterAll: function() {
@@ -4748,6 +4984,14 @@ getJasmineRequireObj().Suite = function(j$) {
4748
4984
 
4749
4985
  this.children = [];
4750
4986
 
4987
+ /**
4988
+ * @typedef SuiteResult
4989
+ * @property {Int} id - The unique id of this suite.
4990
+ * @property {String} description - The description text passed to the {@link describe} that made this suite.
4991
+ * @property {String} fullName - The full description including all ancestors of this suite.
4992
+ * @property {Expectation[]} failedExpectations - The list of expectations that failed in an {@link afterAll} for this suite.
4993
+ * @property {String} status - Once the suite has completed, this string represents the pass/fail status of this suite.
4994
+ */
4751
4995
  this.result = {
4752
4996
  id: this.id,
4753
4997
  description: this.description,
@@ -5137,5 +5381,5 @@ getJasmineRequireObj().UserContext = function(j$) {
5137
5381
  };
5138
5382
 
5139
5383
  getJasmineRequireObj().version = function() {
5140
- return '2.7.0';
5384
+ return '2.8.0';
5141
5385
  };
@@ -117,4 +117,14 @@ describe("CallTracker", function() {
117
117
  expect(callTracker.mostRecent().args[1]).not.toBe(arrayArg);
118
118
  expect(callTracker.mostRecent().args[1]).toEqual(arrayArg);
119
119
  });
120
+
121
+ it('saves primitive arguments by value', function() {
122
+ var callTracker = new jasmineUnderTest.CallTracker(),
123
+ args = [undefined, null, false, '', /\s/, 0, 1.2, NaN];
124
+
125
+ callTracker.saveArgumentsByValue();
126
+ callTracker.track({ object: {}, args: args });
127
+
128
+ expect(callTracker.mostRecent().args).toEqual(args);
129
+ });
120
130
  });
@@ -0,0 +1,47 @@
1
+ describe("ArrayWithExactContents", function() {
2
+ it("matches an array with the same items in a different order", function() {
3
+ var matcher = new jasmineUnderTest.ArrayWithExactContents(['a', 2, /a/]);
4
+
5
+ expect(matcher.asymmetricMatch([2, 'a', /a/])).toBe(true);
6
+ });
7
+
8
+ it("does not work when not passed an array", function() {
9
+ var matcher = new jasmineUnderTest.ArrayWithExactContents("foo");
10
+
11
+ expect(function() {
12
+ matcher.asymmetricMatch([]);
13
+ }).toThrowError(/not 'foo'/);
14
+ });
15
+
16
+ it("does not match when an item is missing", function() {
17
+ var matcher = new jasmineUnderTest.ArrayWithExactContents(['a', 2, /a/]);
18
+
19
+ expect(matcher.asymmetricMatch(['a', 2])).toBe(false);
20
+ expect(matcher.asymmetricMatch(['a', 2, undefined])).toBe(false);
21
+ });
22
+
23
+ it("does not match when there is an extra item", function() {
24
+ var matcher = new jasmineUnderTest.ArrayWithExactContents(['a']);
25
+
26
+ expect(matcher.asymmetricMatch(['a', 2])).toBe(false);
27
+ });
28
+
29
+ it("jasmineToStrings itself", function() {
30
+ var matcher = new jasmineUnderTest.ArrayWithExactContents([]);
31
+
32
+ expect(matcher.jasmineToString()).toMatch("<jasmine.arrayWithExactContents");
33
+ });
34
+
35
+ it("uses custom equality testers", function() {
36
+ var tester = function(a, b) {
37
+ // All "foo*" strings match each other.
38
+ if (typeof a == "string" && typeof b == "string" &&
39
+ a.substr(0, 3) == "foo" && b.substr(0, 3) == "foo") {
40
+ return true;
41
+ }
42
+ };
43
+ var matcher = new jasmineUnderTest.ArrayWithExactContents(["fooVal"]);
44
+
45
+ expect(matcher.asymmetricMatch(["fooBar"], [tester])).toBe(true);
46
+ });
47
+ });
@@ -67,8 +67,9 @@ describe("Custom Matchers (Integration)", function() {
67
67
  };
68
68
 
69
69
  env.addCustomEqualityTester(customEqualityFn);
70
- env.expect({foo: 'fooValue'}).toEqual(jasmine.objectContaining({foo: 'fooBar'}));
71
- env.expect(['fooValue']).toEqual(jasmine.arrayContaining(['fooBar']));
70
+ env.expect({foo: 'fooValue'}).toEqual(jasmineUnderTest.objectContaining({foo: 'fooBar'}));
71
+ env.expect(['fooValue', 'things']).toEqual(jasmineUnderTest.arrayContaining(['fooBar']));
72
+ env.expect(['fooValue']).toEqual(jasmineUnderTest.arrayWithExactContents(['fooBar']));
72
73
  });
73
74
 
74
75
  var specExpectations = function(result) {
@@ -786,7 +786,7 @@ describe("Env integration", function() {
786
786
  env.execute();
787
787
  });
788
788
 
789
- it('can be configured to allow respying on functions', function () {
789
+ it('can be configured to allow respying on functions', function (done) {
790
790
  var env = new jasmineUnderTest.Env(),
791
791
  foo = {
792
792
  bar: function () {
@@ -795,6 +795,7 @@ describe("Env integration", function() {
795
795
  };
796
796
 
797
797
  env.allowRespy(true);
798
+ env.addReporter({ jasmineDone: done });
798
799
 
799
800
  env.describe('test suite', function(){
800
801
  env.it('spec 0', function(){
@@ -928,7 +929,14 @@ describe("Env integration", function() {
928
929
  });
929
930
 
930
931
  it("should run async specs in order, waiting for them to complete", function(done) {
931
- var env = new jasmineUnderTest.Env(), mutatedVar;
932
+ var env = new jasmineUnderTest.Env(),
933
+ reporter = jasmine.createSpyObj('reporter', ['jasmineDone']),
934
+ mutatedVar;
935
+
936
+ reporter.jasmineDone.and.callFake(function() {
937
+ done();
938
+ });
939
+ env.addReporter(reporter);
932
940
 
933
941
  env.describe("tests", function() {
934
942
  env.beforeEach(function() {
@@ -939,7 +947,6 @@ describe("Env integration", function() {
939
947
  setTimeout(function() {
940
948
  expect(mutatedVar).toEqual(2);
941
949
  underTestCallback();
942
- done();
943
950
  }, 0);
944
951
  });
945
952
 
@@ -1110,14 +1117,18 @@ describe("Env integration", function() {
1110
1117
 
1111
1118
  env.describe('suite', function() {
1112
1119
  env.afterAll(function() {
1113
- realSetTimeout(function() {
1114
- jasmine.clock().tick(10);
1115
- }, 100);
1120
+ if (jasmine.getEnv().ieVersion < 9) {
1121
+ } else {
1122
+ realSetTimeout(function() {
1123
+ jasmine.clock().tick(10);
1124
+ }, 100);
1125
+ }
1116
1126
  });
1117
1127
  env.describe('beforeAll', function() {
1118
1128
  env.beforeAll(function(innerDone) {
1119
- jasmine.clock().tick(5001);
1120
- innerDone();
1129
+ realSetTimeout(function() {
1130
+ jasmine.clock().tick(5001);
1131
+ }, 0);
1121
1132
  }, 5000);
1122
1133
 
1123
1134
  env.it('times out', function() {});
@@ -1125,8 +1136,9 @@ describe("Env integration", function() {
1125
1136
 
1126
1137
  env.describe('afterAll', function() {
1127
1138
  env.afterAll(function(innerDone) {
1128
- jasmine.clock().tick(2001);
1129
- innerDone();
1139
+ realSetTimeout(function() {
1140
+ jasmine.clock().tick(2001);
1141
+ }, 0);
1130
1142
  }, 2000);
1131
1143
 
1132
1144
  env.it('times out', function() {});
@@ -1134,8 +1146,9 @@ describe("Env integration", function() {
1134
1146
 
1135
1147
  env.describe('beforeEach', function() {
1136
1148
  env.beforeEach(function(innerDone) {
1137
- jasmine.clock().tick(1001);
1138
- innerDone();
1149
+ realSetTimeout(function() {
1150
+ jasmine.clock().tick(1001);
1151
+ }, 0);
1139
1152
  }, 1000);
1140
1153
 
1141
1154
  env.it('times out', function() {});
@@ -1143,16 +1156,18 @@ describe("Env integration", function() {
1143
1156
 
1144
1157
  env.describe('afterEach', function() {
1145
1158
  env.afterEach(function(innerDone) {
1146
- jasmine.clock().tick(4001);
1147
- innerDone();
1159
+ realSetTimeout(function() {
1160
+ jasmine.clock().tick(4001);
1161
+ }, 0);
1148
1162
  }, 4000);
1149
1163
 
1150
1164
  env.it('times out', function() {});
1151
1165
  });
1152
1166
 
1153
1167
  env.it('it times out', function(innerDone) {
1154
- jasmine.clock().tick(6001);
1155
- innerDone();
1168
+ realSetTimeout(function() {
1169
+ jasmine.clock().tick(6001);
1170
+ }, 0);
1156
1171
  }, 6000);
1157
1172
  });
1158
1173
 
@@ -393,6 +393,13 @@ describe("matchersUtil", function() {
393
393
  expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(true);
394
394
  });
395
395
 
396
+ it("passes when comparing identical sets with different insertion order", function() {
397
+ jasmine.getEnv().requireFunctioningSets();
398
+ var setA = new Set([3, 6]);
399
+ var setB = new Set([6, 3]);
400
+ expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(true);
401
+ });
402
+
396
403
  it("fails for sets with different elements", function() {
397
404
  jasmine.getEnv().requireFunctioningSets();
398
405
  var setA = new Set([6, 3, 5]);
@@ -407,13 +414,6 @@ describe("matchersUtil", function() {
407
414
  expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(false);
408
415
  });
409
416
 
410
- it("fails for sets with different insertion order", function() {
411
- jasmine.getEnv().requireFunctioningSets();
412
- var setA = new Set([3, 6]);
413
- var setB = new Set([6, 3]);
414
- expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(false);
415
- });
416
-
417
417
  it("passes when comparing two empty maps", function() {
418
418
  jasmine.getEnv().requireFunctioningMaps();
419
419
  expect(jasmineUnderTest.matchersUtil.equals(new Map(), new Map())).toBe(true);
@@ -427,6 +427,13 @@ describe("matchersUtil", function() {
427
427
  expect(jasmineUnderTest.matchersUtil.equals(mapA, mapB)).toBe(true);
428
428
  });
429
429
 
430
+ it("passes when comparing identical maps with different insertion order", function() {
431
+ jasmine.getEnv().requireFunctioningMaps();
432
+ var mapA = new Map([['a', 3], [6, 1]]);
433
+ var mapB = new Map([[6, 1], ['a', 3]]);
434
+ expect(jasmineUnderTest.matchersUtil.equals(mapA, mapB)).toBe(true);
435
+ });
436
+
430
437
  it("fails for maps with different elements", function() {
431
438
  jasmine.getEnv().requireFunctioningMaps();
432
439
  var mapA = new Map([[6, 3], [5, 1]]);
@@ -441,13 +448,6 @@ describe("matchersUtil", function() {
441
448
  expect(jasmineUnderTest.matchersUtil.equals(mapA, mapB)).toBe(false);
442
449
  });
443
450
 
444
- it("fails for maps with different insertion order", function() {
445
- jasmine.getEnv().requireFunctioningMaps();
446
- var mapA = new Map([['a', 3], [6, 1]]);
447
- var mapB = new Map([[6, 1], ['a', 3]]);
448
- expect(jasmineUnderTest.matchersUtil.equals(mapA, mapB)).toBe(false);
449
- });
450
-
451
451
  describe("when running in an environment with array polyfills", function() {
452
452
  // IE 8 doesn't support `definePropery` on non-DOM nodes
453
453
  if (jasmine.getEnv().ieVersion < 9) { return; }
@@ -0,0 +1,8 @@
1
+ describe('nothing', function() {
2
+ it('should pass', function() {
3
+ var matcher = jasmineUnderTest.matchers.nothing(),
4
+ result = matcher.compare();
5
+
6
+ expect(result.pass).toBe(true);
7
+ });
8
+ });
@@ -161,8 +161,8 @@ describe("toEqual", function() {
161
161
  it("uses the default failure message given arrays with different lengths", function() {
162
162
  var actual = [1, 2],
163
163
  expected = [1, 2, 3],
164
- message =
165
- "Expected [ 1, 2 ] to equal [ 1, 2, 3 ].";
164
+ message = 'Expected $.length = 2 to equal 3.\n' +
165
+ 'Expected $[2] = undefined to equal 3.';
166
166
 
167
167
  expect(compareEquals(actual, expected).message).toEqual(message);
168
168
  });
@@ -211,6 +211,16 @@ describe("toEqual", function() {
211
211
  expect(compareEquals(actual, expected).message).toEqual(message);
212
212
  });
213
213
 
214
+ it("reports mismatches between arrays of different types", function() {
215
+ jasmine.getEnv().requireFunctioningTypedArrays();
216
+
217
+ var actual = new Uint32Array([1, 2, 3]),
218
+ expected = new Uint16Array([1, 2, 3]),
219
+ message = "Expected Uint32Array [ 1, 2, 3 ] to equal Uint16Array [ 1, 2, 3 ].";
220
+
221
+ expect(compareEquals(actual, expected).message).toEqual(message);
222
+ });
223
+
214
224
  it("reports mismatches involving NaN", function() {
215
225
  var actual = {x: 0},
216
226
  expected = {x: 0/0},
@@ -359,8 +369,9 @@ describe("toEqual", function() {
359
369
  expect(compareEquals(actual, expected).message).toEqual(message);
360
370
  });
361
371
 
362
- it("does not report deep mismatches within Sets", function() {
363
- // TODO: implement deep comparison of set elements
372
+ // == Sets ==
373
+
374
+ it("reports mismatches between Sets", function() {
364
375
  jasmine.getEnv().requireFunctioningSets();
365
376
 
366
377
  var actual = new Set([1]),
@@ -370,6 +381,16 @@ describe("toEqual", function() {
370
381
  expect(compareEquals(actual, expected).message).toEqual(message);
371
382
  });
372
383
 
384
+ it("reports deep mismatches within Sets", function() {
385
+ jasmine.getEnv().requireFunctioningSets();
386
+
387
+ var actual = new Set([{x: 1}]),
388
+ expected = new Set([{x: 2}]),
389
+ message = 'Expected Set( Object({ x: 1 }) ) to equal Set( Object({ x: 2 }) ).';
390
+
391
+ expect(compareEquals(actual, expected).message).toEqual(message);
392
+ });
393
+
373
394
  it("reports mismatches between Sets nested in objects", function() {
374
395
  jasmine.getEnv().requireFunctioningSets();
375
396
 
@@ -390,13 +411,46 @@ describe("toEqual", function() {
390
411
  expect(compareEquals(actual, expected).message).toEqual(message);
391
412
  });
392
413
 
393
- it("does not report deep mismatches within Maps", function() {
394
- // TODO: implement deep comparison of Map elements
414
+ it("reports mismatches between Sets where actual is missing a value from expected", function() {
415
+ jasmine.getEnv().requireFunctioningSets();
416
+
417
+ // Use 'duplicate' object in actual so sizes match
418
+ var actual = new Set([{x: 1}, {x: 1}]),
419
+ expected = new Set([{x: 1}, {x: 2}]),
420
+ message = 'Expected Set( Object({ x: 1 }), Object({ x: 1 }) ) to equal Set( Object({ x: 1 }), Object({ x: 2 }) ).';
421
+
422
+ expect(compareEquals(actual, expected).message).toEqual(message);
423
+ });
424
+
425
+ it("reports mismatches between Sets where actual has a value missing from expected", function() {
426
+ jasmine.getEnv().requireFunctioningSets();
427
+
428
+ // Use 'duplicate' object in expected so sizes match
429
+ var actual = new Set([{x: 1}, {x: 2}]),
430
+ expected = new Set([{x: 1}, {x: 1}]),
431
+ message = 'Expected Set( Object({ x: 1 }), Object({ x: 2 }) ) to equal Set( Object({ x: 1 }), Object({ x: 1 }) ).';
432
+
433
+ expect(compareEquals(actual, expected).message).toEqual(message);
434
+ });
435
+
436
+ // == Maps ==
437
+
438
+ it("does not report mismatches between deep equal Maps", function() {
439
+ jasmine.getEnv().requireFunctioningSets();
440
+
441
+ // values are the same but with different object identity
442
+ var actual = new Map([['a', {x: 1}]]),
443
+ expected = new Map([['a', {x: 1}]]);
444
+
445
+ expect(compareEquals(actual, expected).pass).toBe(true);
446
+ });
447
+
448
+ it("reports deep mismatches within Maps", function() {
395
449
  jasmine.getEnv().requireFunctioningMaps();
396
450
 
397
- var actual = new Map([['a', 1]]),
398
- expected = new Map([['a', 2]]),
399
- message = "Expected Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ] ).";
451
+ var actual = new Map([['a', {x: 1}]]),
452
+ expected = new Map([['a', {x: 2}]]),
453
+ message = "Expected Map( [ 'a', Object({ x: 1 }) ] ) to equal Map( [ 'a', Object({ x: 2 }) ] ).";
400
454
 
401
455
  expect(compareEquals(actual, expected).message).toEqual(message);
402
456
  });
@@ -405,8 +459,8 @@ describe("toEqual", function() {
405
459
  jasmine.getEnv().requireFunctioningMaps();
406
460
 
407
461
  var actual = {Maps: [new Map([['a', 1]])]},
408
- expected = {Maps: [new Map([['a', 2], ['b', 1]])]},
409
- message = "Expected $.Maps[0] = Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ], [ 'b', 1 ] ).";
462
+ expected = {Maps: [new Map([['a', 2]])]},
463
+ message = "Expected $.Maps[0] = Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ] ).";
410
464
 
411
465
  expect(compareEquals(actual, expected).message).toEqual(message);
412
466
  });
@@ -415,11 +469,40 @@ describe("toEqual", function() {
415
469
  jasmine.getEnv().requireFunctioningMaps();
416
470
 
417
471
  var actual = new Map([['a', 1]]),
418
- expected = new Map([['a', 2]]),
419
- message = "Expected Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ] ).";
472
+ expected = new Map([['a', 2], ['b', 1]]),
473
+ message = "Expected Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ], [ 'b', 1 ] ).";
474
+
475
+ expect(compareEquals(actual, expected).message).toEqual(message);
476
+ });
477
+
478
+ it("reports mismatches between Maps with equal values but differing keys", function() {
479
+ jasmine.getEnv().requireFunctioningMaps();
480
+
481
+ var actual = new Map([['a', 1]]),
482
+ expected = new Map([['b', 1]]),
483
+ message = "Expected Map( [ 'a', 1 ] ) to equal Map( [ 'b', 1 ] ).";
420
484
 
421
485
  expect(compareEquals(actual, expected).message).toEqual(message);
422
- });
486
+ });
487
+
488
+ it("does not report mismatches between Maps with keys with same object identity", function() {
489
+ jasmine.getEnv().requireFunctioningMaps();
490
+ var key = {x: 1},
491
+ actual = new Map([[key, 2]]),
492
+ expected = new Map([[key, 2]]);
493
+
494
+ expect(compareEquals(actual, expected).pass).toBe(true);
495
+ });
496
+
497
+ it("reports mismatches between Maps with identical keys with different object identity", function() {
498
+ jasmine.getEnv().requireFunctioningMaps();
499
+
500
+ var actual = new Map([[{x: 1}, 2]]),
501
+ expected = new Map([[{x: 1}, 2]]),
502
+ message = "Expected Map( [ Object({ x: 1 }), 2 ] ) to equal Map( [ Object({ x: 1 }), 2 ] ).";
503
+
504
+ expect(compareEquals(actual, expected).message).toEqual(message);
505
+ });
423
506
 
424
507
  function isNotRunningInBrowser() {
425
508
  return typeof document === 'undefined'
@@ -487,9 +570,9 @@ describe("toEqual", function() {
487
570
 
488
571
  it("does not report a mismatch when asymmetric matchers are satisfied", function() {
489
572
  var actual = {a: 'a'},
490
- expected = {a: jasmineUnderTest.any(String)},
491
- message = 'Expected $.a = 1 to equal <jasmine.any(String)>.';
573
+ expected = {a: jasmineUnderTest.any(String)};
492
574
 
575
+ expect(compareEquals(actual, expected).message).toEqual('');
493
576
  expect(compareEquals(actual, expected).pass).toBe(true)
494
577
  });
495
578
 
@@ -530,7 +613,8 @@ describe("toEqual", function() {
530
613
 
531
614
  var message =
532
615
  'Expected $.foo[0].bar = 1 to equal 2.\n' +
533
- "Expected $.foo[0].things = [ 'a', 'b' ] to equal [ 'a', 'b', 'c' ].\n" +
616
+ 'Expected $.foo[0].things.length = 2 to equal 3.\n' +
617
+ "Expected $.foo[0].things[2] = undefined to equal 'c'.\n" +
534
618
  "Expected $.foo[1].things[1] = 'b' to equal 'd'.\n" +
535
619
  'Expected $.baz[0].a to have properties\n' +
536
620
  ' c: 1\n' +
@@ -544,4 +628,92 @@ describe("toEqual", function() {
544
628
 
545
629
  expect(compareEquals(actual, expected).message).toEqual(message);
546
630
  })
631
+
632
+ describe("different length arrays", function() {
633
+ it("actual array is longer", function() {
634
+ var actual = [1, 1, 2, 3, 5],
635
+ expected = [1, 1, 2, 3],
636
+ message = 'Expected $.length = 5 to equal 4.\n' +
637
+ 'Expected $[4] = 5 to equal undefined.';
638
+
639
+ expect(compareEquals(actual, expected).pass).toBe(false)
640
+ expect(compareEquals(actual, expected).message).toEqual(message);
641
+ });
642
+
643
+ it("expected array is longer", function() {
644
+ var actual = [1, 1, 2, 3],
645
+ expected = [1, 1, 2, 3, 5],
646
+ message = 'Expected $.length = 4 to equal 5.\n' +
647
+ 'Expected $[4] = undefined to equal 5.';
648
+
649
+ expect(compareEquals(actual, expected).pass).toBe(false)
650
+ expect(compareEquals(actual, expected).message).toEqual(message);
651
+ });
652
+
653
+ it("expected array is longer by 4 elements", function() {
654
+ var actual = [1, 1, 2],
655
+ expected = [1, 1, 2, 3, 5, 8, 13],
656
+ message = 'Expected $.length = 3 to equal 7.\n' +
657
+ 'Expected $[3] = undefined to equal 3.\n' +
658
+ 'Expected $[4] = undefined to equal 5.\n' +
659
+ 'Expected $[5] = undefined to equal 8.\n' +
660
+ 'Expected $[6] = undefined to equal 13.';
661
+
662
+ expect(compareEquals(actual, expected).pass).toBe(false)
663
+ expect(compareEquals(actual, expected).message).toEqual(message);
664
+ });
665
+
666
+ it("different length and different elements", function() {
667
+ var actual = [1],
668
+ expected = [2, 3],
669
+ message = 'Expected $.length = 1 to equal 2.\n' +
670
+ 'Expected $[0] = 1 to equal 2.\n' +
671
+ 'Expected $[1] = undefined to equal 3.';
672
+
673
+ expect(compareEquals(actual, expected).pass).toBe(false)
674
+ expect(compareEquals(actual, expected).message).toEqual(message);
675
+ });
676
+
677
+ it("object with nested array", function() {
678
+ var actual = { values: [1, 1, 2, 3] },
679
+ expected = { values: [1, 1, 2] },
680
+ message = 'Expected $.values.length = 4 to equal 3.\n' +
681
+ 'Expected $.values[3] = 3 to equal undefined.';
682
+
683
+ expect(compareEquals(actual, expected).pass).toBe(false)
684
+ expect(compareEquals(actual, expected).message).toEqual(message);
685
+ });
686
+
687
+ it("array with nested object", function() {
688
+ var actual = [1, 1, 2, { value: 3 }],
689
+ expected = [1, 1, 2],
690
+ message = 'Expected $.length = 4 to equal 3.\n' +
691
+ 'Expected $[3] = Object({ value: 3 }) to equal undefined.';
692
+
693
+ expect(compareEquals(actual, expected).pass).toBe(false)
694
+ expect(compareEquals(actual, expected).message).toEqual(message);
695
+ });
696
+
697
+ it("array with nested different length array", function() {
698
+ var actual = [[1], [1, 2]],
699
+ expected = [[1, 1], [2]],
700
+ message = 'Expected $[0].length = 1 to equal 2.\n' +
701
+ 'Expected $[0][1] = undefined to equal 1.\n' +
702
+ 'Expected $[1].length = 2 to equal 1.\n' +
703
+ 'Expected $[1][0] = 1 to equal 2.\n' +
704
+ 'Expected $[1][1] = 2 to equal undefined.';
705
+
706
+ expect(compareEquals(actual, expected).pass).toBe(false)
707
+ expect(compareEquals(actual, expected).message).toEqual(message);
708
+ });
709
+
710
+ it("last element of longer array is undefined", function() {
711
+ var actual = [1, 2],
712
+ expected = [1, 2, void 0],
713
+ message = 'Expected $.length = 2 to equal 3.';
714
+
715
+ expect(compareEquals(actual, expected).pass).toBe(false)
716
+ expect(compareEquals(actual, expected).message).toEqual(message);
717
+ });
718
+ })
547
719
  });
@@ -0,0 +1,20 @@
1
+ (function(env) {
2
+ function hasFunctioningTypedArrays() {
3
+ if (typeof Uint32Array === 'undefined') { return false; }
4
+
5
+ try {
6
+ var a = new Uint32Array([1, 2, 3]);
7
+ if (a.length !== 3) { return false; }
8
+ return true;
9
+ } catch(e) {
10
+ return false;
11
+ }
12
+ }
13
+
14
+ env.requireFunctioningTypedArrays = function() {
15
+ if (!hasFunctioningTypedArrays()) {
16
+ env.pending("Browser has incomplete or missing support for typed arrays");
17
+ }
18
+ };
19
+
20
+ })(jasmine.getEnv());
@@ -4,6 +4,6 @@
4
4
  #
5
5
  module Jasmine
6
6
  module Core
7
- VERSION = "2.7.0"
7
+ VERSION = "2.8.0"
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jasmine-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Van Hove
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-28 00:00:00.000000000 Z
11
+ date: 2017-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -122,6 +122,7 @@ files:
122
122
  - "./lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js"
123
123
  - "./lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js"
124
124
  - "./lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js"
125
+ - "./lib/jasmine-core/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js"
125
126
  - "./lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js"
126
127
  - "./lib/jasmine-core/spec/core/asymmetric_equality/StringMatchingSpec.js"
127
128
  - "./lib/jasmine-core/spec/core/formatErrorMsgSpec.js"
@@ -132,6 +133,7 @@ files:
132
133
  - "./lib/jasmine-core/spec/core/matchers/NullDiffBuilderSpec.js"
133
134
  - "./lib/jasmine-core/spec/core/matchers/ObjectPathSpec.js"
134
135
  - "./lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js"
136
+ - "./lib/jasmine-core/spec/core/matchers/nothingSpec.js"
135
137
  - "./lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js"
136
138
  - "./lib/jasmine-core/spec/core/matchers/toBeDefinedSpec.js"
137
139
  - "./lib/jasmine-core/spec/core/matchers/toBeFalsySpec.js"
@@ -159,6 +161,7 @@ files:
159
161
  - "./lib/jasmine-core/spec/helpers/asyncAwait.js"
160
162
  - "./lib/jasmine-core/spec/helpers/checkForMap.js"
161
163
  - "./lib/jasmine-core/spec/helpers/checkForSet.js"
164
+ - "./lib/jasmine-core/spec/helpers/checkForTypedArrays.js"
162
165
  - "./lib/jasmine-core/spec/helpers/defineJasmineUnderTest.js"
163
166
  - "./lib/jasmine-core/spec/helpers/nodeDefineJasmineUnderTest.js"
164
167
  - "./lib/jasmine-core/spec/html/HtmlReporterSpec.js"