jasmine-core 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jasmine-core/boot/node_boot.js +1 -1
  3. data/lib/jasmine-core/jasmine-html.js +0 -35
  4. data/lib/jasmine-core/jasmine.css +0 -6
  5. data/lib/jasmine-core/jasmine.js +246 -36
  6. data/lib/jasmine-core/node_boot.js +1 -1
  7. data/lib/jasmine-core/version.rb +1 -1
  8. metadata +3 -88
  9. data/lib/jasmine-core/spec/core/CallTrackerSpec.js +0 -130
  10. data/lib/jasmine-core/spec/core/ClearStackSpec.js +0 -137
  11. data/lib/jasmine-core/spec/core/ClockSpec.js +0 -710
  12. data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +0 -286
  13. data/lib/jasmine-core/spec/core/EnvSpec.js +0 -200
  14. data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +0 -120
  15. data/lib/jasmine-core/spec/core/ExceptionsSpec.js +0 -46
  16. data/lib/jasmine-core/spec/core/ExpectationResultSpec.js +0 -61
  17. data/lib/jasmine-core/spec/core/ExpectationSpec.js +0 -434
  18. data/lib/jasmine-core/spec/core/GlobalErrorsSpec.js +0 -110
  19. data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +0 -259
  20. data/lib/jasmine-core/spec/core/MockDateSpec.js +0 -200
  21. data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +0 -332
  22. data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +0 -670
  23. data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +0 -140
  24. data/lib/jasmine-core/spec/core/SpecSpec.js +0 -407
  25. data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +0 -364
  26. data/lib/jasmine-core/spec/core/SpySpec.js +0 -177
  27. data/lib/jasmine-core/spec/core/SpyStrategySpec.js +0 -202
  28. data/lib/jasmine-core/spec/core/StackTraceSpec.js +0 -166
  29. data/lib/jasmine-core/spec/core/SuiteSpec.js +0 -123
  30. data/lib/jasmine-core/spec/core/TimerSpec.js +0 -31
  31. data/lib/jasmine-core/spec/core/TreeProcessorSpec.js +0 -794
  32. data/lib/jasmine-core/spec/core/UserContextSpec.js +0 -54
  33. data/lib/jasmine-core/spec/core/UtilSpec.js +0 -105
  34. data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +0 -91
  35. data/lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js +0 -76
  36. data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js +0 -52
  37. data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js +0 -47
  38. data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +0 -99
  39. data/lib/jasmine-core/spec/core/asymmetric_equality/StringMatchingSpec.js +0 -27
  40. data/lib/jasmine-core/spec/core/formatErrorMsgSpec.js +0 -13
  41. data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +0 -200
  42. data/lib/jasmine-core/spec/core/integration/CustomSpyStrategiesSpec.js +0 -138
  43. data/lib/jasmine-core/spec/core/integration/EnvSpec.js +0 -2344
  44. data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +0 -976
  45. data/lib/jasmine-core/spec/core/matchers/DiffBuilderSpec.js +0 -47
  46. data/lib/jasmine-core/spec/core/matchers/NullDiffBuilderSpec.js +0 -13
  47. data/lib/jasmine-core/spec/core/matchers/ObjectPathSpec.js +0 -43
  48. data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +0 -645
  49. data/lib/jasmine-core/spec/core/matchers/nothingSpec.js +0 -8
  50. data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +0 -93
  51. data/lib/jasmine-core/spec/core/matchers/toBeDefinedSpec.js +0 -18
  52. data/lib/jasmine-core/spec/core/matchers/toBeFalsySpec.js +0 -38
  53. data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanOrEqualSpec.js +0 -29
  54. data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +0 -20
  55. data/lib/jasmine-core/spec/core/matchers/toBeLessThanOrEqualSpec.js +0 -29
  56. data/lib/jasmine-core/spec/core/matchers/toBeLessThanSpec.js +0 -20
  57. data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +0 -37
  58. data/lib/jasmine-core/spec/core/matchers/toBeNegativeInfinitySpec.js +0 -31
  59. data/lib/jasmine-core/spec/core/matchers/toBeNullSpec.js +0 -17
  60. data/lib/jasmine-core/spec/core/matchers/toBePositiveInfinitySpec.js +0 -31
  61. data/lib/jasmine-core/spec/core/matchers/toBeSpec.js +0 -17
  62. data/lib/jasmine-core/spec/core/matchers/toBeTruthySpec.js +0 -38
  63. data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +0 -18
  64. data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +0 -26
  65. data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +0 -785
  66. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledBeforeSpec.js +0 -99
  67. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +0 -47
  68. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledTimesSpec.js +0 -86
  69. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +0 -67
  70. data/lib/jasmine-core/spec/core/matchers/toMatchSpec.js +0 -43
  71. data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +0 -315
  72. data/lib/jasmine-core/spec/core/matchers/toThrowMatchingSpec.js +0 -73
  73. data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +0 -100
  74. data/lib/jasmine-core/spec/helpers/BrowserFlags.js +0 -15
  75. data/lib/jasmine-core/spec/helpers/asyncAwait.js +0 -27
  76. data/lib/jasmine-core/spec/helpers/checkForMap.js +0 -37
  77. data/lib/jasmine-core/spec/helpers/checkForSet.js +0 -41
  78. data/lib/jasmine-core/spec/helpers/checkForSymbol.js +0 -28
  79. data/lib/jasmine-core/spec/helpers/checkForTypedArrays.js +0 -20
  80. data/lib/jasmine-core/spec/helpers/defineJasmineUnderTest.js +0 -6
  81. data/lib/jasmine-core/spec/helpers/integrationMatchers.js +0 -43
  82. data/lib/jasmine-core/spec/helpers/nodeDefineJasmineUnderTest.js +0 -30
  83. data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +0 -1261
  84. data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +0 -18
  85. data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +0 -37
  86. data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +0 -27
  87. data/lib/jasmine-core/spec/html/QueryStringSpec.js +0 -72
  88. data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +0 -62
  89. data/lib/jasmine-core/spec/html/SpyRegistryHtmlSpec.js +0 -39
  90. data/lib/jasmine-core/spec/html/matchers/toHaveClassSpec.js +0 -48
  91. data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +0 -101
  92. data/lib/jasmine-core/spec/performance/large_object_test.js +0 -36
  93. data/lib/jasmine-core/spec/performance/performance_test.js +0 -10
@@ -1,18 +0,0 @@
1
- describe("toBeUndefined", function() {
2
- it("passes for undefined values", function() {
3
- var matcher = jasmineUnderTest.matchers.toBeUndefined(),
4
- result;
5
-
6
- result = matcher.compare(void 0);
7
- expect(result.pass).toBe(true);
8
-
9
- });
10
-
11
- it("fails when matching defined values", function() {
12
- var matcher = jasmineUnderTest.matchers.toBeUndefined(),
13
- result;
14
-
15
- result = matcher.compare('foo');
16
- expect(result.pass).toBe(false);
17
- })
18
- });
@@ -1,26 +0,0 @@
1
- describe("toContain", function() {
2
- it("delegates to jasmineUnderTest.matchersUtil.contains", function() {
3
- var util = {
4
- contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
5
- },
6
- matcher = jasmineUnderTest.matchers.toContain(util),
7
- result;
8
-
9
- result = matcher.compare("ABC", "B");
10
- expect(util.contains).toHaveBeenCalledWith("ABC", "B", []);
11
- expect(result.pass).toBe(true);
12
- });
13
-
14
- it("delegates to jasmineUnderTest.matchersUtil.contains, passing in equality testers if present", function() {
15
- var util = {
16
- contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
17
- },
18
- customEqualityTesters = ['a', 'b'],
19
- matcher = jasmineUnderTest.matchers.toContain(util, customEqualityTesters),
20
- result;
21
-
22
- result = matcher.compare("ABC", "B");
23
- expect(util.contains).toHaveBeenCalledWith("ABC", "B", ['a', 'b']);
24
- expect(result.pass).toBe(true);
25
- });
26
- });
@@ -1,785 +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
- it("reports mismatches between objects with their own constructor property", function () {
303
- function Foo() {}
304
- function Bar() {}
305
-
306
- var actual = {x: {constructor: 'blerf'}},
307
- expected = {x: {constructor: 'ftarrh'}},
308
- message = "Expected $.x.constructor = 'blerf' to equal 'ftarrh'.";
309
-
310
- expect(compareEquals(actual, expected).message).toEqual(message);
311
- });
312
-
313
- it("reports mismatches between an object with a real constructor and one with its own constructor property", function () {
314
- function Foo() {}
315
- function Bar() {}
316
-
317
- var actual = {x: {}},
318
- expected = {x: {constructor: 'ftarrh'}},
319
- message =
320
- "Expected $.x to have properties\n" +
321
- " constructor: 'ftarrh'";
322
-
323
- expect(compareEquals(actual, expected).message).toEqual(message);
324
- expect(compareEquals(expected, actual).message).toEqual(
325
- "Expected $.x not to have properties\n constructor: 'ftarrh'"
326
- );
327
- });
328
-
329
- it("reports mismatches between 0 and -0", function() {
330
- var actual = {x: 0},
331
- expected = {x: -0},
332
- message = "Expected $.x = 0 to equal -0.";
333
-
334
- expect(compareEquals(actual, expected).message).toEqual(message);
335
- });
336
-
337
- it("reports mismatches between Errors", function() {
338
- var actual = {x: new Error("the error you got")},
339
- expected = {x: new Error("the error you want")},
340
- message = "Expected $.x = Error: the error you got to equal Error: the error you want.";
341
-
342
- expect(compareEquals(actual, expected).message).toEqual(message);
343
- });
344
-
345
- it("reports mismatches between Functions", function() {
346
- var actual = {x: function() {}},
347
- expected = {x: function() {}},
348
- message = "Expected $.x = Function to equal Function.";
349
-
350
- expect(compareEquals(actual, expected).message).toEqual(message);
351
- });
352
-
353
- // == Sets ==
354
-
355
- it("reports mismatches between Sets", function() {
356
- jasmine.getEnv().requireFunctioningSets();
357
-
358
- var actual = new Set();
359
- actual.add(1);
360
- var expected = new Set();
361
- expected.add(2);
362
- var message = 'Expected Set( 1 ) to equal Set( 2 ).';
363
-
364
- expect(compareEquals(actual, expected).message).toEqual(message);
365
- });
366
-
367
- it("reports deep mismatches within Sets", function() {
368
- jasmine.getEnv().requireFunctioningSets();
369
-
370
- var actual = new Set();
371
- actual.add({x: 1});
372
- var expected = new Set();
373
- expected.add({x: 2});
374
- var message = 'Expected Set( Object({ x: 1 }) ) to equal Set( Object({ x: 2 }) ).';
375
-
376
- expect(compareEquals(actual, expected).message).toEqual(message);
377
- });
378
-
379
- it("reports mismatches between Sets nested in objects", function() {
380
- jasmine.getEnv().requireFunctioningSets();
381
-
382
- var actualSet = new Set();
383
- actualSet.add(1);
384
- var expectedSet = new Set();
385
- expectedSet.add(2);
386
-
387
- var actual = { sets: [actualSet] };
388
- var expected = { sets: [expectedSet] };
389
- var message = "Expected $.sets[0] = Set( 1 ) to equal Set( 2 ).";
390
-
391
- expect(compareEquals(actual, expected).message).toEqual(message);
392
- });
393
-
394
- it("reports mismatches between Sets of different lengths", function() {
395
- jasmine.getEnv().requireFunctioningSets();
396
-
397
- var actual = new Set();
398
- actual.add(1);
399
- actual.add(2);
400
- var expected = new Set();
401
- expected.add(2);
402
- var message = 'Expected Set( 1, 2 ) to equal Set( 2 ).';
403
-
404
- expect(compareEquals(actual, expected).message).toEqual(message);
405
- });
406
-
407
- it("reports mismatches between Sets where actual is missing a value from expected", function() {
408
- jasmine.getEnv().requireFunctioningSets();
409
-
410
- // Use 'duplicate' object in actual so sizes match
411
- var actual = new Set();
412
- actual.add({x: 1});
413
- actual.add({x: 1});
414
- var expected = new Set();
415
- expected.add({x: 1});
416
- expected.add({x: 2});
417
- var message = 'Expected Set( Object({ x: 1 }), Object({ x: 1 }) ) to equal Set( Object({ x: 1 }), Object({ x: 2 }) ).';
418
-
419
- expect(compareEquals(actual, expected).message).toEqual(message);
420
- });
421
-
422
- it("reports mismatches between Sets where actual has a value missing from expected", function() {
423
- jasmine.getEnv().requireFunctioningSets();
424
-
425
- // Use 'duplicate' object in expected so sizes match
426
- var actual = new Set();
427
- actual.add({x: 1});
428
- actual.add({x: 2});
429
- var expected = new Set();
430
- expected.add({x: 1});
431
- expected.add({x: 1});
432
- var message = 'Expected Set( Object({ x: 1 }), Object({ x: 2 }) ) to equal Set( Object({ x: 1 }), Object({ x: 1 }) ).';
433
-
434
- expect(compareEquals(actual, expected).message).toEqual(message);
435
- });
436
-
437
- // == Maps ==
438
-
439
- it("does not report mismatches between deep equal Maps", function() {
440
- jasmine.getEnv().requireFunctioningMaps();
441
-
442
- // values are the same but with different object identity
443
- var actual = new Map();
444
- actual.set('a',{x:1});
445
- var expected = new Map();
446
- expected.set('a',{x:1});
447
-
448
- expect(compareEquals(actual, expected).pass).toBe(true);
449
- });
450
-
451
- it("reports deep mismatches within Maps", function() {
452
- jasmine.getEnv().requireFunctioningMaps();
453
-
454
- var actual = new Map();
455
- actual.set('a',{x:1});
456
- var expected = new Map();
457
- expected.set('a',{x:2});
458
- var message = "Expected Map( [ 'a', Object({ x: 1 }) ] ) to equal Map( [ 'a', Object({ x: 2 }) ] ).";
459
-
460
- expect(compareEquals(actual, expected).message).toEqual(message);
461
- });
462
-
463
- it("reports mismatches between Maps nested in objects", function() {
464
- jasmine.getEnv().requireFunctioningMaps();
465
-
466
- var actual = {Maps:[new Map()]};
467
- actual.Maps[0].set('a',1);
468
- var expected = {Maps:[new Map()]};
469
- expected.Maps[0].set('a',2);
470
-
471
- var message = "Expected $.Maps[0] = Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ] ).";
472
-
473
- expect(compareEquals(actual, expected).message).toEqual(message);
474
- });
475
-
476
- it("reports mismatches between Maps of different lengths", function() {
477
- jasmine.getEnv().requireFunctioningMaps();
478
-
479
- var actual = new Map();
480
- actual.set('a',1);
481
- var expected = new Map();
482
- expected.set('a',2);
483
- expected.set('b',1);
484
- var message = "Expected Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ], [ 'b', 1 ] ).";
485
-
486
- expect(compareEquals(actual, expected).message).toEqual(message);
487
- });
488
-
489
- it("reports mismatches between Maps with equal values but differing keys", function() {
490
- jasmine.getEnv().requireFunctioningMaps();
491
-
492
- var actual = new Map();
493
- actual.set('a',1);
494
- var expected = new Map();
495
- expected.set('b',1);
496
- var message = "Expected Map( [ 'a', 1 ] ) to equal Map( [ 'b', 1 ] ).";
497
-
498
- expect(compareEquals(actual, expected).message).toEqual(message);
499
- });
500
-
501
- it("does not report mismatches between Maps with keys with same object identity", function() {
502
- jasmine.getEnv().requireFunctioningMaps();
503
- var key = {x: 1};
504
- var actual = new Map();
505
- actual.set(key,2);
506
- var expected = new Map();
507
- expected.set(key,2);
508
-
509
- expect(compareEquals(actual, expected).pass).toBe(true);
510
- });
511
-
512
- it("reports mismatches between Maps with identical keys with different object identity", function() {
513
- jasmine.getEnv().requireFunctioningMaps();
514
-
515
- var actual = new Map();
516
- actual.set({x:1},2);
517
- var expected = new Map();
518
- expected.set({x:1},2);
519
- var message = "Expected Map( [ Object({ x: 1 }), 2 ] ) to equal Map( [ Object({ x: 1 }), 2 ] ).";
520
-
521
- expect(compareEquals(actual, expected).message).toEqual(message);
522
- });
523
-
524
- it("does not report mismatches when comparing Map key to jasmine.anything()", function() {
525
- jasmine.getEnv().requireFunctioningMaps();
526
-
527
- var actual = new Map();
528
- actual.set('a',1);
529
- var expected = new Map();
530
- expected.set(jasmineUnderTest.anything(),1);
531
-
532
- expect(compareEquals(actual, expected).pass).toBe(true);
533
- });
534
-
535
- it("does not report mismatches when comparing Maps with the same symbol keys", function() {
536
- jasmine.getEnv().requireFunctioningMaps();
537
- jasmine.getEnv().requireFunctioningSymbols();
538
-
539
- var key = Symbol();
540
- var actual = new Map();
541
- actual.set(key,1);
542
- var expected = new Map();
543
- expected.set(key,1);
544
-
545
- expect(compareEquals(actual, expected).pass).toBe(true);
546
- });
547
-
548
- it("reports mismatches between Maps with different symbol keys", function() {
549
- jasmine.getEnv().requireFunctioningMaps();
550
- jasmine.getEnv().requireFunctioningSymbols();
551
-
552
- var actual = new Map();
553
- actual.set(Symbol(),1);
554
- var expected = new Map();
555
- expected.set(Symbol(),1);
556
- var message = "Expected Map( [ Symbol(), 1 ] ) to equal Map( [ Symbol(), 1 ] ).";
557
-
558
- expect(compareEquals(actual, expected).message).toBe(message);
559
- });
560
-
561
- it("does not report mismatches when comparing Map symbol key to jasmine.anything()", function() {
562
- jasmine.getEnv().requireFunctioningMaps();
563
- jasmine.getEnv().requireFunctioningSymbols();
564
-
565
- var actual = new Map();
566
- actual.set(Symbol(),1);
567
- var expected = new Map();
568
- expected.set(jasmineUnderTest.anything(),1);
569
-
570
- expect(compareEquals(actual, expected).pass).toBe(true);
571
- });
572
-
573
- function isNotRunningInBrowser() {
574
- return typeof document === 'undefined'
575
- }
576
-
577
- it("reports mismatches between DOM nodes with different tags", function() {
578
- if(isNotRunningInBrowser()) {
579
- return;
580
- }
581
-
582
- var actual = {a: document.createElement('div')},
583
- expected = {a: document.createElement('p')},
584
- message = 'Expected $.a = <div> to equal <p>.';
585
-
586
- expect(compareEquals(actual, expected).message).toEqual(message);
587
- });
588
-
589
- it('reports mismatches between DOM nodes with different content', function() {
590
- if(isNotRunningInBrowser()) {
591
- return;
592
- }
593
-
594
- var nodeA = document.createElement('div'),
595
- nodeB = document.createElement('div');
596
-
597
- nodeA.innerText = 'foo'
598
- nodeB.innerText = 'bar'
599
-
600
- var actual = {a: nodeA},
601
- expected = {a: nodeB},
602
- message = 'Expected $.a = <div>...</div> to equal <div>...</div>.';
603
-
604
- expect(compareEquals(actual, expected).message).toEqual(message);
605
- })
606
-
607
- it("reports mismatches between a DOM node and a bare Object", function() {
608
- if(isNotRunningInBrowser()) {
609
- return;
610
- }
611
-
612
- var actual = {a: document.createElement('div')},
613
- expected = {a: {}},
614
- message = 'Expected $.a = <div> to equal Object({ }).';
615
-
616
- expect(compareEquals(actual, expected).message).toEqual(message);
617
- });
618
-
619
- it("reports asymmetric mismatches", function() {
620
- var actual = {a: 1},
621
- expected = {a: jasmineUnderTest.any(String)},
622
- message = 'Expected $.a = 1 to equal <jasmine.any(String)>.';
623
-
624
- expect(compareEquals(actual, expected).message).toEqual(message);
625
- expect(compareEquals(actual, expected).pass).toBe(false)
626
- });
627
-
628
- it("reports asymmetric mismatches when the asymmetric comparand is the actual value", function() {
629
- var actual = {a: jasmineUnderTest.any(String)},
630
- expected = {a: 1},
631
- message = 'Expected $.a = <jasmine.any(String)> to equal 1.';
632
-
633
- expect(compareEquals(actual, expected).message).toEqual(message);
634
- expect(compareEquals(actual, expected).pass).toBe(false)
635
- });
636
-
637
- it("does not report a mismatch when asymmetric matchers are satisfied", function() {
638
- var actual = {a: 'a'},
639
- expected = {a: jasmineUnderTest.any(String)};
640
-
641
- expect(compareEquals(actual, expected).message).toEqual('');
642
- expect(compareEquals(actual, expected).pass).toBe(true)
643
- });
644
-
645
- it("works on big complex stuff", function() {
646
- var actual = {
647
- foo: [
648
- {bar: 1, things: ['a', 'b']},
649
- {bar: 2, things: ['a', 'b']}
650
- ],
651
- baz: [
652
- {a: {b: 1}}
653
- ],
654
- quux: 1,
655
- nan: 0,
656
- aRegexp: 'hi',
657
- inf: -1/0,
658
- boolean: false,
659
- notDefined: 0,
660
- aNull: void 0
661
- }
662
-
663
- var expected = {
664
- foo: [
665
- {bar: 2, things: ['a', 'b', 'c']},
666
- {bar: 2, things: ['a', 'd']}
667
- ],
668
- baz: [
669
- {a: {b: 1, c: 1}}
670
- ],
671
- quux: [],
672
- nan: 0/0,
673
- aRegexp: /hi/,
674
- inf: 1/0,
675
- boolean: true,
676
- notDefined: void 0,
677
- aNull: null
678
- }
679
-
680
- var message =
681
- 'Expected $.foo[0].bar = 1 to equal 2.\n' +
682
- 'Expected $.foo[0].things.length = 2 to equal 3.\n' +
683
- "Expected $.foo[0].things[2] = undefined to equal 'c'.\n" +
684
- "Expected $.foo[1].things[1] = 'b' to equal 'd'.\n" +
685
- 'Expected $.baz[0].a to have properties\n' +
686
- ' c: 1\n' +
687
- 'Expected $.quux = 1 to equal [ ].\n' +
688
- 'Expected $.nan = 0 to equal NaN.\n' +
689
- "Expected $.aRegexp = 'hi' to equal /hi/.\n" +
690
- 'Expected $.inf = -Infinity to equal Infinity.\n' +
691
- 'Expected $.boolean = false to equal true.\n' +
692
- 'Expected $.notDefined = 0 to equal undefined.\n' +
693
- 'Expected $.aNull = undefined to equal null.'
694
-
695
- expect(compareEquals(actual, expected).message).toEqual(message);
696
- })
697
-
698
- describe("different length arrays", function() {
699
- it("actual array is longer", function() {
700
- var actual = [1, 1, 2, 3, 5],
701
- expected = [1, 1, 2, 3],
702
- message = 'Expected $.length = 5 to equal 4.\n' +
703
- 'Expected $[4] = 5 to equal undefined.';
704
-
705
- expect(compareEquals(actual, expected).pass).toBe(false)
706
- expect(compareEquals(actual, expected).message).toEqual(message);
707
- });
708
-
709
- it("expected array is longer", function() {
710
- var actual = [1, 1, 2, 3],
711
- expected = [1, 1, 2, 3, 5],
712
- message = 'Expected $.length = 4 to equal 5.\n' +
713
- 'Expected $[4] = undefined to equal 5.';
714
-
715
- expect(compareEquals(actual, expected).pass).toBe(false)
716
- expect(compareEquals(actual, expected).message).toEqual(message);
717
- });
718
-
719
- it("expected array is longer by 4 elements", function() {
720
- var actual = [1, 1, 2],
721
- expected = [1, 1, 2, 3, 5, 8, 13],
722
- message = 'Expected $.length = 3 to equal 7.\n' +
723
- 'Expected $[3] = undefined to equal 3.\n' +
724
- 'Expected $[4] = undefined to equal 5.\n' +
725
- 'Expected $[5] = undefined to equal 8.\n' +
726
- 'Expected $[6] = undefined to equal 13.';
727
-
728
- expect(compareEquals(actual, expected).pass).toBe(false)
729
- expect(compareEquals(actual, expected).message).toEqual(message);
730
- });
731
-
732
- it("different length and different elements", function() {
733
- var actual = [1],
734
- expected = [2, 3],
735
- message = 'Expected $.length = 1 to equal 2.\n' +
736
- 'Expected $[0] = 1 to equal 2.\n' +
737
- 'Expected $[1] = undefined to equal 3.';
738
-
739
- expect(compareEquals(actual, expected).pass).toBe(false)
740
- expect(compareEquals(actual, expected).message).toEqual(message);
741
- });
742
-
743
- it("object with nested array", function() {
744
- var actual = { values: [1, 1, 2, 3] },
745
- expected = { values: [1, 1, 2] },
746
- message = 'Expected $.values.length = 4 to equal 3.\n' +
747
- 'Expected $.values[3] = 3 to equal undefined.';
748
-
749
- expect(compareEquals(actual, expected).pass).toBe(false)
750
- expect(compareEquals(actual, expected).message).toEqual(message);
751
- });
752
-
753
- it("array with nested object", function() {
754
- var actual = [1, 1, 2, { value: 3 }],
755
- expected = [1, 1, 2],
756
- message = 'Expected $.length = 4 to equal 3.\n' +
757
- 'Expected $[3] = Object({ value: 3 }) to equal undefined.';
758
-
759
- expect(compareEquals(actual, expected).pass).toBe(false)
760
- expect(compareEquals(actual, expected).message).toEqual(message);
761
- });
762
-
763
- it("array with nested different length array", function() {
764
- var actual = [[1], [1, 2]],
765
- expected = [[1, 1], [2]],
766
- message = 'Expected $[0].length = 1 to equal 2.\n' +
767
- 'Expected $[0][1] = undefined to equal 1.\n' +
768
- 'Expected $[1].length = 2 to equal 1.\n' +
769
- 'Expected $[1][0] = 1 to equal 2.\n' +
770
- 'Expected $[1][1] = 2 to equal undefined.';
771
-
772
- expect(compareEquals(actual, expected).pass).toBe(false)
773
- expect(compareEquals(actual, expected).message).toEqual(message);
774
- });
775
-
776
- it("last element of longer array is undefined", function() {
777
- var actual = [1, 2],
778
- expected = [1, 2, void 0],
779
- message = 'Expected $.length = 2 to equal 3.';
780
-
781
- expect(compareEquals(actual, expected).pass).toBe(false)
782
- expect(compareEquals(actual, expected).message).toEqual(message);
783
- });
784
- })
785
- });