jasmine-core 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jasmine-core/boot.js +6 -6
- data/lib/jasmine-core/boot/boot.js +6 -6
- data/lib/jasmine-core/example/spec/SpecHelper.js +1 -1
- data/lib/jasmine-core/jasmine-html.js +43 -13
- data/lib/jasmine-core/jasmine.css +6 -3
- data/lib/jasmine-core/jasmine.js +399 -149
- data/lib/jasmine-core/spec/core/ClockSpec.js +214 -22
- data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +0 -41
- data/lib/jasmine-core/spec/core/EnvSpec.js +20 -0
- data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +57 -27
- data/lib/jasmine-core/spec/core/SpecSpec.js +140 -1
- data/lib/jasmine-core/spec/core/SuiteSpec.js +47 -244
- data/lib/jasmine-core/spec/core/TreeProcessorSpec.js +633 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +2 -3
- data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +31 -0
- data/lib/jasmine-core/spec/core/integration/EnvSpec.js +35 -6
- data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +108 -15
- data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +27 -0
- data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +0 -2
- data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +115 -1
- data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +2 -5
- data/lib/jasmine-core/version.rb +1 -1
- metadata +96 -95
@@ -22,7 +22,7 @@ describe("Any", function() {
|
|
22
22
|
|
23
23
|
expect(any.asymmetricMatch({})).toBe(true);
|
24
24
|
});
|
25
|
-
|
25
|
+
|
26
26
|
it("matches a Boolean", function() {
|
27
27
|
var any = new j$.Any(Boolean);
|
28
28
|
|
@@ -39,8 +39,7 @@ describe("Any", function() {
|
|
39
39
|
it("jasmineToString's itself", function() {
|
40
40
|
var any = new j$.Any(Number);
|
41
41
|
|
42
|
-
expect(any.jasmineToString()).
|
43
|
-
expect(any.jasmineToString()).toMatch('Number');
|
42
|
+
expect(any.jasmineToString()).toEqual('<jasmine.any(Number)>');
|
44
43
|
});
|
45
44
|
|
46
45
|
});
|
@@ -55,4 +55,35 @@ describe("ObjectContaining", function() {
|
|
55
55
|
|
56
56
|
expect(containing.asymmetricMatch({})).toBe(false);
|
57
57
|
});
|
58
|
+
|
59
|
+
it("matches defined properties", function(){
|
60
|
+
// IE 8 doesn't support `definePropery` on non-DOM nodes
|
61
|
+
if (jasmine.getEnv().ieVersion < 9) { return; }
|
62
|
+
|
63
|
+
var containing = new j$.ObjectContaining({ foo: "fooVal" });
|
64
|
+
|
65
|
+
var definedPropertyObject = {};
|
66
|
+
Object.defineProperty(definedPropertyObject, "foo", {
|
67
|
+
get: function() { return "fooVal" }
|
68
|
+
});
|
69
|
+
expect(containing.asymmetricMatch(definedPropertyObject)).toBe(true);
|
70
|
+
});
|
71
|
+
|
72
|
+
it("matches prototype properties", function(){
|
73
|
+
var containing = new j$.ObjectContaining({ foo: "fooVal" });
|
74
|
+
|
75
|
+
var prototypeObject = {foo: "fooVal"};
|
76
|
+
var obj;
|
77
|
+
|
78
|
+
if (Object.create) {
|
79
|
+
obj = Object.create(prototypeObject);
|
80
|
+
} else {
|
81
|
+
function Foo() {}
|
82
|
+
Foo.prototype = prototypeObject;
|
83
|
+
Foo.prototype.constructor = Foo;
|
84
|
+
obj = new Foo();
|
85
|
+
}
|
86
|
+
|
87
|
+
expect(containing.asymmetricMatch(obj)).toBe(true);
|
88
|
+
});
|
58
89
|
});
|
@@ -612,8 +612,6 @@ describe("Env integration", function() {
|
|
612
612
|
expect(calls).toEqual([
|
613
613
|
"before",
|
614
614
|
"first spec",
|
615
|
-
"after",
|
616
|
-
"before",
|
617
615
|
"second spec",
|
618
616
|
"after"
|
619
617
|
]);
|
@@ -861,6 +859,36 @@ describe("Env integration", function() {
|
|
861
859
|
env.execute();
|
862
860
|
});
|
863
861
|
|
862
|
+
it("should not use the mock clock for asynchronous timeouts", function(){
|
863
|
+
var env = new j$.Env(),
|
864
|
+
reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone" ]),
|
865
|
+
clock = env.clock;
|
866
|
+
|
867
|
+
reporter.jasmineDone.and.callFake(function() {
|
868
|
+
expect(reporter.specDone.calls.count()).toEqual(1);
|
869
|
+
expect(reporter.specDone.calls.argsFor(0)[0]).toEqual(jasmine.objectContaining({status: 'passed'}));
|
870
|
+
});
|
871
|
+
|
872
|
+
env.addReporter(reporter);
|
873
|
+
j$.DEFAULT_TIMEOUT_INTERVAL = 5;
|
874
|
+
|
875
|
+
env.beforeAll(function() {
|
876
|
+
clock.install();
|
877
|
+
});
|
878
|
+
|
879
|
+
env.afterAll(function() {
|
880
|
+
clock.uninstall();
|
881
|
+
});
|
882
|
+
|
883
|
+
env.it("spec that should not time out", function(done) {
|
884
|
+
clock.tick(6);
|
885
|
+
expect(true).toEqual(true);
|
886
|
+
done();
|
887
|
+
});
|
888
|
+
|
889
|
+
env.execute();
|
890
|
+
});
|
891
|
+
|
864
892
|
it("should wait the specified interval before reporting an afterAll that fails to call done", function(done) {
|
865
893
|
var env = new j$.Env(),
|
866
894
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
|
@@ -971,9 +999,6 @@ describe("Env integration", function() {
|
|
971
999
|
|
972
1000
|
env.addReporter({
|
973
1001
|
specDone: specDone,
|
974
|
-
specStarted: function() {
|
975
|
-
jasmine.clock().tick(1);
|
976
|
-
},
|
977
1002
|
jasmineDone: function() {
|
978
1003
|
expect(specDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
979
1004
|
description: 'has a default message',
|
@@ -1033,6 +1058,10 @@ describe("Env integration", function() {
|
|
1033
1058
|
});
|
1034
1059
|
|
1035
1060
|
env.execute();
|
1061
|
+
jasmine.clock().tick(1);
|
1062
|
+
jasmine.clock().tick(1);
|
1063
|
+
jasmine.clock().tick(1);
|
1064
|
+
jasmine.clock().tick(1);
|
1036
1065
|
});
|
1037
1066
|
});
|
1038
1067
|
|
@@ -1177,7 +1206,7 @@ describe("Env integration", function() {
|
|
1177
1206
|
totalSpecsDefined: 1
|
1178
1207
|
});
|
1179
1208
|
|
1180
|
-
expect(reporter.specDone).
|
1209
|
+
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({ status: 'disabled' }));
|
1181
1210
|
expect(reporter.suiteDone.calls.count()).toBe(3);
|
1182
1211
|
|
1183
1212
|
done();
|
@@ -1,6 +1,5 @@
|
|
1
1
|
describe("jasmine spec running", function () {
|
2
2
|
var env;
|
3
|
-
var fakeTimer;
|
4
3
|
|
5
4
|
beforeEach(function() {
|
6
5
|
env = new j$.Env();
|
@@ -61,13 +60,17 @@ describe("jasmine spec running", function () {
|
|
61
60
|
expect(bar).toEqual(0);
|
62
61
|
expect(baz).toEqual(0);
|
63
62
|
expect(quux).toEqual(0);
|
64
|
-
|
63
|
+
var assertions = function() {
|
65
64
|
expect(foo).toEqual(1);
|
66
65
|
expect(bar).toEqual(1);
|
67
66
|
expect(baz).toEqual(1);
|
68
67
|
expect(quux).toEqual(1);
|
69
68
|
done();
|
70
|
-
}
|
69
|
+
};
|
70
|
+
|
71
|
+
env.addReporter({ jasmineDone: assertions });
|
72
|
+
|
73
|
+
env.execute();
|
71
74
|
});
|
72
75
|
|
73
76
|
it("should permit nested describes", function(done) {
|
@@ -289,7 +292,7 @@ describe("jasmine spec running", function () {
|
|
289
292
|
env.execute();
|
290
293
|
});
|
291
294
|
|
292
|
-
it('should run beforeAlls and afterAlls
|
295
|
+
it('should run beforeAlls and afterAlls in the order declared when runnablesToRun is provided', function(done) {
|
293
296
|
var actions = [],
|
294
297
|
spec,
|
295
298
|
spec2;
|
@@ -342,17 +345,13 @@ describe("jasmine spec running", function () {
|
|
342
345
|
"inner beforeAll",
|
343
346
|
"runner beforeEach",
|
344
347
|
"inner beforeEach",
|
345
|
-
"
|
348
|
+
"it2",
|
346
349
|
"inner afterEach",
|
347
350
|
"runner afterEach",
|
348
|
-
"inner afterAll",
|
349
|
-
"runner afterAll",
|
350
351
|
|
351
|
-
"runner beforeAll",
|
352
|
-
"inner beforeAll",
|
353
352
|
"runner beforeEach",
|
354
353
|
"inner beforeEach",
|
355
|
-
"
|
354
|
+
"it",
|
356
355
|
"inner afterEach",
|
357
356
|
"runner afterEach",
|
358
357
|
"inner afterAll",
|
@@ -363,7 +362,7 @@ describe("jasmine spec running", function () {
|
|
363
362
|
};
|
364
363
|
|
365
364
|
env.addReporter({jasmineDone: assertions});
|
366
|
-
env.execute([
|
365
|
+
env.execute([spec2.id, spec.id]);
|
367
366
|
});
|
368
367
|
|
369
368
|
it('only runs *Alls once in a focused suite', function(done){
|
@@ -416,9 +415,7 @@ describe("jasmine spec running", function () {
|
|
416
415
|
'beforeEach',
|
417
416
|
'spec in fdescribe',
|
418
417
|
'afterEach',
|
419
|
-
'afterAll',
|
420
418
|
|
421
|
-
'beforeAll',
|
422
419
|
'beforeEach',
|
423
420
|
'focused spec',
|
424
421
|
'afterEach',
|
@@ -549,10 +546,14 @@ describe("jasmine spec running", function () {
|
|
549
546
|
pendingSpec = env.it("I am a pending spec");
|
550
547
|
});
|
551
548
|
|
552
|
-
|
549
|
+
var assertions = function() {
|
553
550
|
expect(pendingSpec.status()).toBe("pending");
|
554
551
|
done();
|
555
|
-
}
|
552
|
+
};
|
553
|
+
|
554
|
+
env.addReporter({jasmineDone: assertions});
|
555
|
+
|
556
|
+
env.execute();
|
556
557
|
});
|
557
558
|
|
558
559
|
// TODO: is this useful? It doesn't catch syntax errors
|
@@ -603,4 +604,96 @@ describe("jasmine spec running", function () {
|
|
603
604
|
));
|
604
605
|
|
605
606
|
});
|
607
|
+
|
608
|
+
it("re-enters suites that have no *Alls", function(done) {
|
609
|
+
var actions = [],
|
610
|
+
spec1, spec2, spec3;
|
611
|
+
|
612
|
+
env.describe("top", function() {
|
613
|
+
spec1 = env.it("spec1", function() {
|
614
|
+
actions.push("spec1");
|
615
|
+
});
|
616
|
+
|
617
|
+
spec2 = env.it("spec2", function() {
|
618
|
+
actions.push("spec2");
|
619
|
+
});
|
620
|
+
});
|
621
|
+
|
622
|
+
spec3 = env.it("spec3", function() {
|
623
|
+
actions.push("spec3");
|
624
|
+
});
|
625
|
+
|
626
|
+
env.addReporter({
|
627
|
+
jasmineDone: function() {
|
628
|
+
expect(actions).toEqual(["spec2", "spec3", "spec1"]);
|
629
|
+
done();
|
630
|
+
}
|
631
|
+
});
|
632
|
+
|
633
|
+
env.execute([spec2.id, spec3.id, spec1.id]);
|
634
|
+
});
|
635
|
+
|
636
|
+
it("refuses to re-enter suites with a beforeAll", function() {
|
637
|
+
var actions = [],
|
638
|
+
spec1, spec2, spec3;
|
639
|
+
|
640
|
+
env.describe("top", function() {
|
641
|
+
env.beforeAll(function() {});
|
642
|
+
|
643
|
+
spec1 = env.it("spec1", function() {
|
644
|
+
actions.push("spec1");
|
645
|
+
});
|
646
|
+
|
647
|
+
spec2 = env.it("spec2", function() {
|
648
|
+
actions.push("spec2");
|
649
|
+
});
|
650
|
+
});
|
651
|
+
|
652
|
+
spec3 = env.it("spec3", function() {
|
653
|
+
actions.push("spec3");
|
654
|
+
});
|
655
|
+
|
656
|
+
env.addReporter({
|
657
|
+
jasmineDone: function() {
|
658
|
+
expect(actions).toEqual([]);
|
659
|
+
done();
|
660
|
+
}
|
661
|
+
});
|
662
|
+
|
663
|
+
expect(function() {
|
664
|
+
env.execute([spec2.id, spec3.id, spec1.id]);
|
665
|
+
}).toThrowError(/beforeAll/);
|
666
|
+
});
|
667
|
+
|
668
|
+
it("refuses to re-enter suites with a afterAll", function() {
|
669
|
+
var actions = [],
|
670
|
+
spec1, spec2, spec3;
|
671
|
+
|
672
|
+
env.describe("top", function() {
|
673
|
+
env.afterAll(function() {});
|
674
|
+
|
675
|
+
spec1 = env.it("spec1", function() {
|
676
|
+
actions.push("spec1");
|
677
|
+
});
|
678
|
+
|
679
|
+
spec2 = env.it("spec2", function() {
|
680
|
+
actions.push("spec2");
|
681
|
+
});
|
682
|
+
});
|
683
|
+
|
684
|
+
spec3 = env.it("spec3", function() {
|
685
|
+
actions.push("spec3");
|
686
|
+
});
|
687
|
+
|
688
|
+
env.addReporter({
|
689
|
+
jasmineDone: function() {
|
690
|
+
expect(actions).toEqual([]);
|
691
|
+
done();
|
692
|
+
}
|
693
|
+
});
|
694
|
+
|
695
|
+
expect(function() {
|
696
|
+
env.execute([spec2.id, spec3.id, spec1.id]);
|
697
|
+
}).toThrowError(/afterAll/);
|
698
|
+
});
|
606
699
|
});
|
@@ -171,6 +171,33 @@ describe("matchersUtil", function() {
|
|
171
171
|
expect(j$.matchersUtil.equals(a,b)).toBe(true);
|
172
172
|
});
|
173
173
|
|
174
|
+
it("passes for equivalent objects from different vm contexts", function() {
|
175
|
+
if (typeof require !== 'function') {
|
176
|
+
return;
|
177
|
+
}
|
178
|
+
var vm = require('vm');
|
179
|
+
var sandbox = {
|
180
|
+
obj: null
|
181
|
+
};
|
182
|
+
vm.runInNewContext('obj = {a: 1, b: 2}', sandbox);
|
183
|
+
|
184
|
+
expect(j$.matchersUtil.equals(sandbox.obj, {a: 1, b: 2})).toBe(true);
|
185
|
+
});
|
186
|
+
|
187
|
+
it("passes for equivalent arrays from different vm contexts", function() {
|
188
|
+
if (typeof require !== 'function') {
|
189
|
+
return;
|
190
|
+
}
|
191
|
+
|
192
|
+
var vm = require('vm');
|
193
|
+
var sandbox = {
|
194
|
+
arr: null
|
195
|
+
};
|
196
|
+
vm.runInNewContext('arr = [1, 2]', sandbox);
|
197
|
+
|
198
|
+
expect(j$.matchersUtil.equals(sandbox.arr, [1, 2])).toBe(true);
|
199
|
+
});
|
200
|
+
|
174
201
|
it("passes when Any is used", function() {
|
175
202
|
var number = 3,
|
176
203
|
anyNumber = new j$.Any(Number);
|
@@ -170,7 +170,6 @@ describe("toThrowError", function() {
|
|
170
170
|
result;
|
171
171
|
|
172
172
|
CustomError.prototype = new Error();
|
173
|
-
CustomError.prototype.constructor = CustomError;
|
174
173
|
|
175
174
|
result = matcher.compare(fn, CustomError);
|
176
175
|
|
@@ -222,7 +221,6 @@ describe("toThrowError", function() {
|
|
222
221
|
result;
|
223
222
|
|
224
223
|
CustomError.prototype = new Error();
|
225
|
-
CustomError.prototype.constructor = CustomError;
|
226
224
|
|
227
225
|
result = matcher.compare(fn, CustomError, "foo");
|
228
226
|
|
@@ -266,7 +266,7 @@ describe("New HtmlReporter", function() {
|
|
266
266
|
timer.elapsed.and.returnValue(100);
|
267
267
|
reporter.jasmineDone();
|
268
268
|
|
269
|
-
var duration = container.querySelector(".
|
269
|
+
var duration = container.querySelector(".alert .duration");
|
270
270
|
expect(duration.innerHTML).toMatch(/finished in 0.1s/);
|
271
271
|
});
|
272
272
|
|
@@ -364,6 +364,40 @@ describe("New HtmlReporter", function() {
|
|
364
364
|
// expect(specLink.getAttribute("title")).toEqual("A Suite with a spec");
|
365
365
|
});
|
366
366
|
|
367
|
+
it("has an options menu", function() {
|
368
|
+
var env = new j$.Env(),
|
369
|
+
container = document.createElement("div"),
|
370
|
+
getContainer = function() {
|
371
|
+
return container;
|
372
|
+
},
|
373
|
+
reporter = new j$.HtmlReporter({
|
374
|
+
env: env,
|
375
|
+
getContainer: getContainer,
|
376
|
+
createElement: function() {
|
377
|
+
return document.createElement.apply(document, arguments);
|
378
|
+
},
|
379
|
+
createTextNode: function() {
|
380
|
+
return document.createTextNode.apply(document, arguments);
|
381
|
+
}
|
382
|
+
});
|
383
|
+
|
384
|
+
reporter.initialize();
|
385
|
+
reporter.jasmineDone({});
|
386
|
+
|
387
|
+
var trigger = container.querySelector('.run-options .trigger'),
|
388
|
+
payload = container.querySelector('.run-options .payload');
|
389
|
+
|
390
|
+
expect(payload.className).not.toContain('open');
|
391
|
+
|
392
|
+
trigger.onclick();
|
393
|
+
|
394
|
+
expect(payload.className).toContain('open');
|
395
|
+
|
396
|
+
trigger.onclick();
|
397
|
+
|
398
|
+
expect(payload.className).not.toContain('open');
|
399
|
+
});
|
400
|
+
|
367
401
|
describe("UI for raising/catching exceptions", function() {
|
368
402
|
it("should be unchecked if the env is catching", function() {
|
369
403
|
var env = new j$.Env(),
|
@@ -442,6 +476,86 @@ describe("New HtmlReporter", function() {
|
|
442
476
|
});
|
443
477
|
});
|
444
478
|
|
479
|
+
describe("UI for throwing errors on expectation failures", function() {
|
480
|
+
it("should be unchecked if not throwing", function() {
|
481
|
+
var env = new j$.Env(),
|
482
|
+
container = document.createElement("div"),
|
483
|
+
getContainer = function() {
|
484
|
+
return container;
|
485
|
+
},
|
486
|
+
reporter = new j$.HtmlReporter({
|
487
|
+
env: env,
|
488
|
+
getContainer: getContainer,
|
489
|
+
createElement: function() {
|
490
|
+
return document.createElement.apply(document, arguments);
|
491
|
+
},
|
492
|
+
createTextNode: function() {
|
493
|
+
return document.createTextNode.apply(document, arguments);
|
494
|
+
}
|
495
|
+
});
|
496
|
+
|
497
|
+
reporter.initialize();
|
498
|
+
reporter.jasmineDone({});
|
499
|
+
|
500
|
+
var throwingExpectationsUI = container.querySelector(".throw");
|
501
|
+
expect(throwingExpectationsUI.checked).toBe(false);
|
502
|
+
});
|
503
|
+
|
504
|
+
it("should be checked if throwing", function() {
|
505
|
+
var env = new j$.Env(),
|
506
|
+
container = document.createElement("div"),
|
507
|
+
getContainer = function() {
|
508
|
+
return container;
|
509
|
+
},
|
510
|
+
reporter = new j$.HtmlReporter({
|
511
|
+
env: env,
|
512
|
+
getContainer: getContainer,
|
513
|
+
createElement: function() {
|
514
|
+
return document.createElement.apply(document, arguments);
|
515
|
+
},
|
516
|
+
createTextNode: function() {
|
517
|
+
return document.createTextNode.apply(document, arguments);
|
518
|
+
}
|
519
|
+
});
|
520
|
+
|
521
|
+
env.throwOnExpectationFailure(true);
|
522
|
+
|
523
|
+
reporter.initialize();
|
524
|
+
reporter.jasmineDone({});
|
525
|
+
|
526
|
+
var throwingExpectationsUI = container.querySelector(".throw");
|
527
|
+
expect(throwingExpectationsUI.checked).toBe(true);
|
528
|
+
});
|
529
|
+
|
530
|
+
it("should affect the query param for throw expectation failures", function() {
|
531
|
+
var env = new j$.Env(),
|
532
|
+
container = document.createElement("div"),
|
533
|
+
throwingExceptionHandler = jasmine.createSpy('throwingExceptions'),
|
534
|
+
getContainer = function() {
|
535
|
+
return container;
|
536
|
+
},
|
537
|
+
reporter = new j$.HtmlReporter({
|
538
|
+
env: env,
|
539
|
+
getContainer: getContainer,
|
540
|
+
onThrowExpectationsClick: throwingExceptionHandler,
|
541
|
+
createElement: function() {
|
542
|
+
return document.createElement.apply(document, arguments);
|
543
|
+
},
|
544
|
+
createTextNode: function() {
|
545
|
+
return document.createTextNode.apply(document, arguments);
|
546
|
+
}
|
547
|
+
});
|
548
|
+
|
549
|
+
reporter.initialize();
|
550
|
+
reporter.jasmineDone({});
|
551
|
+
|
552
|
+
var throwingExpectationsUI = container.querySelector(".throw");
|
553
|
+
throwingExpectationsUI.click();
|
554
|
+
|
555
|
+
expect(throwingExceptionHandler).toHaveBeenCalled();
|
556
|
+
});
|
557
|
+
});
|
558
|
+
|
445
559
|
it("shows a message if no specs are run", function(){
|
446
560
|
var env, container, reporter;
|
447
561
|
env = new j$.Env();
|