jasmine-core 2.5.0 → 2.99.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) 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 +95 -31
  6. data/lib/jasmine-core/jasmine.css +1 -0
  7. data/lib/jasmine-core/jasmine.js +3635 -1684
  8. data/lib/jasmine-core/node_boot.js +1 -1
  9. data/lib/jasmine-core/spec/core/CallTrackerSpec.js +10 -0
  10. data/lib/jasmine-core/spec/core/ClearStackSpec.js +137 -0
  11. data/lib/jasmine-core/spec/core/ClockSpec.js +94 -14
  12. data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +26 -8
  13. data/lib/jasmine-core/spec/core/EnvSpec.js +142 -10
  14. data/lib/jasmine-core/spec/core/ExpectationSpec.js +52 -7
  15. data/lib/jasmine-core/spec/core/GlobalErrorsSpec.js +110 -0
  16. data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +132 -4
  17. data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +333 -23
  18. data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +16 -1
  19. data/lib/jasmine-core/spec/core/SpecSpec.js +30 -8
  20. data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +225 -1
  21. data/lib/jasmine-core/spec/core/SpySpec.js +44 -2
  22. data/lib/jasmine-core/spec/core/SpyStrategySpec.js +28 -5
  23. data/lib/jasmine-core/spec/core/SuiteSpec.js +14 -19
  24. data/lib/jasmine-core/spec/core/UserContextSpec.js +54 -0
  25. data/lib/jasmine-core/spec/core/UtilSpec.js +71 -0
  26. data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +32 -0
  27. data/lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js +32 -0
  28. data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js +13 -0
  29. data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js +47 -0
  30. data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +13 -0
  31. data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +48 -0
  32. data/lib/jasmine-core/spec/core/integration/EnvSpec.js +339 -38
  33. data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +156 -3
  34. data/lib/jasmine-core/spec/core/matchers/DiffBuilderSpec.js +47 -0
  35. data/lib/jasmine-core/spec/core/matchers/NullDiffBuilderSpec.js +13 -0
  36. data/lib/jasmine-core/spec/core/matchers/ObjectPathSpec.js +43 -0
  37. data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +231 -8
  38. data/lib/jasmine-core/spec/core/matchers/nothingSpec.js +8 -0
  39. data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +42 -0
  40. data/lib/jasmine-core/spec/core/matchers/toBeNegativeInfinitySpec.js +31 -0
  41. data/lib/jasmine-core/spec/core/matchers/toBePositiveInfinitySpec.js +31 -0
  42. data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +780 -4
  43. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledBeforeSpec.js +99 -0
  44. data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +37 -0
  45. data/lib/jasmine-core/spec/helpers/BrowserFlags.js +4 -0
  46. data/lib/jasmine-core/spec/helpers/asyncAwait.js +27 -0
  47. data/lib/jasmine-core/spec/helpers/checkForMap.js +37 -0
  48. data/lib/jasmine-core/spec/helpers/checkForSet.js +41 -0
  49. data/lib/jasmine-core/spec/helpers/checkForSymbol.js +28 -0
  50. data/lib/jasmine-core/spec/helpers/checkForTypedArrays.js +20 -0
  51. data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +105 -23
  52. data/lib/jasmine-core/spec/html/SpyRegistryHtmlSpec.js +34 -0
  53. data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +1 -1
  54. data/lib/jasmine-core/version.rb +1 -1
  55. metadata +19 -4
@@ -29,6 +29,38 @@ describe("Any", function() {
29
29
  expect(any.asymmetricMatch(true)).toBe(true);
30
30
  });
31
31
 
32
+ it("matches a Map", function() {
33
+ jasmine.getEnv().requireFunctioningMaps();
34
+
35
+ var any = new jasmineUnderTest.Any(Map);
36
+
37
+ expect(any.asymmetricMatch(new Map())).toBe(true);
38
+ });
39
+
40
+ it("matches a Set", function() {
41
+ jasmine.getEnv().requireFunctioningSets();
42
+
43
+ var any = new jasmineUnderTest.Any(Set);
44
+
45
+ expect(any.asymmetricMatch(new Set())).toBe(true);
46
+ });
47
+
48
+ it("matches a TypedArray", function() {
49
+ jasmine.getEnv().requireFunctioningTypedArrays();
50
+
51
+ var any = new jasmineUnderTest.Any(Uint32Array);
52
+
53
+ expect(any.asymmetricMatch(new Uint32Array([]))).toBe(true);
54
+ });
55
+
56
+ it("matches a Symbol", function() {
57
+ jasmine.getEnv().requireFunctioningSymbols();
58
+
59
+ var any = new jasmineUnderTest.Any(Symbol);
60
+
61
+ expect(any.asymmetricMatch(Symbol())).toBe(true);
62
+ });
63
+
32
64
  it("matches another constructed object", function() {
33
65
  var Thing = function() {},
34
66
  any = new jasmineUnderTest.Any(Thing);
@@ -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
 
@@ -36,4 +36,17 @@ describe("ArrayContaining", function() {
36
36
 
37
37
  expect(containing.jasmineToString()).toMatch("<jasmine.arrayContaining");
38
38
  });
39
+
40
+ it("uses custom equality testers", function() {
41
+ var tester = function(a, b) {
42
+ // All "foo*" strings match each other.
43
+ if (typeof a == "string" && typeof b == "string" &&
44
+ a.substr(0, 3) == "foo" && b.substr(0, 3) == "foo") {
45
+ return true;
46
+ }
47
+ };
48
+ var containing = new jasmineUnderTest.ArrayContaining(["fooVal"]);
49
+
50
+ expect(containing.asymmetricMatch(["fooBar"], [tester])).toBe(true);
51
+ });
39
52
  });
@@ -0,0 +1,47 @@
1
+ describe("ArrayWithExactContents", function() {
2
+ it("matches an array with the same items in a different order", function() {
3
+ var matcher = new jasmineUnderTest.ArrayWithExactContents(['a', 2, /a/]);
4
+
5
+ expect(matcher.asymmetricMatch([2, 'a', /a/])).toBe(true);
6
+ });
7
+
8
+ it("does not work when not passed an array", function() {
9
+ var matcher = new jasmineUnderTest.ArrayWithExactContents("foo");
10
+
11
+ expect(function() {
12
+ matcher.asymmetricMatch([]);
13
+ }).toThrowError(/not 'foo'/);
14
+ });
15
+
16
+ it("does not match when an item is missing", function() {
17
+ var matcher = new jasmineUnderTest.ArrayWithExactContents(['a', 2, /a/]);
18
+
19
+ expect(matcher.asymmetricMatch(['a', 2])).toBe(false);
20
+ expect(matcher.asymmetricMatch(['a', 2, undefined])).toBe(false);
21
+ });
22
+
23
+ it("does not match when there is an extra item", function() {
24
+ var matcher = new jasmineUnderTest.ArrayWithExactContents(['a']);
25
+
26
+ expect(matcher.asymmetricMatch(['a', 2])).toBe(false);
27
+ });
28
+
29
+ it("jasmineToStrings itself", function() {
30
+ var matcher = new jasmineUnderTest.ArrayWithExactContents([]);
31
+
32
+ expect(matcher.jasmineToString()).toMatch("<jasmine.arrayWithExactContents");
33
+ });
34
+
35
+ it("uses custom equality testers", function() {
36
+ var tester = function(a, b) {
37
+ // All "foo*" strings match each other.
38
+ if (typeof a == "string" && typeof b == "string" &&
39
+ a.substr(0, 3) == "foo" && b.substr(0, 3) == "foo") {
40
+ return true;
41
+ }
42
+ };
43
+ var matcher = new jasmineUnderTest.ArrayWithExactContents(["fooVal"]);
44
+
45
+ expect(matcher.asymmetricMatch(["fooBar"], [tester])).toBe(true);
46
+ });
47
+ });
@@ -86,4 +86,17 @@ describe("ObjectContaining", function() {
86
86
 
87
87
  expect(containing.asymmetricMatch(obj)).toBe(true);
88
88
  });
89
+
90
+ it("uses custom equality testers", function() {
91
+ var tester = function(a, b) {
92
+ // All "foo*" strings match each other.
93
+ if (typeof a == "string" && typeof b == "string" &&
94
+ a.substr(0, 3) == "foo" && b.substr(0, 3) == "foo") {
95
+ return true;
96
+ }
97
+ };
98
+ var containing = new jasmineUnderTest.ObjectContaining({foo: "fooVal"});
99
+
100
+ expect(containing.asymmetricMatch({foo: "fooBar"}, [tester])).toBe(true);
101
+ });
89
102
  });
@@ -56,6 +56,54 @@ describe("Custom Matchers (Integration)", function() {
56
56
  env.execute();
57
57
  });
58
58
 
59
+ it("passes the spec if the custom equality matcher passes for types nested inside asymmetric equality testers", function(done) {
60
+ env.it("spec using custom equality matcher", function() {
61
+ var customEqualityFn = function(a, b) {
62
+ // All "foo*" strings match each other.
63
+ if (typeof a == "string" && typeof b == "string" &&
64
+ a.substr(0, 3) == "foo" && b.substr(0, 3) == "foo") {
65
+ return true;
66
+ }
67
+ };
68
+
69
+ env.addCustomEqualityTester(customEqualityFn);
70
+ env.expect({foo: 'fooValue'}).toEqual(jasmineUnderTest.objectContaining({foo: 'fooBar'}));
71
+ env.expect(['fooValue', 'things']).toEqual(jasmineUnderTest.arrayContaining(['fooBar']));
72
+ env.expect(['fooValue']).toEqual(jasmineUnderTest.arrayWithExactContents(['fooBar']));
73
+ });
74
+
75
+ var specExpectations = function(result) {
76
+ expect(result.status).toEqual('passed');
77
+ };
78
+
79
+ env.addReporter({ specDone: specExpectations, jasmineDone: done });
80
+ env.execute();
81
+ });
82
+
83
+ it("displays an appropriate failure message if a custom equality matcher fails", function(done) {
84
+ env.it("spec using custom equality matcher", function() {
85
+ var customEqualityFn = function(a, b) {
86
+ // "foo" is not equal to anything
87
+ if (a === 'foo' || b === 'foo') {
88
+ return false;
89
+ }
90
+ };
91
+
92
+ env.addCustomEqualityTester(customEqualityFn);
93
+ env.expect({foo: 'foo'}).toEqual({foo: 'foo'});
94
+ });
95
+
96
+ var specExpectations = function(result) {
97
+ expect(result.status).toEqual('failed');
98
+ expect(result.failedExpectations[0].message).toEqual(
99
+ "Expected $.foo = 'foo' to equal 'foo'."
100
+ );
101
+ };
102
+
103
+ env.addReporter({ specDone: specExpectations, jasmineDone: done });
104
+ env.execute();
105
+ });
106
+
59
107
  it("uses the negative compare function for a negative comparison, if provided", function(done) {
60
108
  env.it("spec with custom negative comparison matcher", function() {
61
109
  env.addMatchers({