jasmine-core 2.8.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/console/console.js +1 -1
- data/lib/jasmine-core/boot.js +1 -1
- data/lib/jasmine-core/jasmine-html.js +53 -30
- data/lib/jasmine-core/jasmine.js +258 -101
- data/lib/jasmine-core/node_boot.js +1 -1
- data/lib/jasmine-core/spec/core/ClockSpec.js +85 -13
- data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +10 -8
- data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +63 -15
- data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +8 -5
- data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +18 -0
- data/lib/jasmine-core/spec/core/SpyStrategySpec.js +23 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +32 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js +32 -0
- data/lib/jasmine-core/spec/core/integration/EnvSpec.js +101 -0
- data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +130 -44
- data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +124 -39
- data/lib/jasmine-core/spec/helpers/checkForMap.js +19 -4
- data/lib/jasmine-core/spec/helpers/checkForSet.js +23 -3
- data/lib/jasmine-core/spec/helpers/checkForSymbol.js +28 -0
- data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +2 -2
- data/lib/jasmine-core/spec/html/SpyRegistryHtmlSpec.js +34 -0
- data/lib/jasmine-core/version.rb +1 -1
- metadata +4 -2
@@ -23,6 +23,38 @@ describe("Anything", function() {
|
|
23
23
|
expect(anything.asymmetricMatch([1,2,3])).toBe(true);
|
24
24
|
});
|
25
25
|
|
26
|
+
it("matches a Map", function() {
|
27
|
+
jasmine.getEnv().requireFunctioningMaps();
|
28
|
+
|
29
|
+
var anything = new jasmineUnderTest.Anything();
|
30
|
+
|
31
|
+
expect(anything.asymmetricMatch(new Map())).toBe(true);
|
32
|
+
});
|
33
|
+
|
34
|
+
it("matches a Set", function() {
|
35
|
+
jasmine.getEnv().requireFunctioningSets();
|
36
|
+
|
37
|
+
var anything = new jasmineUnderTest.Anything();
|
38
|
+
|
39
|
+
expect(anything.asymmetricMatch(new Set())).toBe(true);
|
40
|
+
});
|
41
|
+
|
42
|
+
it("matches a TypedArray", function() {
|
43
|
+
jasmine.getEnv().requireFunctioningTypedArrays();
|
44
|
+
|
45
|
+
var anything = new jasmineUnderTest.Anything();
|
46
|
+
|
47
|
+
expect(anything.asymmetricMatch(new Uint32Array([]))).toBe(true);
|
48
|
+
});
|
49
|
+
|
50
|
+
it("matches a Symbol", function() {
|
51
|
+
jasmine.getEnv().requireFunctioningSymbols();
|
52
|
+
|
53
|
+
var anything = new jasmineUnderTest.Anything();
|
54
|
+
|
55
|
+
expect(anything.asymmetricMatch(Symbol())).toBe(true);
|
56
|
+
});
|
57
|
+
|
26
58
|
it("doesn't match undefined", function() {
|
27
59
|
var anything = new jasmineUnderTest.Anything();
|
28
60
|
|
@@ -1485,6 +1485,7 @@ describe("Env integration", function() {
|
|
1485
1485
|
reporter.jasmineDone.and.callFake(function() {
|
1486
1486
|
var specStatus = reporter.specDone.calls.argsFor(0)[0];
|
1487
1487
|
|
1488
|
+
expect(specStatus.status).toBe('pending');
|
1488
1489
|
expect(specStatus.pendingReason).toBe('with a message');
|
1489
1490
|
|
1490
1491
|
done();
|
@@ -1499,6 +1500,45 @@ describe("Env integration", function() {
|
|
1499
1500
|
env.execute();
|
1500
1501
|
});
|
1501
1502
|
|
1503
|
+
it('should report pending spec messages from promise-returning functions', function(done) {
|
1504
|
+
function StubPromise(fn) {
|
1505
|
+
try {
|
1506
|
+
fn();
|
1507
|
+
} catch (e) {
|
1508
|
+
this.exception = e;
|
1509
|
+
}
|
1510
|
+
}
|
1511
|
+
|
1512
|
+
StubPromise.prototype.then = function(resolve, reject) {
|
1513
|
+
reject(this.exception);
|
1514
|
+
};
|
1515
|
+
|
1516
|
+
var env = new jasmineUnderTest.Env(),
|
1517
|
+
reporter = jasmine.createSpyObj('fakeReporter', [
|
1518
|
+
'specDone',
|
1519
|
+
'jasmineDone'
|
1520
|
+
]);
|
1521
|
+
|
1522
|
+
reporter.jasmineDone.and.callFake(function() {
|
1523
|
+
var specStatus = reporter.specDone.calls.argsFor(0)[0];
|
1524
|
+
|
1525
|
+
expect(specStatus.status).toBe('pending');
|
1526
|
+
expect(specStatus.pendingReason).toBe('with a message');
|
1527
|
+
|
1528
|
+
done();
|
1529
|
+
});
|
1530
|
+
|
1531
|
+
env.addReporter(reporter);
|
1532
|
+
|
1533
|
+
env.it('will be pending', function() {
|
1534
|
+
return new StubPromise(function() {
|
1535
|
+
env.pending('with a message');
|
1536
|
+
});
|
1537
|
+
});
|
1538
|
+
|
1539
|
+
env.execute();
|
1540
|
+
});
|
1541
|
+
|
1502
1542
|
it('should report using fallback reporter', function(done) {
|
1503
1543
|
var env = new jasmineUnderTest.Env(),
|
1504
1544
|
reporter = jasmine.createSpyObj('fakeReporter', [
|
@@ -1903,4 +1943,65 @@ describe("Env integration", function() {
|
|
1903
1943
|
|
1904
1944
|
env.execute();
|
1905
1945
|
});
|
1946
|
+
|
1947
|
+
it('should throw on suites/specs/befores/afters nested in methods other than \'describe\'', function(done) {
|
1948
|
+
var env = new jasmineUnderTest.Env(),
|
1949
|
+
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
1950
|
+
|
1951
|
+
reporter.jasmineDone.and.callFake(function() {
|
1952
|
+
var msg = /\'.*\' should only be used in \'describe\' function/;
|
1953
|
+
|
1954
|
+
expect(reporter.specDone).toHaveFailedExpecationsForRunnable('suite describe', [msg]);
|
1955
|
+
expect(reporter.specDone).toHaveFailedExpecationsForRunnable('suite xdescribe', [msg]);
|
1956
|
+
expect(reporter.specDone).toHaveFailedExpecationsForRunnable('suite fdescribe', [msg]);
|
1957
|
+
|
1958
|
+
expect(reporter.specDone).toHaveFailedExpecationsForRunnable('spec it', [msg]);
|
1959
|
+
expect(reporter.specDone).toHaveFailedExpecationsForRunnable('spec xit', [msg]);
|
1960
|
+
expect(reporter.specDone).toHaveFailedExpecationsForRunnable('spec fit', [msg]);
|
1961
|
+
|
1962
|
+
expect(reporter.specDone).toHaveFailedExpecationsForRunnable('beforeAll spec', [msg]);
|
1963
|
+
expect(reporter.specDone).toHaveFailedExpecationsForRunnable('beforeEach spec', [msg]);
|
1964
|
+
|
1965
|
+
expect(reporter.suiteDone).toHaveFailedExpecationsForRunnable('afterAll', [msg]);
|
1966
|
+
expect(reporter.specDone).toHaveFailedExpecationsForRunnable('afterEach spec', [msg]);
|
1967
|
+
|
1968
|
+
done();
|
1969
|
+
});
|
1970
|
+
|
1971
|
+
env.addReporter(reporter);
|
1972
|
+
|
1973
|
+
env.describe('suite', function() {
|
1974
|
+
env.it('describe', function() { env.describe('inner suite', function() {}); });
|
1975
|
+
env.it('xdescribe', function() { env.xdescribe('inner suite', function() {}); });
|
1976
|
+
env.it('fdescribe', function() { env.fdescribe('inner suite', function() {}); });
|
1977
|
+
});
|
1978
|
+
|
1979
|
+
env.describe('spec', function() {
|
1980
|
+
env.it('it', function() { env.it('inner spec', function() {}); });
|
1981
|
+
env.it('xit', function() { env.xit('inner spec', function() {}); });
|
1982
|
+
env.it('fit', function() { env.fit('inner spec', function() {}); });
|
1983
|
+
});
|
1984
|
+
|
1985
|
+
env.describe('beforeAll', function() {
|
1986
|
+
env.beforeAll(function() { env.beforeAll(function() {}); });
|
1987
|
+
env.it('spec', function() {});
|
1988
|
+
});
|
1989
|
+
|
1990
|
+
env.describe('beforeEach', function() {
|
1991
|
+
env.beforeEach(function() { env.beforeEach(function() {}); });
|
1992
|
+
env.it('spec', function() {});
|
1993
|
+
});
|
1994
|
+
|
1995
|
+
env.describe('afterAll', function() {
|
1996
|
+
env.afterAll(function() { env.afterAll(function() {}); });
|
1997
|
+
env.it('spec', function() {});
|
1998
|
+
});
|
1999
|
+
|
2000
|
+
env.describe('afterEach', function() {
|
2001
|
+
env.afterEach(function() { env.afterEach(function() {}); });
|
2002
|
+
env.it('spec', function() {});
|
2003
|
+
});
|
2004
|
+
|
2005
|
+
env.execute();
|
2006
|
+
});
|
1906
2007
|
});
|
@@ -71,7 +71,7 @@ describe("matchersUtil", function() {
|
|
71
71
|
|
72
72
|
it("fails for Arrays whose contents are equivalent, but have differing properties", function() {
|
73
73
|
var one = [1,2,3],
|
74
|
-
|
74
|
+
two = [1,2,3];
|
75
75
|
|
76
76
|
one.foo = 'bar';
|
77
77
|
two.foo = 'baz';
|
@@ -81,7 +81,7 @@ describe("matchersUtil", function() {
|
|
81
81
|
|
82
82
|
it("passes for Arrays with equivalent contents and properties", function() {
|
83
83
|
var one = [1,2,3],
|
84
|
-
|
84
|
+
two = [1,2,3];
|
85
85
|
|
86
86
|
one.foo = 'bar';
|
87
87
|
two.foo = 'bar';
|
@@ -122,7 +122,7 @@ describe("matchersUtil", function() {
|
|
122
122
|
|
123
123
|
it("passes for Objects that are equivalent (with cycles)", function() {
|
124
124
|
var actual = { a: "foo" },
|
125
|
-
|
125
|
+
expected = { a: "foo" };
|
126
126
|
|
127
127
|
actual.b = actual;
|
128
128
|
expected.b = actual;
|
@@ -166,6 +166,16 @@ describe("matchersUtil", function() {
|
|
166
166
|
|
167
167
|
expect(jasmineUnderTest.matchersUtil.equals(a,b)).toBe(true);
|
168
168
|
});
|
169
|
+
|
170
|
+
it("passes for equivalent Promises (GitHub issue #1314)", function() {
|
171
|
+
if (typeof Promise === 'undefined') { return; }
|
172
|
+
|
173
|
+
var p1 = new Promise(function () {}),
|
174
|
+
p2 = new Promise(function () {});
|
175
|
+
|
176
|
+
expect(jasmineUnderTest.matchersUtil.equals(p1, p1)).toBe(true);
|
177
|
+
expect(jasmineUnderTest.matchersUtil.equals(p1, p2)).toBe(false);
|
178
|
+
});
|
169
179
|
|
170
180
|
describe("when running in a browser", function() {
|
171
181
|
function isNotRunningInBrowser() {
|
@@ -332,7 +342,7 @@ describe("matchersUtil", function() {
|
|
332
342
|
|
333
343
|
it("passes for an asymmetric equality tester that returns true when a custom equality tester return false", function() {
|
334
344
|
var asymmetricTester = { asymmetricMatch: function(other) { return true; } },
|
335
|
-
|
345
|
+
symmetricTester = function(a, b) { return false; };
|
336
346
|
|
337
347
|
expect(jasmineUnderTest.matchersUtil.equals(asymmetricTester, true, [symmetricTester])).toBe(true);
|
338
348
|
expect(jasmineUnderTest.matchersUtil.equals(true, asymmetricTester, [symmetricTester])).toBe(true);
|
@@ -350,7 +360,7 @@ describe("matchersUtil", function() {
|
|
350
360
|
|
351
361
|
it("passes when an Any is compared to an Any that checks for the same type", function() {
|
352
362
|
var any1 = new jasmineUnderTest.Any(Function),
|
353
|
-
|
363
|
+
any2 = new jasmineUnderTest.Any(Function);
|
354
364
|
|
355
365
|
expect(jasmineUnderTest.matchersUtil.equals(any1, any2)).toBe(true);
|
356
366
|
});
|
@@ -359,7 +369,7 @@ describe("matchersUtil", function() {
|
|
359
369
|
if (jasmine.getEnv().ieVersion < 9) { return; }
|
360
370
|
|
361
371
|
var objA = Object.create(null),
|
362
|
-
|
372
|
+
objB = Object.create(null);
|
363
373
|
|
364
374
|
objA.name = 'test';
|
365
375
|
objB.name = 'test';
|
@@ -371,7 +381,7 @@ describe("matchersUtil", function() {
|
|
371
381
|
if (jasmine.getEnv().ieVersion < 9) { return; }
|
372
382
|
|
373
383
|
var objA = Object.create(null),
|
374
|
-
|
384
|
+
objB = Object.create(null);
|
375
385
|
|
376
386
|
objA.name = 'test';
|
377
387
|
objB.test = 'name';
|
@@ -386,31 +396,94 @@ describe("matchersUtil", function() {
|
|
386
396
|
|
387
397
|
it("passes when comparing identical sets", function() {
|
388
398
|
jasmine.getEnv().requireFunctioningSets();
|
389
|
-
|
399
|
+
|
400
|
+
var setA = new Set();
|
401
|
+
setA.add(6);
|
402
|
+
setA.add(5);
|
390
403
|
var setB = new Set();
|
391
404
|
setB.add(6);
|
392
405
|
setB.add(5);
|
406
|
+
|
407
|
+
expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(true);
|
408
|
+
});
|
409
|
+
|
410
|
+
it("passes when comparing identical sets with different insertion order and simple elements", function() {
|
411
|
+
jasmine.getEnv().requireFunctioningSets();
|
412
|
+
|
413
|
+
var setA = new Set();
|
414
|
+
setA.add(3);
|
415
|
+
setA.add(6);
|
416
|
+
var setB = new Set();
|
417
|
+
setB.add(6);
|
418
|
+
setB.add(3);
|
419
|
+
|
393
420
|
expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(true);
|
394
421
|
});
|
395
422
|
|
396
|
-
it("passes when comparing identical sets with different insertion order", function() {
|
423
|
+
it("passes when comparing identical sets with different insertion order and complex elements 1", function() {
|
397
424
|
jasmine.getEnv().requireFunctioningSets();
|
398
|
-
|
399
|
-
var
|
425
|
+
|
426
|
+
var setA1 = new Set();
|
427
|
+
setA1.add(['a',3]);
|
428
|
+
setA1.add([6,1]);
|
429
|
+
var setA2 = new Set();
|
430
|
+
setA1.add(['y',3]);
|
431
|
+
setA1.add([6,1]);
|
432
|
+
var setA = new Set();
|
433
|
+
setA.add(setA1);
|
434
|
+
setA.add(setA2);
|
435
|
+
|
436
|
+
|
437
|
+
var setB1 = new Set();
|
438
|
+
setB1.add([6,1]);
|
439
|
+
setB1.add(['a',3]);
|
440
|
+
var setB2 = new Set();
|
441
|
+
setB1.add([6,1]);
|
442
|
+
setB1.add(['y',3]);
|
443
|
+
var setB = new Set();
|
444
|
+
setB.add(setB1);
|
445
|
+
setB.add(setB2);
|
446
|
+
|
447
|
+
expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(true);
|
448
|
+
});
|
449
|
+
|
450
|
+
it("passes when comparing identical sets with different insertion order and complex elements 2", function() {
|
451
|
+
jasmine.getEnv().requireFunctioningSets();
|
452
|
+
|
453
|
+
var setA = new Set();
|
454
|
+
setA.add([[1,2], [3,4]]);
|
455
|
+
setA.add([[5,6], [7,8]]);
|
456
|
+
var setB = new Set();
|
457
|
+
setB.add([[5,6], [7,8]]);
|
458
|
+
setB.add([[1,2], [3,4]]);
|
459
|
+
|
400
460
|
expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(true);
|
401
461
|
});
|
402
462
|
|
403
463
|
it("fails for sets with different elements", function() {
|
404
464
|
jasmine.getEnv().requireFunctioningSets();
|
405
|
-
var setA = new Set(
|
406
|
-
|
465
|
+
var setA = new Set();
|
466
|
+
setA.add(6);
|
467
|
+
setA.add(3);
|
468
|
+
setA.add(5);
|
469
|
+
var setB = new Set();
|
470
|
+
setB.add(6);
|
471
|
+
setB.add(4);
|
472
|
+
setB.add(5);
|
473
|
+
|
407
474
|
expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(false);
|
408
475
|
});
|
409
476
|
|
410
477
|
it("fails for sets of different size", function() {
|
411
478
|
jasmine.getEnv().requireFunctioningSets();
|
412
|
-
var setA = new Set(
|
413
|
-
|
479
|
+
var setA = new Set();
|
480
|
+
setA.add(6);
|
481
|
+
setA.add(3);
|
482
|
+
var setB = new Set();
|
483
|
+
setB.add(6);
|
484
|
+
setB.add(4);
|
485
|
+
setB.add(5);
|
486
|
+
|
414
487
|
expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(false);
|
415
488
|
});
|
416
489
|
|
@@ -421,7 +494,8 @@ describe("matchersUtil", function() {
|
|
421
494
|
|
422
495
|
it("passes when comparing identical maps", function() {
|
423
496
|
jasmine.getEnv().requireFunctioningMaps();
|
424
|
-
var mapA = new Map(
|
497
|
+
var mapA = new Map();
|
498
|
+
mapA.set(6, 5);
|
425
499
|
var mapB = new Map();
|
426
500
|
mapB.set(6, 5);
|
427
501
|
expect(jasmineUnderTest.matchersUtil.equals(mapA, mapB)).toBe(true);
|
@@ -429,22 +503,34 @@ describe("matchersUtil", function() {
|
|
429
503
|
|
430
504
|
it("passes when comparing identical maps with different insertion order", function() {
|
431
505
|
jasmine.getEnv().requireFunctioningMaps();
|
432
|
-
var mapA = new Map(
|
433
|
-
|
506
|
+
var mapA = new Map();
|
507
|
+
mapA.set("a", 3);
|
508
|
+
mapA.set(6, 1);
|
509
|
+
var mapB = new Map();
|
510
|
+
mapB.set(6, 1);
|
511
|
+
mapB.set("a", 3);
|
434
512
|
expect(jasmineUnderTest.matchersUtil.equals(mapA, mapB)).toBe(true);
|
435
513
|
});
|
436
514
|
|
437
515
|
it("fails for maps with different elements", function() {
|
438
516
|
jasmine.getEnv().requireFunctioningMaps();
|
439
|
-
var mapA = new Map(
|
440
|
-
|
517
|
+
var mapA = new Map();
|
518
|
+
mapA.set(6, 3);
|
519
|
+
mapA.set(5, 1);
|
520
|
+
var mapB = new Map();
|
521
|
+
mapB.set(6, 4);
|
522
|
+
mapB.set(5, 1);
|
523
|
+
|
441
524
|
expect(jasmineUnderTest.matchersUtil.equals(mapA, mapB)).toBe(false);
|
442
525
|
});
|
443
526
|
|
444
527
|
it("fails for maps of different size", function() {
|
445
528
|
jasmine.getEnv().requireFunctioningMaps();
|
446
|
-
var mapA = new Map(
|
447
|
-
|
529
|
+
var mapA = new Map();
|
530
|
+
mapA.set(6, 3);
|
531
|
+
var mapB = new Map();
|
532
|
+
mapB.set(6, 4);
|
533
|
+
mapB.set(5, 1);
|
448
534
|
expect(jasmineUnderTest.matchersUtil.equals(mapA, mapB)).toBe(false);
|
449
535
|
});
|
450
536
|
|
@@ -461,28 +547,28 @@ describe("matchersUtil", function() {
|
|
461
547
|
Object.defineProperty(Array.prototype, 'findIndex', {
|
462
548
|
enumerable: true,
|
463
549
|
value: function (predicate) {
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
550
|
+
if (this === null) {
|
551
|
+
throw new TypeError('Array.prototype.findIndex called on null or undefined');
|
552
|
+
}
|
553
|
+
|
554
|
+
if (typeof predicate !== 'function') {
|
555
|
+
throw new TypeError('predicate must be a function');
|
556
|
+
}
|
557
|
+
|
558
|
+
var list = Object(this);
|
559
|
+
var length = list.length >>> 0;
|
560
|
+
var thisArg = arguments[1];
|
561
|
+
var value;
|
562
|
+
|
563
|
+
for (var i = 0; i < length; i++) {
|
564
|
+
value = list[i];
|
565
|
+
if (predicate.call(thisArg, value, i, list)) {
|
566
|
+
return i;
|
567
|
+
}
|
568
|
+
}
|
569
|
+
|
570
|
+
return -1;
|
571
|
+
}
|
486
572
|
});
|
487
573
|
});
|
488
574
|
|
@@ -374,9 +374,11 @@ describe("toEqual", function() {
|
|
374
374
|
it("reports mismatches between Sets", function() {
|
375
375
|
jasmine.getEnv().requireFunctioningSets();
|
376
376
|
|
377
|
-
var actual = new Set(
|
378
|
-
|
379
|
-
|
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 ).';
|
380
382
|
|
381
383
|
expect(compareEquals(actual, expected).message).toEqual(message);
|
382
384
|
});
|
@@ -384,9 +386,11 @@ describe("toEqual", function() {
|
|
384
386
|
it("reports deep mismatches within Sets", function() {
|
385
387
|
jasmine.getEnv().requireFunctioningSets();
|
386
388
|
|
387
|
-
var actual = new Set(
|
388
|
-
|
389
|
-
|
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 }) ).';
|
390
394
|
|
391
395
|
expect(compareEquals(actual, expected).message).toEqual(message);
|
392
396
|
});
|
@@ -394,9 +398,14 @@ describe("toEqual", function() {
|
|
394
398
|
it("reports mismatches between Sets nested in objects", function() {
|
395
399
|
jasmine.getEnv().requireFunctioningSets();
|
396
400
|
|
397
|
-
var
|
398
|
-
|
399
|
-
|
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 ).";
|
400
409
|
|
401
410
|
expect(compareEquals(actual, expected).message).toEqual(message);
|
402
411
|
});
|
@@ -404,9 +413,12 @@ describe("toEqual", function() {
|
|
404
413
|
it("reports mismatches between Sets of different lengths", function() {
|
405
414
|
jasmine.getEnv().requireFunctioningSets();
|
406
415
|
|
407
|
-
var actual = new Set(
|
408
|
-
|
409
|
-
|
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 ).';
|
410
422
|
|
411
423
|
expect(compareEquals(actual, expected).message).toEqual(message);
|
412
424
|
});
|
@@ -415,9 +427,13 @@ describe("toEqual", function() {
|
|
415
427
|
jasmine.getEnv().requireFunctioningSets();
|
416
428
|
|
417
429
|
// Use 'duplicate' object in actual so sizes match
|
418
|
-
var actual = new Set(
|
419
|
-
|
420
|
-
|
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 }) ).';
|
421
437
|
|
422
438
|
expect(compareEquals(actual, expected).message).toEqual(message);
|
423
439
|
});
|
@@ -426,9 +442,13 @@ describe("toEqual", function() {
|
|
426
442
|
jasmine.getEnv().requireFunctioningSets();
|
427
443
|
|
428
444
|
// Use 'duplicate' object in expected so sizes match
|
429
|
-
var actual = new Set(
|
430
|
-
|
431
|
-
|
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 }) ).';
|
432
452
|
|
433
453
|
expect(compareEquals(actual, expected).message).toEqual(message);
|
434
454
|
});
|
@@ -436,11 +456,13 @@ describe("toEqual", function() {
|
|
436
456
|
// == Maps ==
|
437
457
|
|
438
458
|
it("does not report mismatches between deep equal Maps", function() {
|
439
|
-
jasmine.getEnv().
|
459
|
+
jasmine.getEnv().requireFunctioningMaps();
|
440
460
|
|
441
461
|
// values are the same but with different object identity
|
442
|
-
var actual = new Map(
|
443
|
-
|
462
|
+
var actual = new Map();
|
463
|
+
actual.set('a',{x:1});
|
464
|
+
var expected = new Map();
|
465
|
+
expected.set('a',{x:1});
|
444
466
|
|
445
467
|
expect(compareEquals(actual, expected).pass).toBe(true);
|
446
468
|
});
|
@@ -448,9 +470,11 @@ describe("toEqual", function() {
|
|
448
470
|
it("reports deep mismatches within Maps", function() {
|
449
471
|
jasmine.getEnv().requireFunctioningMaps();
|
450
472
|
|
451
|
-
var actual = new Map(
|
452
|
-
|
453
|
-
|
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 }) ] ).";
|
454
478
|
|
455
479
|
expect(compareEquals(actual, expected).message).toEqual(message);
|
456
480
|
});
|
@@ -458,9 +482,12 @@ describe("toEqual", function() {
|
|
458
482
|
it("reports mismatches between Maps nested in objects", function() {
|
459
483
|
jasmine.getEnv().requireFunctioningMaps();
|
460
484
|
|
461
|
-
var actual = {Maps:
|
462
|
-
|
463
|
-
|
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 ] ).";
|
464
491
|
|
465
492
|
expect(compareEquals(actual, expected).message).toEqual(message);
|
466
493
|
});
|
@@ -468,9 +495,12 @@ describe("toEqual", function() {
|
|
468
495
|
it("reports mismatches between Maps of different lengths", function() {
|
469
496
|
jasmine.getEnv().requireFunctioningMaps();
|
470
497
|
|
471
|
-
var actual = new Map(
|
472
|
-
|
473
|
-
|
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 ] ).";
|
474
504
|
|
475
505
|
expect(compareEquals(actual, expected).message).toEqual(message);
|
476
506
|
});
|
@@ -478,18 +508,22 @@ describe("toEqual", function() {
|
|
478
508
|
it("reports mismatches between Maps with equal values but differing keys", function() {
|
479
509
|
jasmine.getEnv().requireFunctioningMaps();
|
480
510
|
|
481
|
-
var actual = new Map(
|
482
|
-
|
483
|
-
|
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 ] ).";
|
484
516
|
|
485
517
|
expect(compareEquals(actual, expected).message).toEqual(message);
|
486
518
|
});
|
487
519
|
|
488
520
|
it("does not report mismatches between Maps with keys with same object identity", function() {
|
489
521
|
jasmine.getEnv().requireFunctioningMaps();
|
490
|
-
var key = {x: 1}
|
491
|
-
|
492
|
-
|
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);
|
493
527
|
|
494
528
|
expect(compareEquals(actual, expected).pass).toBe(true);
|
495
529
|
});
|
@@ -497,13 +531,64 @@ describe("toEqual", function() {
|
|
497
531
|
it("reports mismatches between Maps with identical keys with different object identity", function() {
|
498
532
|
jasmine.getEnv().requireFunctioningMaps();
|
499
533
|
|
500
|
-
var actual = new Map(
|
501
|
-
|
502
|
-
|
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 ] ).";
|
503
539
|
|
504
540
|
expect(compareEquals(actual, expected).message).toEqual(message);
|
505
541
|
});
|
506
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
|
+
|
507
592
|
function isNotRunningInBrowser() {
|
508
593
|
return typeof document === 'undefined'
|
509
594
|
}
|