jasmine-core 2.9.0 → 2.99.2

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 (87) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jasmine-core/jasmine-html.js +24 -1
  3. data/lib/jasmine-core/jasmine.css +1 -0
  4. data/lib/jasmine-core/jasmine.js +50 -6
  5. data/lib/jasmine-core/version.rb +1 -1
  6. metadata +3 -84
  7. data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +0 -270
  8. data/lib/jasmine-core/spec/core/CallTrackerSpec.js +0 -130
  9. data/lib/jasmine-core/spec/core/ClearStackSpec.js +0 -137
  10. data/lib/jasmine-core/spec/core/ClockSpec.js +0 -754
  11. data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +0 -270
  12. data/lib/jasmine-core/spec/core/EnvSpec.js +0 -200
  13. data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +0 -63
  14. data/lib/jasmine-core/spec/core/ExceptionsSpec.js +0 -68
  15. data/lib/jasmine-core/spec/core/ExpectationResultSpec.js +0 -61
  16. data/lib/jasmine-core/spec/core/ExpectationSpec.js +0 -434
  17. data/lib/jasmine-core/spec/core/GlobalErrorsSpec.js +0 -110
  18. data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +0 -259
  19. data/lib/jasmine-core/spec/core/MockDateSpec.js +0 -200
  20. data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +0 -337
  21. data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +0 -620
  22. data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +0 -79
  23. data/lib/jasmine-core/spec/core/SpecSpec.js +0 -441
  24. data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +0 -356
  25. data/lib/jasmine-core/spec/core/SpySpec.js +0 -127
  26. data/lib/jasmine-core/spec/core/SpyStrategySpec.js +0 -159
  27. data/lib/jasmine-core/spec/core/SuiteSpec.js +0 -155
  28. data/lib/jasmine-core/spec/core/TimerSpec.js +0 -31
  29. data/lib/jasmine-core/spec/core/TreeProcessorSpec.js +0 -756
  30. data/lib/jasmine-core/spec/core/UserContextSpec.js +0 -54
  31. data/lib/jasmine-core/spec/core/UtilSpec.js +0 -99
  32. data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +0 -84
  33. data/lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js +0 -76
  34. data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js +0 -52
  35. data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js +0 -47
  36. data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +0 -102
  37. data/lib/jasmine-core/spec/core/asymmetric_equality/StringMatchingSpec.js +0 -27
  38. data/lib/jasmine-core/spec/core/formatErrorMsgSpec.js +0 -13
  39. data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +0 -199
  40. data/lib/jasmine-core/spec/core/integration/EnvSpec.js +0 -2007
  41. data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +0 -950
  42. data/lib/jasmine-core/spec/core/matchers/DiffBuilderSpec.js +0 -47
  43. data/lib/jasmine-core/spec/core/matchers/NullDiffBuilderSpec.js +0 -13
  44. data/lib/jasmine-core/spec/core/matchers/ObjectPathSpec.js +0 -43
  45. data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +0 -658
  46. data/lib/jasmine-core/spec/core/matchers/nothingSpec.js +0 -8
  47. data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +0 -93
  48. data/lib/jasmine-core/spec/core/matchers/toBeDefinedSpec.js +0 -18
  49. data/lib/jasmine-core/spec/core/matchers/toBeFalsySpec.js +0 -38
  50. data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanOrEqualSpec.js +0 -29
  51. data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +0 -20
  52. data/lib/jasmine-core/spec/core/matchers/toBeLessThanOrEqualSpec.js +0 -29
  53. data/lib/jasmine-core/spec/core/matchers/toBeLessThanSpec.js +0 -20
  54. data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +0 -37
  55. data/lib/jasmine-core/spec/core/matchers/toBeNegativeInfinitySpec.js +0 -31
  56. data/lib/jasmine-core/spec/core/matchers/toBeNullSpec.js +0 -17
  57. data/lib/jasmine-core/spec/core/matchers/toBePositiveInfinitySpec.js +0 -31
  58. data/lib/jasmine-core/spec/core/matchers/toBeSpec.js +0 -17
  59. data/lib/jasmine-core/spec/core/matchers/toBeTruthySpec.js +0 -38
  60. data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +0 -18
  61. data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +0 -26
  62. data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +0 -804
  63. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledBeforeSpec.js +0 -99
  64. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +0 -47
  65. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledTimesSpec.js +0 -86
  66. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +0 -67
  67. data/lib/jasmine-core/spec/core/matchers/toMatchSpec.js +0 -43
  68. data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +0 -315
  69. data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +0 -100
  70. data/lib/jasmine-core/spec/helpers/BrowserFlags.js +0 -27
  71. data/lib/jasmine-core/spec/helpers/asyncAwait.js +0 -27
  72. data/lib/jasmine-core/spec/helpers/checkForMap.js +0 -37
  73. data/lib/jasmine-core/spec/helpers/checkForSet.js +0 -41
  74. data/lib/jasmine-core/spec/helpers/checkForSymbol.js +0 -28
  75. data/lib/jasmine-core/spec/helpers/checkForTypedArrays.js +0 -20
  76. data/lib/jasmine-core/spec/helpers/defineJasmineUnderTest.js +0 -7
  77. data/lib/jasmine-core/spec/helpers/nodeDefineJasmineUnderTest.js +0 -33
  78. data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +0 -982
  79. data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +0 -18
  80. data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +0 -37
  81. data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +0 -15
  82. data/lib/jasmine-core/spec/html/QueryStringSpec.js +0 -72
  83. data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +0 -62
  84. data/lib/jasmine-core/spec/html/SpyRegistryHtmlSpec.js +0 -34
  85. data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +0 -101
  86. data/lib/jasmine-core/spec/performance/large_object_test.js +0 -36
  87. data/lib/jasmine-core/spec/performance/performance_test.js +0 -10
@@ -1,270 +0,0 @@
1
- describe("DelayedFunctionScheduler", function() {
2
- it("schedules a function for later execution", function() {
3
- var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
4
- fn = jasmine.createSpy('fn');
5
-
6
- scheduler.scheduleFunction(fn, 0);
7
-
8
- expect(fn).not.toHaveBeenCalled();
9
-
10
- scheduler.tick(0);
11
-
12
- expect(fn).toHaveBeenCalled();
13
- });
14
-
15
- it("schedules a string for later execution", function() {
16
- var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
17
- strfn = "horrible = true;";
18
-
19
- scheduler.scheduleFunction(strfn, 0);
20
-
21
- scheduler.tick(0);
22
-
23
- expect(horrible).toEqual(true);
24
- });
25
-
26
- it("#tick defaults to 0", function() {
27
- var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
28
- fn = jasmine.createSpy('fn');
29
-
30
- scheduler.scheduleFunction(fn, 0);
31
-
32
- expect(fn).not.toHaveBeenCalled();
33
-
34
- scheduler.tick();
35
-
36
- expect(fn).toHaveBeenCalled();
37
- });
38
-
39
- it("defaults delay to 0", function() {
40
- var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
41
- fn = jasmine.createSpy('fn');
42
-
43
- scheduler.scheduleFunction(fn);
44
-
45
- expect(fn).not.toHaveBeenCalled();
46
-
47
- scheduler.tick(0);
48
-
49
- expect(fn).toHaveBeenCalled();
50
- });
51
-
52
- it("optionally passes params to scheduled functions", function() {
53
- var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
54
- fn = jasmine.createSpy('fn');
55
-
56
- scheduler.scheduleFunction(fn, 0, ['foo', 'bar']);
57
-
58
- expect(fn).not.toHaveBeenCalled();
59
-
60
- scheduler.tick(0);
61
-
62
- expect(fn).toHaveBeenCalledWith('foo', 'bar');
63
- });
64
-
65
- it("scheduled fns can optionally reoccur", function() {
66
- var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
67
- fn = jasmine.createSpy('fn');
68
-
69
- scheduler.scheduleFunction(fn, 20, [], true);
70
-
71
- expect(fn).not.toHaveBeenCalled();
72
-
73
- scheduler.tick(20);
74
-
75
- expect(fn.calls.count()).toBe(1);
76
-
77
- scheduler.tick(40);
78
-
79
- expect(fn.calls.count()).toBe(3);
80
-
81
- scheduler.tick(21);
82
-
83
- expect(fn.calls.count()).toBe(4);
84
-
85
- });
86
-
87
- it("increments scheduled fns ids unless one is passed", function() {
88
- var scheduler = new jasmineUnderTest.DelayedFunctionScheduler();
89
-
90
- expect(scheduler.scheduleFunction(function() {
91
- }, 0)).toBe(1);
92
- expect(scheduler.scheduleFunction(function() {
93
- }, 0)).toBe(2);
94
- expect(scheduler.scheduleFunction(function() {
95
- }, 0, [], false, 123)).toBe(123);
96
- expect(scheduler.scheduleFunction(function() {
97
- }, 0)).toBe(3);
98
- });
99
-
100
- it("#removeFunctionWithId removes a previously scheduled function with a given id", function() {
101
- var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
102
- fn = jasmine.createSpy('fn'),
103
- timeoutKey;
104
-
105
- timeoutKey = scheduler.scheduleFunction(fn, 0);
106
-
107
- expect(fn).not.toHaveBeenCalled();
108
-
109
- scheduler.removeFunctionWithId(timeoutKey);
110
-
111
- scheduler.tick(0);
112
-
113
- expect(fn).not.toHaveBeenCalled();
114
- });
115
-
116
- it("executes recurring functions interleaved with regular functions in the correct order", function() {
117
- var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
118
- fn = jasmine.createSpy('fn'),
119
- recurringCallCount = 0,
120
- recurring = jasmine.createSpy('recurring').and.callFake(function() {
121
- recurringCallCount++;
122
- if (recurringCallCount < 5) {
123
- expect(fn).not.toHaveBeenCalled();
124
- }
125
- });
126
-
127
- scheduler.scheduleFunction(recurring, 10, [], true);
128
- scheduler.scheduleFunction(fn, 50);
129
-
130
- scheduler.tick(60);
131
-
132
- expect(recurring).toHaveBeenCalled();
133
- expect(recurring.calls.count()).toBe(6);
134
- expect(fn).toHaveBeenCalled();
135
- });
136
-
137
- it("schedules a function for later execution during a tick", function () {
138
- var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
139
- fn = jasmine.createSpy('fn'),
140
- fnDelay = 10;
141
-
142
- scheduler.scheduleFunction(function () {
143
- scheduler.scheduleFunction(fn, fnDelay);
144
- }, 0);
145
-
146
- expect(fn).not.toHaveBeenCalled();
147
-
148
- scheduler.tick(fnDelay);
149
-
150
- expect(fn).toHaveBeenCalled();
151
- });
152
-
153
- it("#removeFunctionWithId removes a previously scheduled function with a given id during a tick", function () {
154
- var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
155
- fn = jasmine.createSpy('fn'),
156
- fnDelay = 10,
157
- timeoutKey;
158
-
159
- scheduler.scheduleFunction(function () {
160
- scheduler.removeFunctionWithId(timeoutKey);
161
- }, 0);
162
- timeoutKey = scheduler.scheduleFunction(fn, fnDelay);
163
-
164
- expect(fn).not.toHaveBeenCalled();
165
-
166
- scheduler.tick(fnDelay);
167
-
168
- expect(fn).not.toHaveBeenCalled();
169
- });
170
-
171
- it("executes recurring functions interleaved with regular functions and functions scheduled during a tick in the correct order", function () {
172
- var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
173
- fn = jasmine.createSpy('fn'),
174
- recurringCallCount = 0,
175
- recurring = jasmine.createSpy('recurring').and.callFake(function() {
176
- recurringCallCount++;
177
- if (recurringCallCount < 5) {
178
- expect(fn).not.toHaveBeenCalled();
179
- }
180
- }),
181
- innerFn = jasmine.createSpy('innerFn').and.callFake(function() {
182
- expect(recurring.calls.count()).toBe(4);
183
- expect(fn).not.toHaveBeenCalled();
184
- }),
185
- scheduling = jasmine.createSpy('scheduling').and.callFake(function() {
186
- expect(recurring.calls.count()).toBe(3);
187
- expect(fn).not.toHaveBeenCalled();
188
- scheduler.scheduleFunction(innerFn, 10); // 41ms absolute
189
- });
190
-
191
- scheduler.scheduleFunction(recurring, 10, [], true);
192
- scheduler.scheduleFunction(fn, 50);
193
- scheduler.scheduleFunction(scheduling, 31);
194
-
195
- scheduler.tick(60);
196
-
197
- expect(recurring).toHaveBeenCalled();
198
- expect(recurring.calls.count()).toBe(6);
199
- expect(fn).toHaveBeenCalled();
200
- expect(scheduling).toHaveBeenCalled();
201
- expect(innerFn).toHaveBeenCalled();
202
- });
203
-
204
- it("executes recurring functions after rescheduling them", function () {
205
- var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
206
- recurring = function() {
207
- expect(scheduler.scheduleFunction).toHaveBeenCalled();
208
- };
209
-
210
- scheduler.scheduleFunction(recurring, 10, [], true);
211
-
212
- spyOn(scheduler, "scheduleFunction");
213
-
214
- scheduler.tick(10);
215
- });
216
-
217
- it("removes functions during a tick that runs the function", function() {
218
- var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
219
- spy = jasmine.createSpy('fn'),
220
- spyAndRemove = jasmine.createSpy('fn'),
221
- fnDelay = 10,
222
- timeoutKey;
223
-
224
- spyAndRemove.and.callFake(function() {
225
- scheduler.removeFunctionWithId(timeoutKey);
226
- });
227
-
228
- scheduler.scheduleFunction(spyAndRemove, fnDelay);
229
-
230
- timeoutKey = scheduler.scheduleFunction(spy, fnDelay, [], true);
231
-
232
- scheduler.tick(2 * fnDelay);
233
-
234
- expect(spy).not.toHaveBeenCalled();
235
- expect(spyAndRemove).toHaveBeenCalled();
236
- });
237
-
238
- it("removes functions during the first tick that runs the function", function() {
239
- var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
240
- fn = jasmine.createSpy('fn'),
241
- fnDelay = 10,
242
- timeoutKey;
243
-
244
- timeoutKey = scheduler.scheduleFunction(fn, fnDelay, [], true);
245
- scheduler.scheduleFunction(function () {
246
- scheduler.removeFunctionWithId(timeoutKey);
247
- }, fnDelay);
248
-
249
- expect(fn).not.toHaveBeenCalled();
250
-
251
- scheduler.tick(3 * fnDelay);
252
-
253
- expect(fn).toHaveBeenCalled();
254
- expect(fn.calls.count()).toBe(1);
255
- });
256
-
257
- it("updates the mockDate per scheduled time", function () {
258
- var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
259
- tickDate = jasmine.createSpy('tickDate');
260
-
261
- scheduler.scheduleFunction(function() {});
262
- scheduler.scheduleFunction(function() {}, 1);
263
-
264
- scheduler.tick(1, tickDate);
265
-
266
- expect(tickDate).toHaveBeenCalledWith(0);
267
- expect(tickDate).toHaveBeenCalledWith(1);
268
- })
269
- });
270
-
@@ -1,200 +0,0 @@
1
- // TODO: Fix these unit tests!
2
- describe("Env", function() {
3
- var env;
4
- beforeEach(function() {
5
- env = new jasmineUnderTest.Env();
6
- });
7
-
8
- describe("#pending", function() {
9
- it("throws the Pending Spec exception", function() {
10
- expect(function() {
11
- env.pending();
12
- }).toThrow(jasmineUnderTest.Spec.pendingSpecExceptionMessage);
13
- });
14
-
15
- it("throws the Pending Spec exception with a custom message", function() {
16
- expect(function() {
17
- env.pending('custom message');
18
- }).toThrow(jasmineUnderTest.Spec.pendingSpecExceptionMessage + 'custom message');
19
- });
20
- });
21
-
22
- describe("#topSuite", function() {
23
- it("returns the Jasmine top suite for users to traverse the spec tree", function() {
24
- var suite = env.topSuite();
25
- expect(suite.description).toEqual('Jasmine__TopLevel__Suite');
26
- });
27
- });
28
-
29
- it('can configure specs to throw errors on expectation failures', function() {
30
- env.throwOnExpectationFailure(true);
31
-
32
- spyOn(jasmineUnderTest, 'Spec');
33
- env.it('foo', function() {});
34
- expect(jasmineUnderTest.Spec).toHaveBeenCalledWith(jasmine.objectContaining({
35
- throwOnExpectationFailure: true
36
- }));
37
- });
38
-
39
- it('can configure suites to throw errors on expectation failures', function() {
40
- env.throwOnExpectationFailure(true);
41
-
42
- spyOn(jasmineUnderTest, 'Suite');
43
- env.describe('foo', function() {});
44
- expect(jasmineUnderTest.Suite).toHaveBeenCalledWith(jasmine.objectContaining({
45
- throwOnExpectationFailure: true
46
- }));
47
- });
48
-
49
- describe('#describe', function () {
50
- it("throws an error when given arguments", function() {
51
- expect(function() {
52
- env.describe('done method', function(done) {});
53
- }).toThrowError('describe does not expect any arguments');
54
- });
55
-
56
- it('throws an error when it receives a non-fn argument', function() {
57
- // Some versions of PhantomJS return [object DOMWindow] when
58
- // Object.prototype.toString.apply is called with `undefined` or `null`.
59
- // In a similar fashion, IE8 gives [object Object] for both `undefined`
60
- // and `null`. We mostly just want these tests to check that using
61
- // anything other than a function throws an error.
62
- expect(function() {
63
- env.describe('undefined arg', undefined);
64
- }).toThrowError(/describe expects a function argument; received \[object (Undefined|DOMWindow|Object)\]/);
65
- expect(function() {
66
- env.describe('null arg', null);
67
- }).toThrowError(/describe expects a function argument; received \[object (Null|DOMWindow|Object)\]/);
68
-
69
- expect(function() {
70
- env.describe('array arg', []);
71
- }).toThrowError('describe expects a function argument; received [object Array]');
72
- expect(function() {
73
- env.describe('object arg', {});
74
- }).toThrowError('describe expects a function argument; received [object Object]');
75
-
76
- expect(function() {
77
- env.describe('fn arg', function() {});
78
- }).not.toThrowError('describe expects a function argument; received [object Function]');
79
- });
80
- });
81
-
82
- describe('#it', function () {
83
- it('throws an error when it receives a non-fn argument', function() {
84
- expect(function() {
85
- env.it('undefined arg', null);
86
- }).toThrowError(/it expects a function argument; received \[object (Null|DOMWindow|Object)\]/);
87
- });
88
-
89
- it('does not throw when it is not given a fn argument', function() {
90
- expect(function() {
91
- env.it('pending spec');
92
- }).not.toThrow();
93
- });
94
-
95
- it('accepts an async function', function() {
96
- jasmine.getEnv().requireAsyncAwait();
97
- expect(function() {
98
- env.it('async', jasmine.getEnv().makeAsyncAwaitFunction());
99
- }).not.toThrow();
100
- });
101
- });
102
-
103
- describe('#xit', function() {
104
- it('calls spec.pend with "Temporarily disabled with xit"', function() {
105
- var pendSpy = jasmine.createSpy();
106
- spyOn(env, 'it').and.returnValue({
107
- pend: pendSpy
108
- });
109
- env.xit('foo', function() {});
110
- expect(pendSpy).toHaveBeenCalledWith('Temporarily disabled with xit');
111
- });
112
-
113
- it('throws an error when it receives a non-fn argument', function() {
114
- expect(function() {
115
- env.xit('undefined arg', null);
116
- }).toThrowError(/xit expects a function argument; received \[object (Null|DOMWindow|Object)\]/);
117
- });
118
-
119
- it('does not throw when it is not given a fn argument', function() {
120
- expect(function() {
121
- env.xit('pending spec');
122
- }).not.toThrow();
123
- });
124
-
125
- it('accepts an async function', function() {
126
- jasmine.getEnv().requireAsyncAwait();
127
- expect(function() {
128
- env.xit('async', jasmine.getEnv().makeAsyncAwaitFunction());
129
- }).not.toThrow();
130
- });
131
- });
132
-
133
- describe('#fit', function () {
134
- it('throws an error when it receives a non-fn argument', function() {
135
- expect(function() {
136
- env.fit('undefined arg', undefined);
137
- }).toThrowError(/fit expects a function argument; received \[object (Undefined|DOMWindow|Object)\]/);
138
- });
139
- });
140
-
141
- describe('#beforeEach', function () {
142
- it('throws an error when it receives a non-fn argument', function() {
143
- expect(function() {
144
- env.beforeEach(undefined);
145
- }).toThrowError(/beforeEach expects a function argument; received \[object (Undefined|DOMWindow|Object)\]/);
146
- });
147
-
148
- it('accepts an async function', function() {
149
- jasmine.getEnv().requireAsyncAwait();
150
- expect(function() {
151
- env.beforeEach(jasmine.getEnv().makeAsyncAwaitFunction());
152
- }).not.toThrow();
153
- });
154
- });
155
-
156
- describe('#beforeAll', function () {
157
- it('throws an error when it receives a non-fn argument', function() {
158
- expect(function() {
159
- env.beforeAll(undefined);
160
- }).toThrowError(/beforeAll expects a function argument; received \[object (Undefined|DOMWindow|Object)\]/);
161
- });
162
-
163
- it('accepts an async function', function() {
164
- jasmine.getEnv().requireAsyncAwait();
165
- expect(function() {
166
- env.beforeAll(jasmine.getEnv().makeAsyncAwaitFunction());
167
- }).not.toThrow();
168
- });
169
- });
170
-
171
- describe('#afterEach', function () {
172
- it('throws an error when it receives a non-fn argument', function() {
173
- expect(function() {
174
- env.afterEach(undefined);
175
- }).toThrowError(/afterEach expects a function argument; received \[object (Undefined|DOMWindow|Object)\]/);
176
- });
177
-
178
- it('accepts an async function', function() {
179
- jasmine.getEnv().requireAsyncAwait();
180
- expect(function() {
181
- env.afterEach(jasmine.getEnv().makeAsyncAwaitFunction());
182
- }).not.toThrow();
183
- });
184
- });
185
-
186
- describe('#afterAll', function () {
187
- it('throws an error when it receives a non-fn argument', function() {
188
- expect(function() {
189
- env.afterAll(undefined);
190
- }).toThrowError(/afterAll expects a function argument; received \[object (Undefined|DOMWindow|Object)\]/);
191
- });
192
-
193
- it('accepts an async function', function() {
194
- jasmine.getEnv().requireAsyncAwait();
195
- expect(function() {
196
- env.afterAll(jasmine.getEnv().makeAsyncAwaitFunction());
197
- }).not.toThrow();
198
- });
199
- });
200
- });
@@ -1,63 +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 from Webkit, Firefox, node.js or IE10+", function() {
51
- if (jasmine.getEnv().ieVersion < 10 || jasmine.getEnv().safariVersion < 6) { return; }
52
-
53
- var error;
54
- try { throw new Error("an error") } catch(e) { error = e; }
55
-
56
- expect(new jasmineUnderTest.ExceptionFormatter().stack(error)).toMatch(/ExceptionFormatterSpec\.js.*\d+/)
57
- });
58
-
59
- it("returns null if no Error provided", function() {
60
- expect(new jasmineUnderTest.ExceptionFormatter().stack()).toBeNull();
61
- });
62
- });
63
- });
@@ -1,68 +0,0 @@
1
- describe('Exceptions:', function() {
2
- var env;
3
-
4
- beforeEach(function() {
5
- env = new jasmineUnderTest.Env();
6
- });
7
-
8
- describe('with break on exception', function() {
9
- it('should not catch the exception', function() {
10
- env.catchExceptions(false);
11
- env.describe('suite for break on exceptions', function() {
12
- env.it('should break when an exception is thrown', function() {
13
- throw new Error('I should hit a breakpoint!');
14
- });
15
- });
16
- var spy = jasmine.createSpy('spy');
17
-
18
- try {
19
- env.execute();
20
- spy();
21
- }
22
- catch (e) {}
23
-
24
- expect(spy).not.toHaveBeenCalled();
25
- });
26
- });
27
-
28
- describe("with catch on exception", function() {
29
- it('should handle exceptions thrown, but continue', function(done) {
30
- var secondTest = jasmine.createSpy('second test');
31
- env.describe('Suite for handles exceptions', function () {
32
- env.it('should be a test that fails because it throws an exception', function() {
33
- throw new Error();
34
- });
35
- env.it('should be a passing test that runs after exceptions are thrown from a async test', secondTest);
36
- });
37
-
38
- var expectations = function() {
39
- expect(secondTest).toHaveBeenCalled();
40
- done();
41
- };
42
-
43
- env.addReporter({ jasmineDone: expectations });
44
- env.execute();
45
- });
46
-
47
- it("should handle exceptions thrown directly in top-level describe blocks and continue", function(done) {
48
- var secondDescribe = jasmine.createSpy("second describe");
49
- env.describe("a suite that throws an exception", function () {
50
- env.it("is a test that should pass", function () {
51
- this.expect(true).toEqual(true);
52
- });
53
-
54
- throw new Error("top level error");
55
- });
56
- env.describe("a suite that doesn't throw an exception", secondDescribe);
57
-
58
- var expectations = function() {
59
- expect(secondDescribe).toHaveBeenCalled();
60
- done();
61
- };
62
-
63
- env.addReporter({ jasmineDone: expectations });
64
- env.execute();
65
- });
66
- });
67
- });
68
-
@@ -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
- });