jasmine-core 3.0.0 → 3.1.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 (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,120 +0,0 @@
1
- describe("ExceptionFormatter", function() {
2
- describe("#message", function() {
3
- it('formats Firefox exception messages', function() {
4
- var sampleFirefoxException = {
5
- fileName: 'foo.js',
6
- lineNumber: '1978',
7
- message: 'you got your foo in my bar',
8
- name: 'A Classic Mistake'
9
- },
10
- exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
11
- message = exceptionFormatter.message(sampleFirefoxException);
12
-
13
- expect(message).toEqual('A Classic Mistake: you got your foo in my bar in foo.js (line 1978)');
14
- });
15
-
16
- it('formats Webkit exception messages', function() {
17
- var sampleWebkitException = {
18
- sourceURL: 'foo.js',
19
- line: '1978',
20
- message: 'you got your foo in my bar',
21
- name: 'A Classic Mistake'
22
- },
23
- exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
24
- message = exceptionFormatter.message(sampleWebkitException);
25
-
26
- expect(message).toEqual('A Classic Mistake: you got your foo in my bar in foo.js (line 1978)');
27
- });
28
-
29
- it('formats V8 exception messages', function() {
30
- var sampleV8 = {
31
- message: 'you got your foo in my bar',
32
- name: 'A Classic Mistake'
33
- },
34
- exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
35
- message = exceptionFormatter.message(sampleV8);
36
-
37
- expect(message).toEqual('A Classic Mistake: you got your foo in my bar');
38
- });
39
-
40
- it("formats thrown exceptions that aren't errors", function() {
41
- var thrown = "crazy error",
42
- exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
43
- message = exceptionFormatter.message(thrown);
44
-
45
- expect(message).toEqual("crazy error thrown");
46
- });
47
- });
48
-
49
- describe("#stack", function() {
50
- it("formats stack traces", function() {
51
- var error;
52
- try { throw new Error("an error") } catch(e) { error = e; }
53
-
54
- expect(new jasmineUnderTest.ExceptionFormatter().stack(error)).toMatch(/ExceptionFormatterSpec\.js.*\d+/)
55
- });
56
-
57
- it("filters Jasmine stack frames from V8 style traces", function() {
58
- var error = {
59
- stack: 'Error: nope\n' +
60
- ' at fn1 (http://localhost:8888/__spec__/core/UtilSpec.js:115:19)\n' +
61
- ' at fn2 (http://localhost:8888/__jasmine__/jasmine.js:4320:20)\n' +
62
- ' at fn3 (http://localhost:8888/__jasmine__/jasmine.js:4320:20)\n' +
63
- ' at fn4 (http://localhost:8888/__spec__/core/UtilSpec.js:110:19)\n'
64
- };
65
- var subject = new jasmineUnderTest.ExceptionFormatter({
66
- jasmineFile: 'http://localhost:8888/__jasmine__/jasmine.js'
67
- });
68
- var result = subject.stack(error);
69
- expect(result).toEqual('Error: nope\n' +
70
- ' at fn1 (http://localhost:8888/__spec__/core/UtilSpec.js:115:19)\n' +
71
- ' at <Jasmine>\n' +
72
- ' at fn4 (http://localhost:8888/__spec__/core/UtilSpec.js:110:19)'
73
- );
74
- });
75
-
76
- it("filters Jamine stack frames from Webkit style traces", function() {
77
- var error = {
78
- stack: 'http://localhost:8888/__spec__/core/UtilSpec.js:115:28\n' +
79
- 'fn1@http://localhost:8888/__jasmine__/jasmine.js:4320:27\n' +
80
- 'fn2@http://localhost:8888/__jasmine__/jasmine.js:4320:27\n' +
81
- 'http://localhost:8888/__spec__/core/UtilSpec.js:115:28'
82
- };
83
- var subject = new jasmineUnderTest.ExceptionFormatter({
84
- jasmineFile: 'http://localhost:8888/__jasmine__/jasmine.js'
85
- });
86
- var result = subject.stack(error);
87
- expect(result).toEqual(
88
- 'http://localhost:8888/__spec__/core/UtilSpec.js:115:28\n' +
89
- '<Jasmine>\n' +
90
- 'http://localhost:8888/__spec__/core/UtilSpec.js:115:28'
91
- );
92
- });
93
-
94
- it("filters Jasmine stack frames in this environment", function() {
95
- var error, i;
96
- try { throw new Error("an error"); } catch(e) { error = e; }
97
- var subject = new jasmineUnderTest.ExceptionFormatter({
98
- jasmineFile: jasmine.util.jasmineFile()
99
- });
100
- var result = subject.stack(error);
101
- var lines = result.split('\n');
102
-
103
- if (lines[0].match(/an error/)) {
104
- lines.shift();
105
- }
106
-
107
- expect(lines[0]).toMatch(/ExceptionFormatterSpec.js/);
108
- expect(lines[1]).toMatch(/<Jasmine>/);
109
-
110
- // Node has some number of additional frames below Jasmine.
111
- for (i = 2; i < lines.length; i++) {
112
- expect(lines[i]).not.toMatch(/jasmine.js/);
113
- }
114
- });
115
-
116
- it("returns null if no Error provided", function() {
117
- expect(new jasmineUnderTest.ExceptionFormatter().stack()).toBeNull();
118
- });
119
- });
120
- });
@@ -1,46 +0,0 @@
1
- describe('Exceptions:', function() {
2
- var env;
3
-
4
- beforeEach(function() {
5
- env = new jasmineUnderTest.Env();
6
- });
7
-
8
- it('should handle exceptions thrown, but continue', function(done) {
9
- var secondTest = jasmine.createSpy('second test');
10
- env.describe('Suite for handles exceptions', function () {
11
- env.it('should be a test that fails because it throws an exception', function() {
12
- throw new Error();
13
- });
14
- env.it('should be a passing test that runs after exceptions are thrown from a async test', secondTest);
15
- });
16
-
17
- var expectations = function() {
18
- expect(secondTest).toHaveBeenCalled();
19
- done();
20
- };
21
-
22
- env.addReporter({ jasmineDone: expectations });
23
- env.execute();
24
- });
25
-
26
- it("should handle exceptions thrown directly in top-level describe blocks and continue", function(done) {
27
- var secondDescribe = jasmine.createSpy("second describe");
28
- env.describe("a suite that throws an exception", function () {
29
- env.it("is a test that should pass", function () {
30
- this.expect(true).toEqual(true);
31
- });
32
-
33
- throw new Error("top level error");
34
- });
35
- env.describe("a suite that doesn't throw an exception", secondDescribe);
36
-
37
- var expectations = function() {
38
- expect(secondDescribe).toHaveBeenCalled();
39
- done();
40
- };
41
-
42
- env.addReporter({ jasmineDone: expectations });
43
- env.execute();
44
- });
45
- });
46
-
@@ -1,61 +0,0 @@
1
- describe("buildExpectationResult", function() {
2
- it("defaults to passed", function() {
3
- var result = jasmineUnderTest.buildExpectationResult({passed: 'some-value'});
4
- expect(result.passed).toBe('some-value');
5
- });
6
-
7
- it("message defaults to Passed for passing specs", function() {
8
- var result = jasmineUnderTest.buildExpectationResult({passed: true, message: 'some-value'});
9
- expect(result.message).toBe('Passed.');
10
- });
11
-
12
- it("message returns the message for failing expectations", function() {
13
- var result = jasmineUnderTest.buildExpectationResult({passed: false, message: 'some-value'});
14
- expect(result.message).toBe('some-value');
15
- });
16
-
17
- it("delegates message formatting to the provided formatter if there was an Error", function() {
18
- var fakeError = {message: 'foo'},
19
- messageFormatter = jasmine.createSpy("exception message formatter").and.returnValue(fakeError.message);
20
-
21
- var result = jasmineUnderTest.buildExpectationResult(
22
- {
23
- passed: false,
24
- error: fakeError,
25
- messageFormatter: messageFormatter
26
- });
27
-
28
- expect(messageFormatter).toHaveBeenCalledWith(fakeError);
29
- expect(result.message).toEqual('foo');
30
- });
31
-
32
- it("delegates stack formatting to the provided formatter if there was an Error", function() {
33
- var fakeError = {stack: 'foo'},
34
- stackFormatter = jasmine.createSpy("stack formatter").and.returnValue(fakeError.stack);
35
-
36
- var result = jasmineUnderTest.buildExpectationResult(
37
- {
38
- passed: false,
39
- error: fakeError,
40
- stackFormatter: stackFormatter
41
- });
42
-
43
- expect(stackFormatter).toHaveBeenCalledWith(fakeError);
44
- expect(result.stack).toEqual('foo');
45
- });
46
-
47
- it("matcherName returns passed matcherName", function() {
48
- var result = jasmineUnderTest.buildExpectationResult({matcherName: 'some-value'});
49
- expect(result.matcherName).toBe('some-value');
50
- });
51
-
52
- it("expected returns passed expected", function() {
53
- var result = jasmineUnderTest.buildExpectationResult({expected: 'some-value'});
54
- expect(result.expected).toBe('some-value');
55
- });
56
-
57
- it("actual returns passed actual", function() {
58
- var result = jasmineUnderTest.buildExpectationResult({actual: 'some-value'});
59
- expect(result.actual).toBe('some-value');
60
- });
61
- });
@@ -1,434 +0,0 @@
1
- describe("Expectation", function() {
2
- it("makes custom matchers available to this expectation", function() {
3
- var matchers = {
4
- toFoo: function() {},
5
- toBar: function() {}
6
- },
7
- expectation;
8
-
9
- expectation = new jasmineUnderTest.Expectation({
10
- customMatchers: matchers
11
- });
12
-
13
- expect(expectation.toFoo).toBeDefined();
14
- expect(expectation.toBar).toBeDefined();
15
- });
16
-
17
- it(".addCoreMatchers makes matchers available to any expectation", function() {
18
- var coreMatchers = {
19
- toQuux: function() {}
20
- },
21
- expectation;
22
-
23
- jasmineUnderTest.Expectation.addCoreMatchers(coreMatchers);
24
-
25
- expectation = new jasmineUnderTest.Expectation({});
26
-
27
- expect(expectation.toQuux).toBeDefined();
28
- });
29
-
30
- it("Factory builds an expectation/negative expectation", function() {
31
- var builtExpectation = jasmineUnderTest.Expectation.Factory();
32
-
33
- expect(builtExpectation instanceof jasmineUnderTest.Expectation).toBe(true);
34
- expect(builtExpectation.not instanceof jasmineUnderTest.Expectation).toBe(true);
35
- expect(builtExpectation.not.isNot).toBe(true);
36
- });
37
-
38
- it("wraps matchers's compare functions, passing in matcher dependencies", function() {
39
- var fakeCompare = function() { return { pass: true }; },
40
- matcherFactory = jasmine.createSpy("matcher").and.returnValue({ compare: fakeCompare }),
41
- matchers = {
42
- toFoo: matcherFactory
43
- },
44
- util = {},
45
- customEqualityTesters = ['a'],
46
- addExpectationResult = jasmine.createSpy("addExpectationResult"),
47
- expectation;
48
-
49
- expectation = new jasmineUnderTest.Expectation({
50
- util: util,
51
- customMatchers: matchers,
52
- customEqualityTesters: customEqualityTesters,
53
- actual: "an actual",
54
- addExpectationResult: addExpectationResult
55
- });
56
-
57
- expectation.toFoo("hello");
58
-
59
- expect(matcherFactory).toHaveBeenCalledWith(util, customEqualityTesters)
60
- });
61
-
62
- it("wraps matchers's compare functions, passing the actual and expected", function() {
63
- var fakeCompare = jasmine.createSpy('fake-compare').and.returnValue({pass: true}),
64
- matchers = {
65
- toFoo: function() {
66
- return {
67
- compare: fakeCompare
68
- };
69
- }
70
- },
71
- util = {
72
- buildFailureMessage: jasmine.createSpy('buildFailureMessage')
73
- },
74
- addExpectationResult = jasmine.createSpy("addExpectationResult"),
75
- expectation;
76
-
77
- expectation = new jasmineUnderTest.Expectation({
78
- util: util,
79
- customMatchers: matchers,
80
- actual: "an actual",
81
- addExpectationResult: addExpectationResult
82
- });
83
-
84
- expectation.toFoo("hello");
85
-
86
- expect(fakeCompare).toHaveBeenCalledWith("an actual", "hello");
87
- });
88
-
89
- it("reports a passing result to the spec when the comparison passes", function() {
90
- var matchers = {
91
- toFoo: function() {
92
- return {
93
- compare: function() { return { pass: true }; }
94
- };
95
- }
96
- },
97
- util = {
98
- buildFailureMessage: jasmine.createSpy('buildFailureMessage')
99
- },
100
- addExpectationResult = jasmine.createSpy("addExpectationResult"),
101
- expectation;
102
-
103
- expectation = new jasmineUnderTest.Expectation({
104
- customMatchers: matchers,
105
- util: util,
106
- actual: "an actual",
107
- addExpectationResult: addExpectationResult
108
- });
109
-
110
- expectation.toFoo("hello");
111
-
112
- expect(addExpectationResult).toHaveBeenCalledWith(true, {
113
- matcherName: "toFoo",
114
- passed: true,
115
- message: "",
116
- error: undefined,
117
- expected: "hello",
118
- actual: "an actual"
119
- });
120
- });
121
-
122
- it("reports a failing result to the spec when the comparison fails", function() {
123
- var matchers = {
124
- toFoo: function() {
125
- return {
126
- compare: function() { return { pass: false }; }
127
- };
128
- }
129
- },
130
- util = {
131
- buildFailureMessage: function() { return ""; }
132
- },
133
- addExpectationResult = jasmine.createSpy("addExpectationResult"),
134
- expectation;
135
-
136
- expectation = new jasmineUnderTest.Expectation({
137
- customMatchers: matchers,
138
- util: util,
139
- actual: "an actual",
140
- addExpectationResult: addExpectationResult
141
- });
142
-
143
- expectation.toFoo("hello");
144
-
145
- expect(addExpectationResult).toHaveBeenCalledWith(false, {
146
- matcherName: "toFoo",
147
- passed: false,
148
- expected: "hello",
149
- actual: "an actual",
150
- message: "",
151
- error: undefined
152
- });
153
- });
154
-
155
- it("reports a failing result and a custom fail message to the spec when the comparison fails", function() {
156
- var matchers = {
157
- toFoo: function() {
158
- return {
159
- compare: function() {
160
- return {
161
- pass: false,
162
- message: "I am a custom message"
163
- };
164
- }
165
- };
166
- }
167
- },
168
- addExpectationResult = jasmine.createSpy("addExpectationResult"),
169
- expectation;
170
-
171
- expectation = new jasmineUnderTest.Expectation({
172
- actual: "an actual",
173
- customMatchers: matchers,
174
- addExpectationResult: addExpectationResult
175
- });
176
-
177
- expectation.toFoo("hello");
178
-
179
- expect(addExpectationResult).toHaveBeenCalledWith(false, {
180
- matcherName: "toFoo",
181
- passed: false,
182
- expected: "hello",
183
- actual: "an actual",
184
- message: "I am a custom message",
185
- error: undefined
186
- });
187
- });
188
-
189
- it("reports a failing result with a custom fail message function to the spec when the comparison fails", function() {
190
- var matchers = {
191
- toFoo: function() {
192
- return {
193
- compare: function() {
194
- return {
195
- pass: false,
196
- message: function() { return "I am a custom message"; }
197
- };
198
- }
199
- };
200
- }
201
- },
202
- addExpectationResult = jasmine.createSpy("addExpectationResult"),
203
- expectation;
204
-
205
- expectation = new jasmineUnderTest.Expectation({
206
- customMatchers: matchers,
207
- actual: "an actual",
208
- addExpectationResult: addExpectationResult
209
- });
210
-
211
- expectation.toFoo("hello");
212
-
213
- expect(addExpectationResult).toHaveBeenCalledWith(false, {
214
- matcherName: "toFoo",
215
- passed: false,
216
- expected: "hello",
217
- actual: "an actual",
218
- message: "I am a custom message",
219
- error: undefined
220
- });
221
- });
222
-
223
- it("reports a passing result to the spec when the comparison fails for a negative expectation", function() {
224
- var matchers = {
225
- toFoo: function() {
226
- return {
227
- compare: function() { return { pass: false }; }
228
- };
229
- }
230
- },
231
- util = {
232
- buildFailureMessage: function() { return ""; }
233
- },
234
- addExpectationResult = jasmine.createSpy("addExpectationResult"),
235
- actual = "an actual",
236
- expectation;
237
-
238
- expectation = new jasmineUnderTest.Expectation({
239
- customMatchers: matchers,
240
- actual: "an actual",
241
- addExpectationResult: addExpectationResult,
242
- isNot: true
243
- });
244
-
245
- expectation.toFoo("hello");
246
-
247
- expect(addExpectationResult).toHaveBeenCalledWith(true, {
248
- matcherName: "toFoo",
249
- passed: true,
250
- message: "",
251
- error: undefined,
252
- expected: "hello",
253
- actual: actual
254
- });
255
- });
256
-
257
- it("reports a failing result to the spec when the comparison passes for a negative expectation", function() {
258
- var matchers = {
259
- toFoo: function() {
260
- return {
261
- compare: function() { return { pass: true }; }
262
- };
263
- }
264
- },
265
- util = {
266
- buildFailureMessage: function() { return "default message"; }
267
- },
268
- addExpectationResult = jasmine.createSpy("addExpectationResult"),
269
- actual = "an actual",
270
- expectation;
271
-
272
- expectation = new jasmineUnderTest.Expectation({
273
- customMatchers: matchers,
274
- actual: "an actual",
275
- util: util,
276
- addExpectationResult: addExpectationResult,
277
- isNot: true
278
- });
279
-
280
- expectation.toFoo("hello");
281
-
282
- expect(addExpectationResult).toHaveBeenCalledWith(false, {
283
- matcherName: "toFoo",
284
- passed: false,
285
- expected: "hello",
286
- actual: actual,
287
- message: "default message",
288
- error: undefined
289
- });
290
- });
291
-
292
- it("reports a failing result and a custom fail message to the spec when the comparison passes for a negative expectation", function() {
293
- var matchers = {
294
- toFoo: function() {
295
- return {
296
- compare: function() {
297
- return {
298
- pass: true,
299
- message: "I am a custom message"
300
- };
301
- }
302
- };
303
- }
304
- },
305
- addExpectationResult = jasmine.createSpy("addExpectationResult"),
306
- actual = "an actual",
307
- expectation;
308
-
309
- expectation = new jasmineUnderTest.Expectation({
310
- customMatchers: matchers,
311
- actual: "an actual",
312
- addExpectationResult: addExpectationResult,
313
- isNot: true
314
- });
315
-
316
- expectation.toFoo("hello");
317
-
318
- expect(addExpectationResult).toHaveBeenCalledWith(false, {
319
- matcherName: "toFoo",
320
- passed: false,
321
- expected: "hello",
322
- actual: actual,
323
- message: "I am a custom message",
324
- error: undefined
325
- });
326
- });
327
-
328
- it("reports a passing result to the spec when the 'not' comparison passes, given a negativeCompare", function() {
329
- var matchers = {
330
- toFoo: function() {
331
- return {
332
- compare: function() { return { pass: true }; },
333
- negativeCompare: function() { return { pass: true }; }
334
- };
335
- }
336
- },
337
- addExpectationResult = jasmine.createSpy("addExpectationResult"),
338
- actual = "an actual",
339
- expectation;
340
-
341
- expectation = new jasmineUnderTest.Expectation({
342
- customMatchers: matchers,
343
- actual: "an actual",
344
- addExpectationResult: addExpectationResult,
345
- isNot: true
346
- });
347
-
348
- expectation.toFoo("hello");
349
-
350
- expect(addExpectationResult).toHaveBeenCalledWith(true, {
351
- matcherName: "toFoo",
352
- passed: true,
353
- expected: "hello",
354
- actual: actual,
355
- message: "",
356
- error: undefined
357
- });
358
- });
359
-
360
- it("reports a failing result and a custom fail message to the spec when the 'not' comparison fails, given a negativeCompare", function() {
361
- var matchers = {
362
- toFoo: function() {
363
- return {
364
- compare: function() { return { pass: true }; },
365
- negativeCompare: function() {
366
- return {
367
- pass: false,
368
- message: "I'm a custom message"
369
- };
370
- }
371
- };
372
- }
373
- },
374
- addExpectationResult = jasmine.createSpy("addExpectationResult"),
375
- actual = "an actual",
376
- expectation;
377
-
378
- expectation = new jasmineUnderTest.Expectation({
379
- customMatchers: matchers,
380
- actual: "an actual",
381
- addExpectationResult: addExpectationResult,
382
- isNot: true
383
- });
384
-
385
- expectation.toFoo("hello");
386
-
387
- expect(addExpectationResult).toHaveBeenCalledWith(false, {
388
- matcherName: "toFoo",
389
- passed: false,
390
- expected: "hello",
391
- actual: actual,
392
- message: "I'm a custom message",
393
- error: undefined
394
- });
395
- });
396
-
397
- it("reports a custom error message to the spec", function() {
398
- var customError = new Error("I am a custom error");
399
- var matchers = {
400
- toFoo: function() {
401
- return {
402
- compare: function() {
403
- return {
404
- pass: false,
405
- message: "I am a custom message",
406
- error: customError
407
- };
408
- }
409
- };
410
- }
411
- },
412
- addExpectationResult = jasmine.createSpy("addExpectationResult"),
413
- expectation;
414
-
415
- expectation = new jasmineUnderTest.Expectation({
416
- actual: "an actual",
417
- customMatchers: matchers,
418
- addExpectationResult: addExpectationResult
419
- });
420
-
421
- expectation.toFoo("hello");
422
-
423
- expect(addExpectationResult).toHaveBeenCalledWith(false, {
424
- matcherName: "toFoo",
425
- passed: false,
426
- expected: "hello",
427
- actual: "an actual",
428
- message: "I am a custom message",
429
- error: customError
430
- });
431
- });
432
-
433
- });
434
-