jasmine-core 2.9.0 → 2.99.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jasmine-core/jasmine-html.js +24 -1
  3. data/lib/jasmine-core/jasmine.css +1 -0
  4. data/lib/jasmine-core/jasmine.js +50 -6
  5. data/lib/jasmine-core/version.rb +1 -1
  6. metadata +3 -84
  7. data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +0 -270
  8. data/lib/jasmine-core/spec/core/CallTrackerSpec.js +0 -130
  9. data/lib/jasmine-core/spec/core/ClearStackSpec.js +0 -137
  10. data/lib/jasmine-core/spec/core/ClockSpec.js +0 -754
  11. data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +0 -270
  12. data/lib/jasmine-core/spec/core/EnvSpec.js +0 -200
  13. data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +0 -63
  14. data/lib/jasmine-core/spec/core/ExceptionsSpec.js +0 -68
  15. data/lib/jasmine-core/spec/core/ExpectationResultSpec.js +0 -61
  16. data/lib/jasmine-core/spec/core/ExpectationSpec.js +0 -434
  17. data/lib/jasmine-core/spec/core/GlobalErrorsSpec.js +0 -110
  18. data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +0 -259
  19. data/lib/jasmine-core/spec/core/MockDateSpec.js +0 -200
  20. data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +0 -337
  21. data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +0 -620
  22. data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +0 -79
  23. data/lib/jasmine-core/spec/core/SpecSpec.js +0 -441
  24. data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +0 -356
  25. data/lib/jasmine-core/spec/core/SpySpec.js +0 -127
  26. data/lib/jasmine-core/spec/core/SpyStrategySpec.js +0 -159
  27. data/lib/jasmine-core/spec/core/SuiteSpec.js +0 -155
  28. data/lib/jasmine-core/spec/core/TimerSpec.js +0 -31
  29. data/lib/jasmine-core/spec/core/TreeProcessorSpec.js +0 -756
  30. data/lib/jasmine-core/spec/core/UserContextSpec.js +0 -54
  31. data/lib/jasmine-core/spec/core/UtilSpec.js +0 -99
  32. data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +0 -84
  33. data/lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js +0 -76
  34. data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js +0 -52
  35. data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js +0 -47
  36. data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +0 -102
  37. data/lib/jasmine-core/spec/core/asymmetric_equality/StringMatchingSpec.js +0 -27
  38. data/lib/jasmine-core/spec/core/formatErrorMsgSpec.js +0 -13
  39. data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +0 -199
  40. data/lib/jasmine-core/spec/core/integration/EnvSpec.js +0 -2007
  41. data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +0 -950
  42. data/lib/jasmine-core/spec/core/matchers/DiffBuilderSpec.js +0 -47
  43. data/lib/jasmine-core/spec/core/matchers/NullDiffBuilderSpec.js +0 -13
  44. data/lib/jasmine-core/spec/core/matchers/ObjectPathSpec.js +0 -43
  45. data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +0 -658
  46. data/lib/jasmine-core/spec/core/matchers/nothingSpec.js +0 -8
  47. data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +0 -93
  48. data/lib/jasmine-core/spec/core/matchers/toBeDefinedSpec.js +0 -18
  49. data/lib/jasmine-core/spec/core/matchers/toBeFalsySpec.js +0 -38
  50. data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanOrEqualSpec.js +0 -29
  51. data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +0 -20
  52. data/lib/jasmine-core/spec/core/matchers/toBeLessThanOrEqualSpec.js +0 -29
  53. data/lib/jasmine-core/spec/core/matchers/toBeLessThanSpec.js +0 -20
  54. data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +0 -37
  55. data/lib/jasmine-core/spec/core/matchers/toBeNegativeInfinitySpec.js +0 -31
  56. data/lib/jasmine-core/spec/core/matchers/toBeNullSpec.js +0 -17
  57. data/lib/jasmine-core/spec/core/matchers/toBePositiveInfinitySpec.js +0 -31
  58. data/lib/jasmine-core/spec/core/matchers/toBeSpec.js +0 -17
  59. data/lib/jasmine-core/spec/core/matchers/toBeTruthySpec.js +0 -38
  60. data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +0 -18
  61. data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +0 -26
  62. data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +0 -804
  63. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledBeforeSpec.js +0 -99
  64. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +0 -47
  65. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledTimesSpec.js +0 -86
  66. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +0 -67
  67. data/lib/jasmine-core/spec/core/matchers/toMatchSpec.js +0 -43
  68. data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +0 -315
  69. data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +0 -100
  70. data/lib/jasmine-core/spec/helpers/BrowserFlags.js +0 -27
  71. data/lib/jasmine-core/spec/helpers/asyncAwait.js +0 -27
  72. data/lib/jasmine-core/spec/helpers/checkForMap.js +0 -37
  73. data/lib/jasmine-core/spec/helpers/checkForSet.js +0 -41
  74. data/lib/jasmine-core/spec/helpers/checkForSymbol.js +0 -28
  75. data/lib/jasmine-core/spec/helpers/checkForTypedArrays.js +0 -20
  76. data/lib/jasmine-core/spec/helpers/defineJasmineUnderTest.js +0 -7
  77. data/lib/jasmine-core/spec/helpers/nodeDefineJasmineUnderTest.js +0 -33
  78. data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +0 -982
  79. data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +0 -18
  80. data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +0 -37
  81. data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +0 -15
  82. data/lib/jasmine-core/spec/html/QueryStringSpec.js +0 -72
  83. data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +0 -62
  84. data/lib/jasmine-core/spec/html/SpyRegistryHtmlSpec.js +0 -34
  85. data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +0 -101
  86. data/lib/jasmine-core/spec/performance/large_object_test.js +0 -36
  87. data/lib/jasmine-core/spec/performance/performance_test.js +0 -10
@@ -1,804 +0,0 @@
1
- describe("toEqual", function() {
2
- "use strict";
3
-
4
- function compareEquals(actual, expected) {
5
- var util = jasmineUnderTest.matchersUtil,
6
- matcher = jasmineUnderTest.matchers.toEqual(util);
7
-
8
- var result = matcher.compare(actual, expected);
9
-
10
- return result;
11
- }
12
-
13
- it("delegates to equals function", function() {
14
- var util = {
15
- equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
16
- buildFailureMessage: function() {
17
- return 'does not matter'
18
- },
19
- DiffBuilder: jasmineUnderTest.matchersUtil.DiffBuilder
20
- },
21
- matcher = jasmineUnderTest.matchers.toEqual(util),
22
- result;
23
-
24
- result = matcher.compare(1, 1);
25
-
26
- expect(util.equals).toHaveBeenCalledWith(1, 1, [], jasmine.anything());
27
- expect(result.pass).toBe(true);
28
- });
29
-
30
- it("delegates custom equality testers, if present", function() {
31
- var util = {
32
- equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
33
- buildFailureMessage: function() {
34
- return 'does not matter'
35
- },
36
- DiffBuilder: jasmineUnderTest.matchersUtil.DiffBuilder
37
- },
38
- customEqualityTesters = ['a', 'b'],
39
- matcher = jasmineUnderTest.matchers.toEqual(util, customEqualityTesters),
40
- result;
41
-
42
- result = matcher.compare(1, 1);
43
-
44
- expect(util.equals).toHaveBeenCalledWith(1, 1, ['a', 'b'], jasmine.anything());
45
- expect(result.pass).toBe(true);
46
- });
47
-
48
- it("reports the difference between objects that are not equal", function() {
49
- var actual = {x: 1, y: 3},
50
- expected = {x: 2, y: 3},
51
- message = "Expected $.x = 1 to equal 2.";
52
-
53
- expect(compareEquals(actual, expected).message).toEqual(message);
54
- });
55
-
56
- it("reports the difference between nested objects that are not equal", function() {
57
- var actual = {x: {y: 1}},
58
- expected = {x: {y: 2}},
59
- message = "Expected $.x.y = 1 to equal 2.";
60
-
61
- expect(compareEquals(actual, expected).message).toEqual(message);
62
- });
63
-
64
- it("formats property access so that it's valid JavaScript", function() {
65
- var actual = {'my prop': 1},
66
- expected = {'my prop': 2},
67
- message = "Expected $['my prop'] = 1 to equal 2.";
68
-
69
- expect(compareEquals(actual, expected).message).toEqual(message);
70
- });
71
-
72
- it("reports missing properties", function() {
73
- var actual = {x: {}},
74
- expected = {x: {y: 1}},
75
- message =
76
- "Expected $.x to have properties\n" +
77
- " y: 1";
78
-
79
- expect(compareEquals(actual, expected).message).toEqual(message);
80
- });
81
-
82
- it("reports extra properties", function() {
83
- var actual = {x: {y: 1, z: 2}},
84
- expected = {x: {}},
85
- message =
86
- "Expected $.x not to have properties\n" +
87
- " y: 1\n" +
88
- " z: 2";
89
-
90
- expect(compareEquals(actual, expected).message).toEqual(message);
91
- });
92
-
93
- it("pretty-prints properties", function() {
94
- var actual = {x: {y: 'foo bar'}},
95
- expected = {x: {}},
96
- message =
97
- "Expected $.x not to have properties\n" +
98
- " y: 'foo bar'"
99
-
100
- expect(compareEquals(actual, expected).message).toEqual(message);
101
- });
102
-
103
- it("reports extra and missing properties together", function() {
104
- var actual = {x: {y: 1, z: 2, f: 4}},
105
- expected = {x: {y: 1, z: 2, g: 3}},
106
- message =
107
- "Expected $.x to have properties\n" +
108
- " g: 3\n" +
109
- "Expected $.x not to have properties\n" +
110
- " f: 4";
111
-
112
- expect(compareEquals(actual, expected).message).toEqual(message);
113
- });
114
-
115
- it("reports extra and missing properties of the root-level object", function() {
116
- var actual = {x: 1},
117
- expected = {a: 1},
118
- message =
119
- "Expected object to have properties\n" +
120
- " a: 1\n" +
121
- "Expected object not to have properties\n" +
122
- " x: 1";
123
-
124
- expect(compareEquals(actual, expected).message).toEqual(message);
125
- });
126
-
127
- it("reports multiple incorrect values", function() {
128
- var actual = {x: 1, y: 2},
129
- expected = {x: 3, y: 4},
130
- message =
131
- "Expected $.x = 1 to equal 3.\n" +
132
- "Expected $.y = 2 to equal 4.";
133
-
134
- expect(compareEquals(actual, expected).message).toEqual(message);
135
- });
136
-
137
- it("reports mismatch between actual child object and expected child number", function() {
138
- var actual = {x: {y: 2}},
139
- expected = {x: 1},
140
- message = "Expected $.x = Object({ y: 2 }) to equal 1.";
141
-
142
- expect(compareEquals(actual, expected).message).toEqual(message);
143
- });
144
-
145
- it("uses the default failure message if actual is not an object", function() {
146
- var actual = 1,
147
- expected = {x: {}},
148
- message = "Expected 1 to equal Object({ x: Object({ }) }).";
149
-
150
- expect(compareEquals(actual, expected).message).toEqual(message);
151
- });
152
-
153
- it("uses the default failure message if expected is not an object", function() {
154
- var actual = {x: {}},
155
- expected = 1,
156
- message = "Expected Object({ x: Object({ }) }) to equal 1.";
157
-
158
- expect(compareEquals(actual, expected).message).toEqual(message);
159
- });
160
-
161
- it("uses the default failure message given arrays with different lengths", function() {
162
- var actual = [1, 2],
163
- expected = [1, 2, 3],
164
- message = 'Expected $.length = 2 to equal 3.\n' +
165
- 'Expected $[2] = undefined to equal 3.';
166
-
167
- expect(compareEquals(actual, expected).message).toEqual(message);
168
- });
169
-
170
- it("reports a mismatch between elements of equal-length arrays", function() {
171
- var actual = [1, 2, 5],
172
- expected = [1, 2, 3],
173
- message = "Expected $[2] = 5 to equal 3.";
174
-
175
- expect(compareEquals(actual, expected).message).toEqual(message);
176
- });
177
-
178
- it("reports a mismatch between multiple array elements", function() {
179
- var actual = [2, 2, 5],
180
- expected = [1, 2, 3],
181
- message =
182
- "Expected $[0] = 2 to equal 1.\n" +
183
- "Expected $[2] = 5 to equal 3.";
184
-
185
- expect(compareEquals(actual, expected).message).toEqual(message);
186
- });
187
-
188
- it("reports a mismatch between properties of objects in arrays", function() {
189
- var actual = [{x: 1}],
190
- expected = [{x: 2}],
191
- message = "Expected $[0].x = 1 to equal 2.";
192
-
193
- expect(compareEquals(actual, expected).message).toEqual(message);
194
- });
195
-
196
- it("reports a mismatch between arrays in objects", function() {
197
- var actual = {x: [1]},
198
- expected = {x: [2]},
199
- message =
200
- "Expected $.x[0] = 1 to equal 2.";
201
-
202
- expect(compareEquals(actual, expected).message).toEqual(message);
203
- });
204
-
205
- it("reports mismatches between nested arrays", function() {
206
- var actual = [[1]],
207
- expected = [[2]],
208
- message =
209
- "Expected $[0][0] = 1 to equal 2.";
210
-
211
- expect(compareEquals(actual, expected).message).toEqual(message);
212
- });
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
-
224
- it("reports mismatches involving NaN", function() {
225
- var actual = {x: 0},
226
- expected = {x: 0/0},
227
- message = "Expected $.x = 0 to equal NaN.";
228
-
229
- expect(compareEquals(actual, expected).message).toEqual(message);
230
- });
231
-
232
- it("reports mismatches involving regular expressions", function() {
233
- var actual = {x: '1'},
234
- expected = {x: /1/},
235
- message = "Expected $.x = '1' to equal /1/.";
236
-
237
- expect(compareEquals(actual, expected).message).toEqual(message);
238
- });
239
-
240
- it("reports mismatches involving infinities", function() {
241
- var actual = {x: 0},
242
- expected = {x: 1/0},
243
- message = "Expected $.x = 0 to equal Infinity.";
244
-
245
- expect(compareEquals(actual, expected).message).toEqual(message);
246
- });
247
-
248
- it("reports mismatches involving booleans", function() {
249
- var actual = {x: false},
250
- expected = {x: true},
251
- message = "Expected $.x = false to equal true.";
252
-
253
- expect(compareEquals(actual, expected).message).toEqual(message);
254
- });
255
-
256
- it("reports mismatches involving strings", function() {
257
- var actual = {x: 'foo'},
258
- expected = {x: 'bar'},
259
- message = "Expected $.x = 'foo' to equal 'bar'.";
260
-
261
- expect(compareEquals(actual, expected).message).toEqual(message);
262
- });
263
-
264
- it("reports mismatches involving undefined", function() {
265
- var actual = {x: void 0},
266
- expected = {x: 0},
267
- message = "Expected $.x = undefined to equal 0.";
268
-
269
- expect(compareEquals(actual, expected).message).toEqual(message);
270
- });
271
-
272
- it("reports mismatches involving null", function() {
273
- var actual = {x: null},
274
- expected = {x: 0},
275
- message = "Expected $.x = null to equal 0.";
276
-
277
- expect(compareEquals(actual, expected).message).toEqual(message);
278
- });
279
-
280
- it("reports mismatches between objects with different constructors", function () {
281
- function Foo() {}
282
- function Bar() {}
283
-
284
- var actual = {x: new Foo()},
285
- expected = {x: new Bar()},
286
- message = "Expected $.x to be a kind of Bar, but was Foo({ }).";
287
-
288
- expect(compareEquals(actual, expected).message).toEqual(message);
289
- });
290
-
291
- it("reports type mismatches at the root level", function () {
292
- function Foo() {}
293
- function Bar() {}
294
-
295
- var actual = new Foo(),
296
- expected = new Bar(),
297
- message = "Expected object to be a kind of Bar, but was Foo({ }).";
298
-
299
- expect(compareEquals(actual, expected).message).toEqual(message);
300
- });
301
-
302
- function constructorIsNotEnumerable() {
303
- // in IE8, the constructor property is not enumerable, even if it is an
304
- // own property of the object.
305
- // Objects that differ only by an own `constructor` property are thus
306
- // considered equal in IE8.
307
- for (var key in {constructor: 1}) {
308
- return false;
309
- }
310
- return true;
311
- }
312
-
313
- it("reports mismatches between objects with their own constructor property", function () {
314
- if (constructorIsNotEnumerable()) {
315
- return;
316
- }
317
-
318
- function Foo() {}
319
- function Bar() {}
320
-
321
- var actual = {x: {constructor: 'blerf'}},
322
- expected = {x: {constructor: 'ftarrh'}},
323
- message = "Expected $.x.constructor = 'blerf' to equal 'ftarrh'.";
324
-
325
- expect(compareEquals(actual, expected).message).toEqual(message);
326
- });
327
-
328
- it("reports mismatches between an object with a real constructor and one with its own constructor property", function () {
329
- if (constructorIsNotEnumerable()) {
330
- return;
331
- }
332
-
333
- function Foo() {}
334
- function Bar() {}
335
-
336
- var actual = {x: {}},
337
- expected = {x: {constructor: 'ftarrh'}},
338
- message =
339
- "Expected $.x to have properties\n" +
340
- " constructor: 'ftarrh'";
341
-
342
- expect(compareEquals(actual, expected).message).toEqual(message);
343
- expect(compareEquals(expected, actual).message).toEqual(
344
- "Expected $.x not to have properties\n constructor: 'ftarrh'"
345
- );
346
- });
347
-
348
- it("reports mismatches between 0 and -0", function() {
349
- var actual = {x: 0},
350
- expected = {x: -0},
351
- message = "Expected $.x = 0 to equal -0.";
352
-
353
- expect(compareEquals(actual, expected).message).toEqual(message);
354
- });
355
-
356
- it("reports mismatches between Errors", function() {
357
- var actual = {x: new Error("the error you got")},
358
- expected = {x: new Error("the error you want")},
359
- message = "Expected $.x = Error: the error you got to equal Error: the error you want.";
360
-
361
- expect(compareEquals(actual, expected).message).toEqual(message);
362
- });
363
-
364
- it("reports mismatches between Functions", function() {
365
- var actual = {x: function() {}},
366
- expected = {x: function() {}},
367
- message = "Expected $.x = Function to equal Function.";
368
-
369
- expect(compareEquals(actual, expected).message).toEqual(message);
370
- });
371
-
372
- // == Sets ==
373
-
374
- it("reports mismatches between Sets", function() {
375
- jasmine.getEnv().requireFunctioningSets();
376
-
377
- var actual = new Set();
378
- actual.add(1);
379
- var expected = new Set();
380
- expected.add(2);
381
- var message = 'Expected Set( 1 ) to equal Set( 2 ).';
382
-
383
- expect(compareEquals(actual, expected).message).toEqual(message);
384
- });
385
-
386
- it("reports deep mismatches within Sets", function() {
387
- jasmine.getEnv().requireFunctioningSets();
388
-
389
- var actual = new Set();
390
- actual.add({x: 1});
391
- var expected = new Set();
392
- expected.add({x: 2});
393
- var message = 'Expected Set( Object({ x: 1 }) ) to equal Set( Object({ x: 2 }) ).';
394
-
395
- expect(compareEquals(actual, expected).message).toEqual(message);
396
- });
397
-
398
- it("reports mismatches between Sets nested in objects", function() {
399
- jasmine.getEnv().requireFunctioningSets();
400
-
401
- var actualSet = new Set();
402
- actualSet.add(1);
403
- var expectedSet = new Set();
404
- expectedSet.add(2);
405
-
406
- var actual = { sets: [actualSet] };
407
- var expected = { sets: [expectedSet] };
408
- var message = "Expected $.sets[0] = Set( 1 ) to equal Set( 2 ).";
409
-
410
- expect(compareEquals(actual, expected).message).toEqual(message);
411
- });
412
-
413
- it("reports mismatches between Sets of different lengths", function() {
414
- jasmine.getEnv().requireFunctioningSets();
415
-
416
- var actual = new Set();
417
- actual.add(1);
418
- actual.add(2);
419
- var expected = new Set();
420
- expected.add(2);
421
- var message = 'Expected Set( 1, 2 ) to equal Set( 2 ).';
422
-
423
- expect(compareEquals(actual, expected).message).toEqual(message);
424
- });
425
-
426
- it("reports mismatches between Sets where actual is missing a value from expected", function() {
427
- jasmine.getEnv().requireFunctioningSets();
428
-
429
- // Use 'duplicate' object in actual so sizes match
430
- var actual = new Set();
431
- actual.add({x: 1});
432
- actual.add({x: 1});
433
- var expected = new Set();
434
- expected.add({x: 1});
435
- expected.add({x: 2});
436
- var message = 'Expected Set( Object({ x: 1 }), Object({ x: 1 }) ) to equal Set( Object({ x: 1 }), Object({ x: 2 }) ).';
437
-
438
- expect(compareEquals(actual, expected).message).toEqual(message);
439
- });
440
-
441
- it("reports mismatches between Sets where actual has a value missing from expected", function() {
442
- jasmine.getEnv().requireFunctioningSets();
443
-
444
- // Use 'duplicate' object in expected so sizes match
445
- var actual = new Set();
446
- actual.add({x: 1});
447
- actual.add({x: 2});
448
- var expected = new Set();
449
- expected.add({x: 1});
450
- expected.add({x: 1});
451
- var message = 'Expected Set( Object({ x: 1 }), Object({ x: 2 }) ) to equal Set( Object({ x: 1 }), Object({ x: 1 }) ).';
452
-
453
- expect(compareEquals(actual, expected).message).toEqual(message);
454
- });
455
-
456
- // == Maps ==
457
-
458
- it("does not report mismatches between deep equal Maps", function() {
459
- jasmine.getEnv().requireFunctioningMaps();
460
-
461
- // values are the same but with different object identity
462
- var actual = new Map();
463
- actual.set('a',{x:1});
464
- var expected = new Map();
465
- expected.set('a',{x:1});
466
-
467
- expect(compareEquals(actual, expected).pass).toBe(true);
468
- });
469
-
470
- it("reports deep mismatches within Maps", function() {
471
- jasmine.getEnv().requireFunctioningMaps();
472
-
473
- var actual = new Map();
474
- actual.set('a',{x:1});
475
- var expected = new Map();
476
- expected.set('a',{x:2});
477
- var message = "Expected Map( [ 'a', Object({ x: 1 }) ] ) to equal Map( [ 'a', Object({ x: 2 }) ] ).";
478
-
479
- expect(compareEquals(actual, expected).message).toEqual(message);
480
- });
481
-
482
- it("reports mismatches between Maps nested in objects", function() {
483
- jasmine.getEnv().requireFunctioningMaps();
484
-
485
- var actual = {Maps:[new Map()]};
486
- actual.Maps[0].set('a',1);
487
- var expected = {Maps:[new Map()]};
488
- expected.Maps[0].set('a',2);
489
-
490
- var message = "Expected $.Maps[0] = Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ] ).";
491
-
492
- expect(compareEquals(actual, expected).message).toEqual(message);
493
- });
494
-
495
- it("reports mismatches between Maps of different lengths", function() {
496
- jasmine.getEnv().requireFunctioningMaps();
497
-
498
- var actual = new Map();
499
- actual.set('a',1);
500
- var expected = new Map();
501
- expected.set('a',2);
502
- expected.set('b',1);
503
- var message = "Expected Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ], [ 'b', 1 ] ).";
504
-
505
- expect(compareEquals(actual, expected).message).toEqual(message);
506
- });
507
-
508
- it("reports mismatches between Maps with equal values but differing keys", function() {
509
- jasmine.getEnv().requireFunctioningMaps();
510
-
511
- var actual = new Map();
512
- actual.set('a',1);
513
- var expected = new Map();
514
- expected.set('b',1);
515
- var message = "Expected Map( [ 'a', 1 ] ) to equal Map( [ 'b', 1 ] ).";
516
-
517
- expect(compareEquals(actual, expected).message).toEqual(message);
518
- });
519
-
520
- it("does not report mismatches between Maps with keys with same object identity", function() {
521
- jasmine.getEnv().requireFunctioningMaps();
522
- var key = {x: 1};
523
- var actual = new Map();
524
- actual.set(key,2);
525
- var expected = new Map();
526
- expected.set(key,2);
527
-
528
- expect(compareEquals(actual, expected).pass).toBe(true);
529
- });
530
-
531
- it("reports mismatches between Maps with identical keys with different object identity", function() {
532
- jasmine.getEnv().requireFunctioningMaps();
533
-
534
- var actual = new Map();
535
- actual.set({x:1},2);
536
- var expected = new Map();
537
- expected.set({x:1},2);
538
- var message = "Expected Map( [ Object({ x: 1 }), 2 ] ) to equal Map( [ Object({ x: 1 }), 2 ] ).";
539
-
540
- expect(compareEquals(actual, expected).message).toEqual(message);
541
- });
542
-
543
- it("does not report mismatches when comparing Map key to jasmine.anything()", function() {
544
- jasmine.getEnv().requireFunctioningMaps();
545
-
546
- var actual = new Map();
547
- actual.set('a',1);
548
- var expected = new Map();
549
- expected.set(jasmineUnderTest.anything(),1);
550
-
551
- expect(compareEquals(actual, expected).pass).toBe(true);
552
- });
553
-
554
- it("does not report mismatches when comparing Maps with the same symbol keys", function() {
555
- jasmine.getEnv().requireFunctioningMaps();
556
- jasmine.getEnv().requireFunctioningSymbols();
557
-
558
- var key = Symbol();
559
- var actual = new Map();
560
- actual.set(key,1);
561
- var expected = new Map();
562
- expected.set(key,1);
563
-
564
- expect(compareEquals(actual, expected).pass).toBe(true);
565
- });
566
-
567
- it("reports mismatches between Maps with different symbol keys", function() {
568
- jasmine.getEnv().requireFunctioningMaps();
569
- jasmine.getEnv().requireFunctioningSymbols();
570
-
571
- var actual = new Map();
572
- actual.set(Symbol(),1);
573
- var expected = new Map();
574
- expected.set(Symbol(),1);
575
- var message = "Expected Map( [ Symbol(), 1 ] ) to equal Map( [ Symbol(), 1 ] ).";
576
-
577
- expect(compareEquals(actual, expected).message).toBe(message);
578
- });
579
-
580
- it("does not report mismatches when comparing Map symbol key to jasmine.anything()", function() {
581
- jasmine.getEnv().requireFunctioningMaps();
582
- jasmine.getEnv().requireFunctioningSymbols();
583
-
584
- var actual = new Map();
585
- actual.set(Symbol(),1);
586
- var expected = new Map();
587
- expected.set(jasmineUnderTest.anything(),1);
588
-
589
- expect(compareEquals(actual, expected).pass).toBe(true);
590
- });
591
-
592
- function isNotRunningInBrowser() {
593
- return typeof document === 'undefined'
594
- }
595
-
596
- it("reports mismatches between DOM nodes with different tags", function() {
597
- if(isNotRunningInBrowser()) {
598
- return;
599
- }
600
-
601
- var actual = {a: document.createElement('div')},
602
- expected = {a: document.createElement('p')},
603
- message = 'Expected $.a = HTMLNode to equal HTMLNode.';
604
-
605
- expect(compareEquals(actual, expected).message).toEqual(message);
606
- });
607
-
608
- it('reports mismatches between DOM nodes with different content', function() {
609
- if(isNotRunningInBrowser()) {
610
- return;
611
- }
612
-
613
- var nodeA = document.createElement('div'),
614
- nodeB = document.createElement('div');
615
-
616
- nodeA.innerText = 'foo'
617
- nodeB.innerText = 'bar'
618
-
619
- var actual = {a: nodeA},
620
- expected = {a: nodeB},
621
- message = 'Expected $.a = HTMLNode to equal HTMLNode.';
622
-
623
- expect(compareEquals(actual, expected).message).toEqual(message);
624
- })
625
-
626
- it("reports mismatches between a DOM node and a bare Object", function() {
627
- if(isNotRunningInBrowser()) {
628
- return;
629
- }
630
-
631
- var actual = {a: document.createElement('div')},
632
- expected = {a: {}},
633
- message = 'Expected $.a = HTMLNode to equal Object({ }).';
634
-
635
- expect(compareEquals(actual, expected).message).toEqual(message);
636
- });
637
-
638
- it("reports asymmetric mismatches", function() {
639
- var actual = {a: 1},
640
- expected = {a: jasmineUnderTest.any(String)},
641
- message = 'Expected $.a = 1 to equal <jasmine.any(String)>.';
642
-
643
- expect(compareEquals(actual, expected).message).toEqual(message);
644
- expect(compareEquals(actual, expected).pass).toBe(false)
645
- });
646
-
647
- it("reports asymmetric mismatches when the asymmetric comparand is the actual value", function() {
648
- var actual = {a: jasmineUnderTest.any(String)},
649
- expected = {a: 1},
650
- message = 'Expected $.a = <jasmine.any(String)> to equal 1.';
651
-
652
- expect(compareEquals(actual, expected).message).toEqual(message);
653
- expect(compareEquals(actual, expected).pass).toBe(false)
654
- });
655
-
656
- it("does not report a mismatch when asymmetric matchers are satisfied", function() {
657
- var actual = {a: 'a'},
658
- expected = {a: jasmineUnderTest.any(String)};
659
-
660
- expect(compareEquals(actual, expected).message).toEqual('');
661
- expect(compareEquals(actual, expected).pass).toBe(true)
662
- });
663
-
664
- it("works on big complex stuff", function() {
665
- var actual = {
666
- foo: [
667
- {bar: 1, things: ['a', 'b']},
668
- {bar: 2, things: ['a', 'b']}
669
- ],
670
- baz: [
671
- {a: {b: 1}}
672
- ],
673
- quux: 1,
674
- nan: 0,
675
- aRegexp: 'hi',
676
- inf: -1/0,
677
- boolean: false,
678
- notDefined: 0,
679
- aNull: void 0
680
- }
681
-
682
- var expected = {
683
- foo: [
684
- {bar: 2, things: ['a', 'b', 'c']},
685
- {bar: 2, things: ['a', 'd']}
686
- ],
687
- baz: [
688
- {a: {b: 1, c: 1}}
689
- ],
690
- quux: [],
691
- nan: 0/0,
692
- aRegexp: /hi/,
693
- inf: 1/0,
694
- boolean: true,
695
- notDefined: void 0,
696
- aNull: null
697
- }
698
-
699
- var message =
700
- 'Expected $.foo[0].bar = 1 to equal 2.\n' +
701
- 'Expected $.foo[0].things.length = 2 to equal 3.\n' +
702
- "Expected $.foo[0].things[2] = undefined to equal 'c'.\n" +
703
- "Expected $.foo[1].things[1] = 'b' to equal 'd'.\n" +
704
- 'Expected $.baz[0].a to have properties\n' +
705
- ' c: 1\n' +
706
- 'Expected $.quux = 1 to equal [ ].\n' +
707
- 'Expected $.nan = 0 to equal NaN.\n' +
708
- "Expected $.aRegexp = 'hi' to equal /hi/.\n" +
709
- 'Expected $.inf = -Infinity to equal Infinity.\n' +
710
- 'Expected $.boolean = false to equal true.\n' +
711
- 'Expected $.notDefined = 0 to equal undefined.\n' +
712
- 'Expected $.aNull = undefined to equal null.'
713
-
714
- expect(compareEquals(actual, expected).message).toEqual(message);
715
- })
716
-
717
- describe("different length arrays", function() {
718
- it("actual array is longer", function() {
719
- var actual = [1, 1, 2, 3, 5],
720
- expected = [1, 1, 2, 3],
721
- message = 'Expected $.length = 5 to equal 4.\n' +
722
- 'Expected $[4] = 5 to equal undefined.';
723
-
724
- expect(compareEquals(actual, expected).pass).toBe(false)
725
- expect(compareEquals(actual, expected).message).toEqual(message);
726
- });
727
-
728
- it("expected array is longer", function() {
729
- var actual = [1, 1, 2, 3],
730
- expected = [1, 1, 2, 3, 5],
731
- message = 'Expected $.length = 4 to equal 5.\n' +
732
- 'Expected $[4] = undefined to equal 5.';
733
-
734
- expect(compareEquals(actual, expected).pass).toBe(false)
735
- expect(compareEquals(actual, expected).message).toEqual(message);
736
- });
737
-
738
- it("expected array is longer by 4 elements", function() {
739
- var actual = [1, 1, 2],
740
- expected = [1, 1, 2, 3, 5, 8, 13],
741
- message = 'Expected $.length = 3 to equal 7.\n' +
742
- 'Expected $[3] = undefined to equal 3.\n' +
743
- 'Expected $[4] = undefined to equal 5.\n' +
744
- 'Expected $[5] = undefined to equal 8.\n' +
745
- 'Expected $[6] = undefined to equal 13.';
746
-
747
- expect(compareEquals(actual, expected).pass).toBe(false)
748
- expect(compareEquals(actual, expected).message).toEqual(message);
749
- });
750
-
751
- it("different length and different elements", function() {
752
- var actual = [1],
753
- expected = [2, 3],
754
- message = 'Expected $.length = 1 to equal 2.\n' +
755
- 'Expected $[0] = 1 to equal 2.\n' +
756
- 'Expected $[1] = undefined to equal 3.';
757
-
758
- expect(compareEquals(actual, expected).pass).toBe(false)
759
- expect(compareEquals(actual, expected).message).toEqual(message);
760
- });
761
-
762
- it("object with nested array", function() {
763
- var actual = { values: [1, 1, 2, 3] },
764
- expected = { values: [1, 1, 2] },
765
- message = 'Expected $.values.length = 4 to equal 3.\n' +
766
- 'Expected $.values[3] = 3 to equal undefined.';
767
-
768
- expect(compareEquals(actual, expected).pass).toBe(false)
769
- expect(compareEquals(actual, expected).message).toEqual(message);
770
- });
771
-
772
- it("array with nested object", function() {
773
- var actual = [1, 1, 2, { value: 3 }],
774
- expected = [1, 1, 2],
775
- message = 'Expected $.length = 4 to equal 3.\n' +
776
- 'Expected $[3] = Object({ value: 3 }) to equal undefined.';
777
-
778
- expect(compareEquals(actual, expected).pass).toBe(false)
779
- expect(compareEquals(actual, expected).message).toEqual(message);
780
- });
781
-
782
- it("array with nested different length array", function() {
783
- var actual = [[1], [1, 2]],
784
- expected = [[1, 1], [2]],
785
- message = 'Expected $[0].length = 1 to equal 2.\n' +
786
- 'Expected $[0][1] = undefined to equal 1.\n' +
787
- 'Expected $[1].length = 2 to equal 1.\n' +
788
- 'Expected $[1][0] = 1 to equal 2.\n' +
789
- 'Expected $[1][1] = 2 to equal undefined.';
790
-
791
- expect(compareEquals(actual, expected).pass).toBe(false)
792
- expect(compareEquals(actual, expected).message).toEqual(message);
793
- });
794
-
795
- it("last element of longer array is undefined", function() {
796
- var actual = [1, 2],
797
- expected = [1, 2, void 0],
798
- message = 'Expected $.length = 2 to equal 3.';
799
-
800
- expect(compareEquals(actual, expected).pass).toBe(false)
801
- expect(compareEquals(actual, expected).message).toEqual(message);
802
- });
803
- })
804
- });