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,54 +0,0 @@
1
- describe("UserContext", function() {
2
- it("Behaves just like an plain object", function() {
3
- var context = new jasmineUnderTest.UserContext(),
4
- properties = [];
5
-
6
- for (var prop in context) {
7
- if (obj.hasOwnProperty(prop)) {
8
- properties.push(prop);
9
- }
10
- }
11
-
12
- expect(properties).toEqual([]);
13
- });
14
-
15
- describe('.fromExisting', function() {
16
- describe('when using an already built context as model', function() {
17
- beforeEach(function() {
18
- this.context = new jasmineUnderTest.UserContext();
19
- this.context.key = 'value';
20
- this.cloned = jasmineUnderTest.UserContext.fromExisting(this.context);
21
- });
22
-
23
- it('returns a cloned object', function() {
24
- expect(this.cloned).toEqual(this.context);
25
- });
26
-
27
- it('does not return the same object', function() {
28
- expect(this.cloned).not.toBe(this.context);
29
- });
30
- });
31
-
32
- describe('when using a regular object as parameter', function() {
33
- beforeEach(function() {
34
- this.context = {};
35
- this.value = 'value'
36
- this.context.key = this.value;
37
- this.cloned = jasmineUnderTest.UserContext.fromExisting(this.context);
38
- });
39
-
40
- it('returns an object with the same attributes', function() {
41
- expect(this.cloned.key).toEqual(this.value);
42
- });
43
-
44
- it('does not return the same object', function() {
45
- expect(this.cloned).not.toBe(this.context);
46
- });
47
-
48
- it('returns an UserContext', function() {
49
- expect(this.cloned.constructor).toBe(jasmineUnderTest.UserContext);
50
- });
51
- });
52
- });
53
- });
54
-
@@ -1,105 +0,0 @@
1
- describe("jasmineUnderTest.util", function() {
2
- describe("isArray_", function() {
3
- it("should return true if the argument is an array", function() {
4
- expect(jasmineUnderTest.isArray_([])).toBe(true);
5
- expect(jasmineUnderTest.isArray_(['a'])).toBe(true);
6
- });
7
-
8
- it("should return false if the argument is not an array", function() {
9
- expect(jasmineUnderTest.isArray_(undefined)).toBe(false);
10
- expect(jasmineUnderTest.isArray_({})).toBe(false);
11
- expect(jasmineUnderTest.isArray_(function() {})).toBe(false);
12
- expect(jasmineUnderTest.isArray_('foo')).toBe(false);
13
- expect(jasmineUnderTest.isArray_(5)).toBe(false);
14
- expect(jasmineUnderTest.isArray_(null)).toBe(false);
15
- });
16
- });
17
-
18
- describe("isObject_", function() {
19
- it("should return true if the argument is an object", function() {
20
- expect(jasmineUnderTest.isObject_({})).toBe(true);
21
- expect(jasmineUnderTest.isObject_({an: "object"})).toBe(true);
22
- });
23
-
24
- it("should return false if the argument is not an object", function() {
25
- expect(jasmineUnderTest.isObject_(undefined)).toBe(false);
26
- expect(jasmineUnderTest.isObject_([])).toBe(false);
27
- expect(jasmineUnderTest.isObject_(function() {})).toBe(false);
28
- expect(jasmineUnderTest.isObject_('foo')).toBe(false);
29
- expect(jasmineUnderTest.isObject_(5)).toBe(false);
30
- expect(jasmineUnderTest.isObject_(null)).toBe(false);
31
- });
32
- });
33
-
34
- describe("isUndefined", function() {
35
- it("reports if a variable is defined", function() {
36
- var a;
37
- expect(jasmineUnderTest.util.isUndefined(a)).toBe(true);
38
- expect(jasmineUnderTest.util.isUndefined(undefined)).toBe(true);
39
-
40
- var undefined = "diz be undefined yo";
41
- expect(jasmineUnderTest.util.isUndefined(undefined)).toBe(false);
42
- });
43
- });
44
-
45
- describe("getPropertyDescriptor", function() {
46
- it("get property descriptor from object", function() {
47
- var obj = {prop: 1},
48
- actual = jasmineUnderTest.util.getPropertyDescriptor(obj, 'prop'),
49
- expected = Object.getOwnPropertyDescriptor(obj, 'prop');
50
-
51
- expect(actual).toEqual(expected);
52
- });
53
-
54
- it("get property descriptor from object property", function() {
55
- var proto = {prop: 1},
56
- obj = Object.create(proto),
57
- actual = jasmineUnderTest.util.getPropertyDescriptor(proto, 'prop'),
58
- expected = Object.getOwnPropertyDescriptor(proto, 'prop');
59
-
60
- expect(actual).toEqual(expected);
61
- });
62
- });
63
-
64
- describe("objectDifference", function() {
65
- it("given two objects A and B, returns the properties in A not present in B", function() {
66
- var a = {
67
- foo: 3,
68
- bar: 4,
69
- baz: 5
70
- };
71
-
72
- var b = {
73
- bar: 6,
74
- quux: 7
75
- };
76
-
77
- expect(jasmineUnderTest.util.objectDifference(a, b)).toEqual({foo: 3, baz: 5})
78
- });
79
-
80
- it("only looks at own properties of both objects", function() {
81
- function Foo() {}
82
-
83
- Foo.prototype.x = 1;
84
- Foo.prototype.y = 2;
85
-
86
- var a = new Foo();
87
- a.x = 1;
88
-
89
- var b = new Foo();
90
- b.y = 2;
91
-
92
- expect(jasmineUnderTest.util.objectDifference(a, b)).toEqual({x: 1});
93
- expect(jasmineUnderTest.util.objectDifference(b, a)).toEqual({y: 2});
94
- });
95
- });
96
-
97
- describe("jasmineFile", function() {
98
- it("returns the file containing jasmine.util", function() {
99
- // Chrome sometimes reports foo.js as foo.js/, so tolerate
100
- // a trailing slash if present.
101
- expect(jasmineUnderTest.util.jasmineFile()).toMatch(/util.js\/?$/);
102
- expect(jasmine.util.jasmineFile()).toMatch(/jasmine.js\/?$/);
103
- });
104
- });
105
- });
@@ -1,91 +0,0 @@
1
- describe("Any", function() {
2
- it("matches a string", function() {
3
- var any = new jasmineUnderTest.Any(String);
4
-
5
- expect(any.asymmetricMatch("foo")).toBe(true);
6
- });
7
-
8
- it("matches a number", function() {
9
- var any = new jasmineUnderTest.Any(Number);
10
-
11
- expect(any.asymmetricMatch(1)).toBe(true);
12
- });
13
-
14
- it("matches a function", function() {
15
- var any = new jasmineUnderTest.Any(Function);
16
-
17
- expect(any.asymmetricMatch(function(){})).toBe(true);
18
- });
19
-
20
- it("matches an Object", function() {
21
- var any = new jasmineUnderTest.Any(Object);
22
-
23
- expect(any.asymmetricMatch({})).toBe(true);
24
- });
25
-
26
- it("matches a Boolean", function() {
27
- var any = new jasmineUnderTest.Any(Boolean);
28
-
29
- expect(any.asymmetricMatch(true)).toBe(true);
30
- });
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
-
64
- it("matches another constructed object", function() {
65
- var Thing = function() {},
66
- any = new jasmineUnderTest.Any(Thing);
67
-
68
- expect(any.asymmetricMatch(new Thing())).toBe(true);
69
- });
70
-
71
- it("does not treat null as an Object", function() {
72
- var any = new jasmineUnderTest.Any(Object);
73
-
74
- expect(any.asymmetricMatch(null)).toBe(false);
75
- });
76
-
77
- it("jasmineToString's itself", function() {
78
- var any = new jasmineUnderTest.Any(Number);
79
-
80
- expect(any.jasmineToString()).toEqual('<jasmine.any(Number)>');
81
- expect(any.jasmineToString()).toEqual('<jasmine.any(Number)>');
82
- });
83
-
84
- describe("when called without an argument", function() {
85
- it("tells the user to pass a constructor or use jasmine.anything()", function() {
86
- expect(function() {
87
- new jasmineUnderTest.Any();
88
- }).toThrowError(TypeError, /constructor.*anything/);
89
- });
90
- });
91
- });
@@ -1,76 +0,0 @@
1
- describe("Anything", function() {
2
- it("matches a string", function() {
3
- var anything = new jasmineUnderTest.Anything();
4
-
5
- expect(anything.asymmetricMatch('foo')).toBe(true);
6
- });
7
-
8
- it("matches a number", function() {
9
- var anything = new jasmineUnderTest.Anything();
10
-
11
- expect(anything.asymmetricMatch(42)).toBe(true);
12
- });
13
-
14
- it("matches an object", function() {
15
- var anything = new jasmineUnderTest.Anything();
16
-
17
- expect(anything.asymmetricMatch({ foo: 'bar' })).toBe(true);
18
- });
19
-
20
- it("matches an array", function() {
21
- var anything = new jasmineUnderTest.Anything();
22
-
23
- expect(anything.asymmetricMatch([1,2,3])).toBe(true);
24
- });
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
-
58
- it("doesn't match undefined", function() {
59
- var anything = new jasmineUnderTest.Anything();
60
-
61
- expect(anything.asymmetricMatch()).toBe(false);
62
- expect(anything.asymmetricMatch(undefined)).toBe(false);
63
- });
64
-
65
- it("doesn't match null", function() {
66
- var anything = new jasmineUnderTest.Anything();
67
-
68
- expect(anything.asymmetricMatch(null)).toBe(false);
69
- });
70
-
71
- it("jasmineToString's itself", function() {
72
- var anything = new jasmineUnderTest.Anything();
73
-
74
- expect(anything.jasmineToString()).toEqual("<jasmine.anything>");
75
- });
76
- });
@@ -1,52 +0,0 @@
1
- describe("ArrayContaining", function() {
2
- it("matches any actual to an empty array", function() {
3
- var containing = new jasmineUnderTest.ArrayContaining([]);
4
-
5
- expect(containing.asymmetricMatch("foo")).toBe(true);
6
- });
7
-
8
- it("does not work when not passed an array", function() {
9
- var containing = new jasmineUnderTest.ArrayContaining("foo");
10
-
11
- expect(function() {
12
- containing.asymmetricMatch([]);
13
- }).toThrowError(/not 'foo'/);
14
- });
15
-
16
- it("matches when the item is in the actual", function() {
17
- var containing = new jasmineUnderTest.ArrayContaining(["foo"]);
18
-
19
- expect(containing.asymmetricMatch(["foo"])).toBe(true);
20
- });
21
-
22
- it("matches when additional items are in the actual", function() {
23
- var containing = new jasmineUnderTest.ArrayContaining(["foo"]);
24
-
25
- expect(containing.asymmetricMatch(["foo", "bar"])).toBe(true);
26
- });
27
-
28
- it("does not match when the item is not in the actual", function() {
29
- var containing = new jasmineUnderTest.ArrayContaining(["foo"]);
30
-
31
- expect(containing.asymmetricMatch(["bar"])).toBe(false);
32
- });
33
-
34
- it("jasmineToStrings itself", function() {
35
- var containing = new jasmineUnderTest.ArrayContaining([]);
36
-
37
- expect(containing.jasmineToString()).toMatch("<jasmine.arrayContaining");
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
- });
52
- });
@@ -1,47 +0,0 @@
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
- });
@@ -1,99 +0,0 @@
1
- describe("ObjectContaining", function() {
2
-
3
- it("matches any actual to an empty object", function() {
4
- var containing = new jasmineUnderTest.ObjectContaining({});
5
-
6
- expect(containing.asymmetricMatch("foo")).toBe(true);
7
- });
8
-
9
- it("does not match an empty object actual", function() {
10
- var containing = new jasmineUnderTest.ObjectContaining("foo");
11
-
12
- expect(function() {
13
- containing.asymmetricMatch({})
14
- }).toThrowError(/not 'foo'/)
15
- });
16
-
17
- it("matches when the key/value pair is present in the actual", function() {
18
- var containing = new jasmineUnderTest.ObjectContaining({foo: "fooVal"});
19
-
20
- expect(containing.asymmetricMatch({foo: "fooVal", bar: "barVal"})).toBe(true);
21
- });
22
-
23
- it("does not match when the key/value pair is not present in the actual", function() {
24
- var containing = new jasmineUnderTest.ObjectContaining({foo: "fooVal"});
25
-
26
- expect(containing.asymmetricMatch({bar: "barVal", quux: "quuxVal"})).toBe(false);
27
- });
28
-
29
- it("does not match when the key is present but the value is different in the actual", function() {
30
- var containing = new jasmineUnderTest.ObjectContaining({foo: "other"});
31
-
32
- expect(containing.asymmetricMatch({foo: "fooVal", bar: "barVal"})).toBe(false);
33
- });
34
-
35
- it("jasmineToString's itself", function() {
36
- var containing = new jasmineUnderTest.ObjectContaining({});
37
-
38
- expect(containing.jasmineToString()).toMatch("<jasmine.objectContaining");
39
- });
40
-
41
- it("matches recursively", function() {
42
- var containing = new jasmineUnderTest.ObjectContaining({one: new jasmineUnderTest.ObjectContaining({two: {}})});
43
-
44
- expect(containing.asymmetricMatch({one: {two: {}}})).toBe(true);
45
- });
46
-
47
- it("matches when key is present with undefined value", function() {
48
- var containing = new jasmineUnderTest.ObjectContaining({ one: undefined });
49
-
50
- expect(containing.asymmetricMatch({ one: undefined })).toBe(true);
51
- });
52
-
53
- it("does not match when key with undefined value is not present", function() {
54
- var containing = new jasmineUnderTest.ObjectContaining({ one: undefined });
55
-
56
- expect(containing.asymmetricMatch({})).toBe(false);
57
- });
58
-
59
- it("matches defined properties", function(){
60
- var containing = new jasmineUnderTest.ObjectContaining({ foo: "fooVal" });
61
-
62
- var definedPropertyObject = {};
63
- Object.defineProperty(definedPropertyObject, "foo", {
64
- get: function() { return "fooVal" }
65
- });
66
- expect(containing.asymmetricMatch(definedPropertyObject)).toBe(true);
67
- });
68
-
69
- it("matches prototype properties", function(){
70
- var containing = new jasmineUnderTest.ObjectContaining({ foo: "fooVal" });
71
-
72
- var prototypeObject = {foo: "fooVal"};
73
- var obj;
74
-
75
- if (Object.create) {
76
- obj = Object.create(prototypeObject);
77
- } else {
78
- function Foo() {}
79
- Foo.prototype = prototypeObject;
80
- Foo.prototype.constructor = Foo;
81
- obj = new Foo();
82
- }
83
-
84
- expect(containing.asymmetricMatch(obj)).toBe(true);
85
- });
86
-
87
- it("uses custom equality testers", function() {
88
- var tester = function(a, b) {
89
- // All "foo*" strings match each other.
90
- if (typeof a == "string" && typeof b == "string" &&
91
- a.substr(0, 3) == "foo" && b.substr(0, 3) == "foo") {
92
- return true;
93
- }
94
- };
95
- var containing = new jasmineUnderTest.ObjectContaining({foo: "fooVal"});
96
-
97
- expect(containing.asymmetricMatch({foo: "fooBar"}, [tester])).toBe(true);
98
- });
99
- });