jasmine-core 1.3.1 → 2.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/lib/jasmine-core.rb +14 -1
  2. data/lib/jasmine-core/boot.js +131 -0
  3. data/lib/jasmine-core/boot/boot.js +109 -0
  4. data/lib/jasmine-core/example/spec/PlayerSpec.js +2 -2
  5. data/lib/jasmine-core/example/spec/SpecHelper.js +14 -8
  6. data/lib/jasmine-core/jasmine-html.js +289 -616
  7. data/lib/jasmine-core/jasmine.css +52 -80
  8. data/lib/jasmine-core/jasmine.js +1972 -2211
  9. data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +161 -386
  10. data/lib/jasmine-core/spec/core/AnySpec.js +45 -0
  11. data/lib/jasmine-core/spec/core/CallTrackerSpec.js +105 -0
  12. data/lib/jasmine-core/spec/core/ClockSpec.js +314 -0
  13. data/lib/jasmine-core/spec/core/CustomMatchersSpec.js +96 -97
  14. data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +179 -0
  15. data/lib/jasmine-core/spec/core/EnvSpec.js +454 -102
  16. data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +56 -0
  17. data/lib/jasmine-core/spec/core/ExceptionsSpec.js +15 -126
  18. data/lib/jasmine-core/spec/core/ExpectationResultSpec.js +61 -0
  19. data/lib/jasmine-core/spec/core/ExpectationSpec.js +320 -0
  20. data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +150 -38
  21. data/lib/jasmine-core/spec/core/ObjectContainingSpec.js +64 -0
  22. data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +43 -42
  23. data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +147 -0
  24. data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +40 -0
  25. data/lib/jasmine-core/spec/core/SpecRunningSpec.js +92 -1075
  26. data/lib/jasmine-core/spec/core/SpecSpec.js +215 -95
  27. data/lib/jasmine-core/spec/core/SpySpec.js +28 -196
  28. data/lib/jasmine-core/spec/core/SpyStrategySpec.js +101 -0
  29. data/lib/jasmine-core/spec/core/SuiteSpec.js +216 -106
  30. data/lib/jasmine-core/spec/core/TimerSpec.js +13 -0
  31. data/lib/jasmine-core/spec/core/UtilSpec.js +19 -30
  32. data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +219 -0
  33. data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +51 -0
  34. data/lib/jasmine-core/spec/core/matchers/toBeDefinedSpec.js +18 -0
  35. data/lib/jasmine-core/spec/core/matchers/toBeFalsySpec.js +38 -0
  36. data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +19 -0
  37. data/lib/jasmine-core/spec/core/matchers/toBeLessThanSpec.js +20 -0
  38. data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +36 -0
  39. data/lib/jasmine-core/spec/core/matchers/toBeNullSpec.js +17 -0
  40. data/lib/jasmine-core/spec/core/matchers/toBeSpec.js +17 -0
  41. data/lib/jasmine-core/spec/core/matchers/toBeTruthySpec.js +38 -0
  42. data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +17 -0
  43. data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +24 -0
  44. data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +28 -0
  45. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +46 -0
  46. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +57 -0
  47. data/lib/jasmine-core/spec/core/matchers/toMatchSpec.js +34 -0
  48. data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +280 -0
  49. data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +98 -0
  50. data/lib/jasmine-core/spec/helpers/BrowserFlags.js +19 -0
  51. data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +494 -0
  52. data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +18 -0
  53. data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +8 -8
  54. data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +3 -3
  55. data/lib/jasmine-core/spec/html/QueryStringSpec.js +43 -0
  56. data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +62 -0
  57. data/lib/jasmine-core/spec/node_suite.js +137 -79
  58. data/lib/jasmine-core/spec/performance/performance_test.js +10 -0
  59. data/lib/jasmine-core/spec/support/dev_boot.js +118 -0
  60. data/lib/jasmine-core/version.rb +5 -2
  61. metadata +47 -103
  62. data/lib/jasmine-core/example/SpecRunner.html +0 -54
  63. data/lib/jasmine-core/spec/core/BaseSpec.js +0 -27
  64. data/lib/jasmine-core/spec/core/MatchersSpec.js +0 -1157
  65. data/lib/jasmine-core/spec/core/MockClockSpec.js +0 -38
  66. data/lib/jasmine-core/spec/core/MultiReporterSpec.js +0 -45
  67. data/lib/jasmine-core/spec/core/NestedResultsSpec.js +0 -54
  68. data/lib/jasmine-core/spec/core/QueueSpec.js +0 -23
  69. data/lib/jasmine-core/spec/core/ReporterSpec.js +0 -56
  70. data/lib/jasmine-core/spec/core/RunnerSpec.js +0 -280
  71. data/lib/jasmine-core/spec/core/WaitsForBlockSpec.js +0 -118
  72. data/lib/jasmine-core/spec/html/HTMLReporterSpec.js +0 -209
  73. data/lib/jasmine-core/spec/html/TrivialReporterSpec.js +0 -239
@@ -0,0 +1,45 @@
1
+ describe("Any", function() {
2
+ it("matches a string", function() {
3
+ var any = new j$.Any(String);
4
+
5
+ expect(any.jasmineMatches("foo")).toBe(true);
6
+ });
7
+
8
+ it("matches a number", function() {
9
+ var any = new j$.Any(Number);
10
+
11
+ expect(any.jasmineMatches(1)).toBe(true);
12
+ });
13
+
14
+ it("matches a function", function() {
15
+ var any = new j$.Any(Function);
16
+
17
+ expect(any.jasmineMatches(function(){})).toBe(true);
18
+ });
19
+
20
+ it("matches an Object", function() {
21
+ var any = new j$.Any(Object);
22
+
23
+ expect(any.jasmineMatches({})).toBe(true);
24
+ });
25
+
26
+ it("matches a Boolean", function() {
27
+ var any = new j$.Any(Boolean);
28
+
29
+ expect(any.jasmineMatches(true)).toBe(true);
30
+ });
31
+
32
+ it("matches another constructed object", function() {
33
+ var Thing = function() {},
34
+ any = new j$.Any(Thing);
35
+
36
+ expect(any.jasmineMatches(new Thing())).toBe(true);
37
+ });
38
+
39
+ it("jasmineToString's itself", function() {
40
+ var any = new j$.Any(Number);
41
+
42
+ expect(any.jasmineToString()).toMatch('<jasmine.any');
43
+ });
44
+
45
+ });
@@ -0,0 +1,105 @@
1
+ describe("CallTracker", function() {
2
+ it("tracks that it was called when executed", function() {
3
+ var callTracker = new j$.CallTracker();
4
+
5
+ expect(callTracker.any()).toBe(false);
6
+
7
+ callTracker.track();
8
+
9
+ expect(callTracker.any()).toBe(true);
10
+ });
11
+
12
+ it("tracks that number of times that it is executed", function() {
13
+ var callTracker = new j$.CallTracker();
14
+
15
+ expect(callTracker.count()).toEqual(0);
16
+
17
+ callTracker.track();
18
+
19
+ expect(callTracker.count()).toEqual(1);
20
+ });
21
+
22
+ it("tracks the params from each execution", function() {
23
+ var callTracker = new j$.CallTracker();
24
+
25
+ callTracker.track({object: void 0, args: []});
26
+ callTracker.track({object: {}, args: [0, "foo"]});
27
+
28
+ expect(callTracker.argsFor(0)).toEqual([]);
29
+
30
+ expect(callTracker.argsFor(1)).toEqual([0, "foo"]);
31
+ });
32
+
33
+ it("returns any empty array when there was no call", function() {
34
+ var callTracker = new j$.CallTracker();
35
+
36
+ expect(callTracker.argsFor(0)).toEqual([]);
37
+ });
38
+
39
+ it("allows access for the arguments for all calls", function() {
40
+ var callTracker = new j$.CallTracker();
41
+
42
+ callTracker.track({object: {}, args: []});
43
+ callTracker.track({object: {}, args: [0, "foo"]});
44
+
45
+ expect(callTracker.allArgs()).toEqual([[], [0, "foo"]]);
46
+ });
47
+
48
+ it("tracks the context and arguments for each call", function() {
49
+ var callTracker = new j$.CallTracker();
50
+
51
+ callTracker.track({object: {}, args: []});
52
+ callTracker.track({object: {}, args: [0, "foo"]});
53
+
54
+ expect(callTracker.all()[0]).toEqual({object: {}, args: []});
55
+
56
+ expect(callTracker.all()[1]).toEqual({object: {}, args: [0, "foo"]});
57
+ });
58
+
59
+ it("simplifies access to the arguments for the last (most recent) call", function() {
60
+ var callTracker = new j$.CallTracker();
61
+
62
+ callTracker.track();
63
+ callTracker.track({object: {}, args: [0, "foo"]});
64
+
65
+ expect(callTracker.mostRecent()).toEqual({
66
+ object: {},
67
+ args: [0, "foo"]
68
+ });
69
+ });
70
+
71
+ it("returns a useful falsy value when there isn't a last (most recent) call", function() {
72
+ var callTracker = new j$.CallTracker();
73
+
74
+ expect(callTracker.mostRecent()).toBeFalsy();
75
+ });
76
+
77
+ it("simplifies access to the arguments for the first (oldest) call", function() {
78
+ var callTracker = new j$.CallTracker();
79
+
80
+ callTracker.track({object: {}, args: [0, "foo"]});
81
+
82
+ expect(callTracker.first()).toEqual({object: {}, args: [0, "foo"]})
83
+ });
84
+
85
+ it("returns a useful falsy value when there isn't a first (oldest) call", function() {
86
+ var callTracker = new j$.CallTracker();
87
+
88
+ expect(callTracker.first()).toBeFalsy();
89
+ });
90
+
91
+
92
+ it("allows the tracking to be reset", function() {
93
+ var callTracker = new j$.CallTracker();
94
+
95
+ callTracker.track();
96
+ callTracker.track({object: {}, args: [0, "foo"]});
97
+ callTracker.reset();
98
+
99
+ expect(callTracker.any()).toBe(false);
100
+ expect(callTracker.count()).toEqual(0);
101
+ expect(callTracker.argsFor(0)).toEqual([]);
102
+ expect(callTracker.all()).toEqual([]);
103
+ expect(callTracker.mostRecent()).toBeFalsy();
104
+ });
105
+ });
@@ -0,0 +1,314 @@
1
+ describe("Clock", function() {
2
+
3
+ it("calls the global setTimeout directly if Clock is not installed", function() {
4
+ var setTimeout = jasmine.createSpy('setTimeout'),
5
+ delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['scheduleFunction']),
6
+ global = { setTimeout: setTimeout },
7
+ delayedFn = jasmine.createSpy('delayedFn'),
8
+ clock = new j$.Clock(global, delayedFunctionScheduler);
9
+
10
+ clock.setTimeout(delayedFn, 0);
11
+
12
+ expect(delayedFunctionScheduler.scheduleFunction).not.toHaveBeenCalled();
13
+ expect(setTimeout).toHaveBeenCalledWith(delayedFn, 0);
14
+ });
15
+
16
+ it("schedules the delayed function with the fake timer", function() {
17
+ var setTimeout = jasmine.createSpy('setTimeout'),
18
+ scheduleFunction = jasmine.createSpy('scheduleFunction'),
19
+ delayedFunctionScheduler = {scheduleFunction: scheduleFunction},
20
+ global = { setTimeout: setTimeout },
21
+ delayedFn = jasmine.createSpy('delayedFn'),
22
+ clock = new j$.Clock(global, delayedFunctionScheduler);
23
+
24
+ clock.install();
25
+ clock.setTimeout(delayedFn, 0, 'a', 'b');
26
+
27
+ expect(setTimeout).not.toHaveBeenCalled();
28
+ expect(delayedFunctionScheduler.scheduleFunction).toHaveBeenCalledWith(delayedFn, 0, ['a', 'b']);
29
+ });
30
+
31
+ it("returns an id for the delayed function", function() {
32
+ var setTimeout = jasmine.createSpy('setTimeout'),
33
+ scheduleId = 123,
34
+ scheduleFunction = jasmine.createSpy('scheduleFunction').and.callReturn(scheduleId),
35
+ delayedFunctionScheduler = {scheduleFunction: scheduleFunction},
36
+ global = { setTimeout: setTimeout },
37
+ delayedFn = jasmine.createSpy('delayedFn'),
38
+ clock = new j$.Clock(global, delayedFunctionScheduler),
39
+ timeoutId;
40
+
41
+ clock.install();
42
+ timeoutId = clock.setTimeout(delayedFn, 0);
43
+
44
+ expect(timeoutId).toEqual(123);
45
+ });
46
+
47
+ it("calls the global clearTimeout directly if Clock is not installed", function() {
48
+ var clearTimeout = jasmine.createSpy('clearTimeout'),
49
+ delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['clearTimeout']),
50
+ global = { clearTimeout: clearTimeout },
51
+ clock = new j$.Clock(global, delayedFunctionScheduler);
52
+
53
+ clock.clearTimeout(123);
54
+
55
+ expect(clearTimeout).toHaveBeenCalledWith(123);
56
+ });
57
+
58
+ it("clears the scheduled function with the scheduler", function() {
59
+ var clearTimeout = jasmine.createSpy('clearTimeout'),
60
+ delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['removeFunctionWithId']),
61
+ global = { setTimeout: clearTimeout },
62
+ delayedFn = jasmine.createSpy('delayedFn'),
63
+ clock = new j$.Clock(global, delayedFunctionScheduler);
64
+
65
+ clock.install();
66
+ clock.clearTimeout(123);
67
+
68
+ expect(clearTimeout).not.toHaveBeenCalled();
69
+ expect(delayedFunctionScheduler.removeFunctionWithId).toHaveBeenCalledWith(123);
70
+ });
71
+
72
+ it("calls the global setInterval directly if Clock is not installed", function() {
73
+ var setInterval = jasmine.createSpy('setInterval'),
74
+ delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['scheduleFunction']),
75
+ global = { setInterval: setInterval },
76
+ delayedFn = jasmine.createSpy('delayedFn'),
77
+ clock = new j$.Clock(global, delayedFunctionScheduler);
78
+
79
+ clock.setInterval(delayedFn, 0);
80
+
81
+ expect(delayedFunctionScheduler.scheduleFunction).not.toHaveBeenCalled();
82
+ expect(setInterval).toHaveBeenCalledWith(delayedFn, 0);
83
+ });
84
+
85
+ it("schedules the delayed function with the fake timer", function() {
86
+ var setInterval = jasmine.createSpy('setInterval'),
87
+ scheduleFunction = jasmine.createSpy('scheduleFunction'),
88
+ delayedFunctionScheduler = {scheduleFunction: scheduleFunction},
89
+ global = { setInterval: setInterval },
90
+ delayedFn = jasmine.createSpy('delayedFn'),
91
+ clock = new j$.Clock(global, delayedFunctionScheduler);
92
+
93
+ clock.install();
94
+ clock.setInterval(delayedFn, 0, 'a', 'b');
95
+
96
+ expect(setInterval).not.toHaveBeenCalled();
97
+ expect(delayedFunctionScheduler.scheduleFunction).toHaveBeenCalledWith(delayedFn, 0, ['a', 'b'], true);
98
+ });
99
+
100
+ it("returns an id for the delayed function", function() {
101
+ var setInterval = jasmine.createSpy('setInterval'),
102
+ scheduleId = 123,
103
+ scheduleFunction = jasmine.createSpy('scheduleFunction').and.callReturn(scheduleId),
104
+ delayedFunctionScheduler = {scheduleFunction: scheduleFunction},
105
+ global = { setInterval: setInterval },
106
+ delayedFn = jasmine.createSpy('delayedFn'),
107
+ clock = new j$.Clock(global, delayedFunctionScheduler),
108
+ intervalId;
109
+
110
+ clock.install();
111
+ intervalId = clock.setInterval(delayedFn, 0);
112
+
113
+ expect(intervalId).toEqual(123);
114
+ });
115
+
116
+ it("calls the global clearInterval directly if Clock is not installed", function() {
117
+ var clearInterval = jasmine.createSpy('clearInterval'),
118
+ delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['clearInterval']),
119
+ global = { clearInterval: clearInterval },
120
+ clock = new j$.Clock(global, delayedFunctionScheduler);
121
+
122
+ clock.clearInterval(123);
123
+
124
+ expect(clearInterval).toHaveBeenCalledWith(123);
125
+ });
126
+
127
+ it("clears the scheduled function with the scheduler", function() {
128
+ var clearInterval = jasmine.createSpy('clearInterval'),
129
+ delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['removeFunctionWithId']),
130
+ global = { setInterval: clearInterval },
131
+ delayedFn = jasmine.createSpy('delayedFn'),
132
+ clock = new j$.Clock(global, delayedFunctionScheduler);
133
+
134
+ clock.install();
135
+ clock.clearInterval(123);
136
+
137
+ expect(clearInterval).not.toHaveBeenCalled();
138
+ expect(delayedFunctionScheduler.removeFunctionWithId).toHaveBeenCalledWith(123);
139
+ });
140
+
141
+ it("gives you a friendly reminder if the Clock is not installed and you tick", function() {
142
+ var clock = new j$.Clock({}, jasmine.createSpyObj('delayedFunctionScheduler', ['tick']));
143
+ expect(function() {
144
+ clock.tick(50);
145
+ }).toThrow();
146
+ });
147
+
148
+ it("can be uninstalled", function() {
149
+ var setTimeout = jasmine.createSpy('setTimeout'),
150
+ setInterval = jasmine.createSpy('setInterval'),
151
+ delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['scheduleFunction', 'tick', 'reset']),
152
+ global = { setTimeout: setTimeout, setInterval: setInterval },
153
+ delayedFn = jasmine.createSpy('delayedFn'),
154
+ clock = new j$.Clock(global, delayedFunctionScheduler);
155
+
156
+ clock.install();
157
+ clock.setTimeout(delayedFn, 0);
158
+ expect(setTimeout).not.toHaveBeenCalled();
159
+
160
+ clock.setInterval(delayedFn, 0);
161
+ expect(setInterval).not.toHaveBeenCalled();
162
+
163
+ expect(function() {
164
+ clock.tick(0);
165
+ }).not.toThrow();
166
+
167
+ clock.uninstall();
168
+
169
+ expect(delayedFunctionScheduler.reset).toHaveBeenCalled();
170
+
171
+ clock.setTimeout(delayedFn, 0);
172
+
173
+ expect(setTimeout).toHaveBeenCalled();
174
+
175
+ clock.setInterval(delayedFn, 0);
176
+ expect(setInterval).toHaveBeenCalled();
177
+
178
+ expect(function() {
179
+ clock.tick(0);
180
+ }).toThrow();
181
+ });
182
+
183
+
184
+ it("on IE < 9, fails if extra args are passed to fake clock", function() {
185
+ //fail, because this would break in IE9.
186
+ var setTimeout = jasmine.createSpy('setTimeout'),
187
+ setInterval = jasmine.createSpy('setInterval'),
188
+ delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['scheduleFunction']),
189
+ fn = jasmine.createSpy('fn'),
190
+ global = { setTimeout: setTimeout, setInterval: setInterval },
191
+ clock = new j$.Clock(global, delayedFunctionScheduler);
192
+
193
+ setTimeout.apply = null;
194
+ setInterval.apply = null;
195
+
196
+ clock.install();
197
+
198
+ clock.setTimeout(fn, 0);
199
+ expect(delayedFunctionScheduler.scheduleFunction).toHaveBeenCalledWith(fn, 0, []);
200
+ expect(function() {
201
+ clock.setTimeout(fn, 0, 'extra');
202
+ }).toThrow();
203
+
204
+ clock.setInterval(fn, 0);
205
+ expect(delayedFunctionScheduler.scheduleFunction).toHaveBeenCalledWith(fn, 0, [], true);
206
+ expect(function() {
207
+ clock.setInterval(fn, 0, 'extra');
208
+ }).toThrow();
209
+ });
210
+
211
+ });
212
+
213
+ describe("Clock (acceptance)", function() {
214
+ it("can run setTimeouts/setIntervals synchronously", function() {
215
+ var delayedFn1 = jasmine.createSpy('delayedFn1'),
216
+ delayedFn2 = jasmine.createSpy('delayedFn2'),
217
+ delayedFn3 = jasmine.createSpy('delayedFn3'),
218
+ recurring1 = jasmine.createSpy('recurring1'),
219
+ delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
220
+ clock = new j$.Clock({setTimeout: setTimeout}, delayedFunctionScheduler);
221
+
222
+ clock.install();
223
+
224
+ clock.setTimeout(delayedFn1, 0, 'some', 'arg');
225
+ var intervalId = clock.setInterval(recurring1, 50, 'some', 'other', 'args');
226
+ clock.setTimeout(delayedFn2, 100);
227
+ clock.setTimeout(delayedFn3, 200);
228
+
229
+ expect(delayedFn1).not.toHaveBeenCalled();
230
+ expect(delayedFn2).not.toHaveBeenCalled();
231
+ expect(delayedFn3).not.toHaveBeenCalled();
232
+
233
+ clock.tick(0);
234
+
235
+ expect(delayedFn1).toHaveBeenCalledWith('some', 'arg');
236
+ expect(delayedFn2).not.toHaveBeenCalled();
237
+ expect(delayedFn3).not.toHaveBeenCalled();
238
+
239
+ clock.tick(50);
240
+
241
+ expect(recurring1).toHaveBeenCalledWith('some', 'other', 'args');
242
+ expect(recurring1.calls.count()).toBe(1);
243
+ expect(delayedFn2).not.toHaveBeenCalled();
244
+ expect(delayedFn3).not.toHaveBeenCalled();
245
+
246
+ clock.tick(50);
247
+
248
+ expect(recurring1.calls.count()).toBe(2);
249
+ expect(delayedFn2).toHaveBeenCalled();
250
+ expect(delayedFn3).not.toHaveBeenCalled();
251
+
252
+ clock.tick(100);
253
+
254
+ expect(recurring1.calls.count()).toBe(4);
255
+ expect(delayedFn3).toHaveBeenCalled();
256
+
257
+ clock.clearInterval(intervalId);
258
+ clock.tick(50);
259
+
260
+ expect(recurring1.calls.count()).toBe(4);
261
+ });
262
+
263
+ it("can clear a previously set timeout", function() {
264
+ var clearedFn = jasmine.createSpy('clearedFn'),
265
+ delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
266
+ clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler),
267
+ timeoutId;
268
+
269
+ clock.install();
270
+
271
+ timeoutId = clock.setTimeout(clearedFn, 100);
272
+ expect(clearedFn).not.toHaveBeenCalled();
273
+
274
+ clock.clearTimeout(timeoutId);
275
+ clock.tick(100);
276
+
277
+ expect(clearedFn).not.toHaveBeenCalled();
278
+ });
279
+
280
+ it("correctly schedules functions after the Clock has advanced", function() {
281
+ var delayedFn1 = jasmine.createSpy('delayedFn1'),
282
+ delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
283
+ clock = new j$.Clock({setTimeout: function(){}}, delayedFunctionScheduler);
284
+
285
+ clock.install();
286
+
287
+ clock.tick(100);
288
+ clock.setTimeout(delayedFn1, 10, ['some', 'arg']);
289
+ clock.tick(5);
290
+ expect(delayedFn1).not.toHaveBeenCalled();
291
+ clock.tick(5);
292
+ expect(delayedFn1).toHaveBeenCalled();
293
+ });
294
+
295
+ it("calls the global clearTimeout correctly when not installed", function () {
296
+ var delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['clearTimeout']),
297
+ global = jasmine.getGlobal(),
298
+ clock = new j$.Clock(global, delayedFunctionScheduler);
299
+
300
+ expect(function() {
301
+ clock.clearTimeout(123)
302
+ }).not.toThrow();
303
+ });
304
+
305
+ it("calls the global clearTimeout correctly when not installed", function () {
306
+ var delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['clearTimeout']),
307
+ global = jasmine.getGlobal(),
308
+ clock = new j$.Clock(global, delayedFunctionScheduler);
309
+
310
+ expect(function() {
311
+ clock.clearInterval(123)
312
+ }).not.toThrow();
313
+ });
314
+ });