jasmine-core 2.5.2 → 2.6.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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/lib/console/console.js +1 -1
  3. data/lib/jasmine-core/boot/boot.js +4 -1
  4. data/lib/jasmine-core/boot.js +5 -2
  5. data/lib/jasmine-core/jasmine-html.js +19 -1
  6. data/lib/jasmine-core/jasmine.js +2859 -1571
  7. data/lib/jasmine-core/node_boot.js +1 -1
  8. data/lib/jasmine-core/spec/core/ClearStackSpec.js +67 -0
  9. data/lib/jasmine-core/spec/core/EnvSpec.js +100 -10
  10. data/lib/jasmine-core/spec/core/ExpectationSpec.js +52 -7
  11. data/lib/jasmine-core/spec/core/GlobalErrorsSpec.js +94 -0
  12. data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +37 -1
  13. data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +37 -0
  14. data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +183 -0
  15. data/lib/jasmine-core/spec/core/SpySpec.js +44 -2
  16. data/lib/jasmine-core/spec/core/SuiteSpec.js +3 -18
  17. data/lib/jasmine-core/spec/core/UtilSpec.js +71 -0
  18. data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js +13 -0
  19. data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +13 -0
  20. data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +47 -0
  21. data/lib/jasmine-core/spec/core/integration/EnvSpec.js +85 -14
  22. data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +45 -3
  23. data/lib/jasmine-core/spec/core/matchers/DiffBuilderSpec.js +47 -0
  24. data/lib/jasmine-core/spec/core/matchers/NullDiffBuilderSpec.js +13 -0
  25. data/lib/jasmine-core/spec/core/matchers/ObjectPathSpec.js +43 -0
  26. data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +57 -1
  27. data/lib/jasmine-core/spec/core/matchers/toBeNegativeInfinitySpec.js +31 -0
  28. data/lib/jasmine-core/spec/core/matchers/toBePositiveInfinitySpec.js +31 -0
  29. data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +492 -4
  30. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledBeforeSpec.js +99 -0
  31. data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +37 -0
  32. data/lib/jasmine-core/spec/helpers/BrowserFlags.js +4 -0
  33. data/lib/jasmine-core/spec/helpers/checkForSet.js +21 -0
  34. data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +58 -0
  35. data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +1 -1
  36. data/lib/jasmine-core/version.rb +1 -1
  37. metadata +11 -4
@@ -172,6 +172,22 @@ describe("jasmine spec running", function () {
172
172
  it("should run multiple befores and afters ordered so functions declared later are treated as more specific", function(done) {
173
173
  var actions = [];
174
174
 
175
+ env.beforeAll(function() {
176
+ actions.push('runner beforeAll1');
177
+ });
178
+
179
+ env.afterAll(function() {
180
+ actions.push('runner afterAll1');
181
+ });
182
+
183
+ env.beforeAll(function() {
184
+ actions.push('runner beforeAll2');
185
+ });
186
+
187
+ env.afterAll(function() {
188
+ actions.push('runner afterAll2');
189
+ });
190
+
175
191
  env.beforeEach(function () {
176
192
  actions.push('runner beforeEach1');
177
193
  });
@@ -212,6 +228,8 @@ describe("jasmine spec running", function () {
212
228
 
213
229
  var assertions = function() {
214
230
  var expected = [
231
+ "runner beforeAll1",
232
+ "runner beforeAll2",
215
233
  "runner beforeEach1",
216
234
  "runner beforeEach2",
217
235
  "beforeEach1",
@@ -220,7 +238,9 @@ describe("jasmine spec running", function () {
220
238
  "afterEach2",
221
239
  "afterEach1",
222
240
  "runner afterEach2",
223
- "runner afterEach1"
241
+ "runner afterEach1",
242
+ "runner afterAll2",
243
+ "runner afterAll1"
224
244
  ];
225
245
  expect(actions).toEqual(expected);
226
246
  done();
@@ -475,7 +495,7 @@ describe("jasmine spec running", function () {
475
495
  env.execute();
476
496
  });
477
497
 
478
- it('focused runnables unfocus ancestor focused suites', function() {
498
+ it('focused runnables unfocus ancestor focused suites', function(done) {
479
499
  var actions = [];
480
500
 
481
501
  env.fdescribe('focused suite', function() {
@@ -518,7 +538,29 @@ describe("jasmine spec running", function () {
518
538
  env.execute();
519
539
  });
520
540
 
521
- it("should allow top level suites to be disabled", function() {
541
+ it("shouldn't run before/after functions in disabled suites", function(done) {
542
+ var shouldNotRun = jasmine.createSpy("shouldNotRun"),
543
+ suite = env.xdescribe('A disabled Suite', function() {
544
+ // None of the before/after functions should run.
545
+ env.beforeAll(shouldNotRun);
546
+ env.beforeEach(shouldNotRun);
547
+ env.afterEach(shouldNotRun);
548
+ env.afterAll(shouldNotRun);
549
+
550
+ env.it('spec inside a disabled suite', shouldNotRun);
551
+ });
552
+
553
+ var assertions = function() {
554
+ expect(shouldNotRun).not.toHaveBeenCalled();
555
+ done();
556
+ };
557
+
558
+ env.addReporter({jasmineDone: assertions});
559
+
560
+ env.execute();
561
+ });
562
+
563
+ it("should allow top level suites to be disabled", function(done) {
522
564
  var specInADisabledSuite = jasmine.createSpy("specInADisabledSuite"),
523
565
  otherSpec = jasmine.createSpy("otherSpec");
524
566
 
@@ -0,0 +1,47 @@
1
+ describe("DiffBuilder", function() {
2
+ it("records the actual and expected objects", function() {
3
+ var diffBuilder = jasmineUnderTest.DiffBuilder();
4
+ diffBuilder.record({x: 'actual'}, {x: 'expected'});
5
+
6
+ expect(diffBuilder.getMessage()).toEqual("Expected Object({ x: 'actual' }) to equal Object({ x: 'expected' }).");
7
+ });
8
+
9
+ it("prints the path at which the difference was found", function() {
10
+ var diffBuilder = jasmineUnderTest.DiffBuilder();
11
+
12
+ diffBuilder.withPath('foo', function() {
13
+ diffBuilder.record({x: 'actual'}, {x: 'expected'});
14
+ });
15
+
16
+ expect(diffBuilder.getMessage()).toEqual("Expected $.foo = Object({ x: 'actual' }) to equal Object({ x: 'expected' }).");
17
+ });
18
+
19
+ it("prints multiple messages, separated by newlines", function() {
20
+ var diffBuilder = jasmineUnderTest.DiffBuilder();
21
+
22
+ diffBuilder.withPath('foo', function() {
23
+ diffBuilder.record(1, 2);
24
+ });
25
+
26
+ var message =
27
+ "Expected $.foo = 1 to equal 2.\n" +
28
+ "Expected 3 to equal 4.";
29
+
30
+ diffBuilder.record(3, 4);
31
+ expect(diffBuilder.getMessage()).toEqual(message);
32
+ });
33
+
34
+ it("allows customization of the message", function() {
35
+ var diffBuilder = jasmineUnderTest.DiffBuilder();
36
+
37
+ function darthVaderFormatter(actual, expected, path) {
38
+ return "I find your lack of " + expected + " disturbing. (was " + actual + ", at " + path + ")"
39
+ }
40
+
41
+ diffBuilder.withPath('x', function() {
42
+ diffBuilder.record('bar', 'foo', darthVaderFormatter);
43
+ });
44
+
45
+ expect(diffBuilder.getMessage()).toEqual("I find your lack of foo disturbing. (was bar, at $.x)");
46
+ });
47
+ });
@@ -0,0 +1,13 @@
1
+ describe('NullDiffBuilder', function() {
2
+ it('responds to withPath() by calling the passed function', function() {
3
+ var spy = jasmine.createSpy('callback');
4
+ jasmineUnderTest.NullDiffBuilder().withPath('does not matter', spy);
5
+ expect(spy).toHaveBeenCalled();
6
+ });
7
+
8
+ it('responds to record()', function() {
9
+ expect(function() {
10
+ jasmineUnderTest.NullDiffBuilder().record('does not matter');
11
+ }).not.toThrow();
12
+ })
13
+ });
@@ -0,0 +1,43 @@
1
+ describe('ObjectPath', function() {
2
+ var ObjectPath = jasmineUnderTest.ObjectPath;
3
+
4
+ it('represents the path to a node in an object tree', function() {
5
+ expect(new ObjectPath(['foo', 'bar']).toString()).toEqual('$.foo.bar');
6
+ });
7
+
8
+ it('has a depth', function() {
9
+ expect(new ObjectPath().depth()).toEqual(0);
10
+ expect(new ObjectPath(['foo']).depth()).toEqual(1);
11
+ });
12
+
13
+ it('renders numbers as array access', function() {
14
+ expect(new ObjectPath(['foo', 0]).toString()).toEqual('$.foo[0]');
15
+ });
16
+
17
+ it('renders properties that are valid identifiers with dot notation', function() {
18
+ expect(new ObjectPath(['foo123']).toString()).toEqual('$.foo123');
19
+ expect(new ObjectPath(['x_y']).toString()).toEqual('$.x_y');
20
+ expect(new ObjectPath(['A$B']).toString()).toEqual('$.A$B');
21
+ });
22
+
23
+ it('renders properties with non-identifier-safe characters with square bracket notation', function() {
24
+ expect(new ObjectPath(['a b c']).toString()).toEqual("$['a b c']");
25
+ expect(new ObjectPath(['1hello']).toString()).toEqual("$['1hello']");
26
+ });
27
+
28
+ it('renders as the empty string when empty', function() {
29
+ expect(new ObjectPath().toString()).toEqual('');
30
+ });
31
+
32
+ it('stringifies properties that are not strings or numbers', function() {
33
+ expect(new ObjectPath([{}]).toString()).toEqual("$['[object Object]']");
34
+ });
35
+
36
+ it('can be created based on another path', function() {
37
+ var root = new ObjectPath();
38
+ var path = root.add('foo');
39
+
40
+ expect(path.toString()).toEqual('$.foo');
41
+ expect(root.toString()).toEqual('');
42
+ })
43
+ });
@@ -61,10 +61,14 @@ describe("matchersUtil", function() {
61
61
  expect(jasmineUnderTest.matchersUtil.equals(foo, [undefined])).toBe(true);
62
62
  });
63
63
 
64
- it("fails for Arrays that are not equivalent", function() {
64
+ it("fails for Arrays that have different lengths", function() {
65
65
  expect(jasmineUnderTest.matchersUtil.equals([1, 2], [1, 2, 3])).toBe(false);
66
66
  });
67
67
 
68
+ it("fails for Arrays that have different elements", function() {
69
+ expect(jasmineUnderTest.matchersUtil.equals([1, 2, 3], [1, 5, 3])).toBe(false);
70
+ });
71
+
68
72
  it("fails for Arrays whose contents are equivalent, but have differing properties", function() {
69
73
  var one = [1,2,3],
70
74
  two = [1,2,3];
@@ -136,6 +140,13 @@ describe("matchersUtil", function() {
136
140
  expect(jasmineUnderTest.matchersUtil.equals(actual, expected)).toBe(false);
137
141
  });
138
142
 
143
+ it("fails for Objects that have the same number of keys, but different keys/values", function () {
144
+ var expected = { a: undefined },
145
+ actual = { b: 1 };
146
+
147
+ expect(jasmineUnderTest.matchersUtil.equals(actual, expected)).toBe(false);
148
+ })
149
+
139
150
  it("fails when comparing an empty object to an empty array (issue #114)", function() {
140
151
  var emptyObject = {},
141
152
  emptyArray = [];
@@ -327,6 +338,16 @@ describe("matchersUtil", function() {
327
338
  expect(jasmineUnderTest.matchersUtil.equals(true, asymmetricTester, [symmetricTester])).toBe(true);
328
339
  });
329
340
 
341
+ it("passes custom equality matchers to asymmetric equality testers", function() {
342
+ var tester = function(a, b) {};
343
+ var asymmetricTester = { asymmetricMatch: jasmine.createSpy('asymmetricMatch') };
344
+ asymmetricTester.asymmetricMatch.and.returnValue(true);
345
+ var other = {};
346
+
347
+ expect(jasmineUnderTest.matchersUtil.equals(asymmetricTester, other, [tester])).toBe(true);
348
+ expect(asymmetricTester.asymmetricMatch).toHaveBeenCalledWith(other, [tester]);
349
+ });
350
+
330
351
  it("passes when an Any is compared to an Any that checks for the same type", function() {
331
352
  var any1 = new jasmineUnderTest.Any(Function),
332
353
  any2 = new jasmineUnderTest.Any(Function);
@@ -357,6 +378,41 @@ describe("matchersUtil", function() {
357
378
 
358
379
  expect(jasmineUnderTest.matchersUtil.equals(objA, objB)).toBe(false);
359
380
  });
381
+
382
+ it("passes when comparing two empty sets", function() {
383
+ jasmine.getEnv().requireFunctioningSets();
384
+ expect(jasmineUnderTest.matchersUtil.equals(new Set(), new Set())).toBe(true);
385
+ });
386
+
387
+ it("passes when comparing identical sets", function() {
388
+ jasmine.getEnv().requireFunctioningSets();
389
+ var setA = new Set([6, 5]);
390
+ var setB = new Set();
391
+ setB.add(6);
392
+ setB.add(5);
393
+ expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(true);
394
+ });
395
+
396
+ it("fails for sets with different elements", function() {
397
+ jasmine.getEnv().requireFunctioningSets();
398
+ var setA = new Set([6, 3, 5]);
399
+ var setB = new Set([6, 4, 5]);
400
+ expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(false);
401
+ });
402
+
403
+ it("fails for sets of different size", function() {
404
+ jasmine.getEnv().requireFunctioningSets();
405
+ var setA = new Set([6, 3]);
406
+ var setB = new Set([6, 4, 5]);
407
+ expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(false);
408
+ });
409
+
410
+ it("fails for sets with different insertion order", function() {
411
+ jasmine.getEnv().requireFunctioningSets();
412
+ var setA = new Set([3, 6]);
413
+ var setB = new Set([6, 3]);
414
+ expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(false);
415
+ });
360
416
  });
361
417
 
362
418
  describe("contains", function() {
@@ -0,0 +1,31 @@
1
+ describe("toBeNegativeInfinity", function() {
2
+ it("fails for anything that isn't -Infinity", function() {
3
+ var matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(),
4
+ result;
5
+
6
+ result = matcher.compare(1);
7
+ expect(result.pass).toBe(false);
8
+
9
+ result = matcher.compare(Number.NaN);
10
+ expect(result.pass).toBe(false);
11
+
12
+ result = matcher.compare(null);
13
+ expect(result.pass).toBe(false);
14
+ });
15
+
16
+ it("has a custom message on failure", function() {
17
+ var matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(),
18
+ result = matcher.compare(0);
19
+
20
+ expect(result.message()).toEqual("Expected 0 not to be -Infinity.")
21
+ });
22
+
23
+ it("succeeds for -Infinity", function() {
24
+ var matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(),
25
+ result = matcher.compare(Number.NEGATIVE_INFINITY);
26
+
27
+ expect(result.pass).toBe(true);
28
+ expect(result.message).toEqual("Expected actual to be -Infinity.")
29
+ });
30
+
31
+ });
@@ -0,0 +1,31 @@
1
+ describe("toBePositiveInfinity", function() {
2
+ it("fails for anything that isn't Infinity", function() {
3
+ var matcher = jasmineUnderTest.matchers.toBePositiveInfinity(),
4
+ result;
5
+
6
+ result = matcher.compare(1);
7
+ expect(result.pass).toBe(false);
8
+
9
+ result = matcher.compare(Number.NaN);
10
+ expect(result.pass).toBe(false);
11
+
12
+ result = matcher.compare(null);
13
+ expect(result.pass).toBe(false);
14
+ });
15
+
16
+ it("has a custom message on failure", function() {
17
+ var matcher = jasmineUnderTest.matchers.toBePositiveInfinity(),
18
+ result = matcher.compare(0);
19
+
20
+ expect(result.message()).toEqual("Expected 0 not to be Infinity.")
21
+ });
22
+
23
+ it("succeeds for Infinity", function() {
24
+ var matcher = jasmineUnderTest.matchers.toBePositiveInfinity(),
25
+ result = matcher.compare(Number.POSITIVE_INFINITY);
26
+
27
+ expect(result.pass).toBe(true);
28
+ expect(result.message).toEqual("Expected actual to be Infinity.")
29
+ });
30
+
31
+ });