jasmine-core 2.4.1 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/lib/console/console.js +1 -1
  3. data/lib/jasmine-core/boot.js +1 -1
  4. data/lib/jasmine-core/jasmine-html.js +15 -7
  5. data/lib/jasmine-core/jasmine.js +261 -82
  6. data/lib/jasmine-core/node_boot.js +1 -1
  7. data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +16 -16
  8. data/lib/jasmine-core/spec/core/CallTrackerSpec.js +26 -11
  9. data/lib/jasmine-core/spec/core/ClockSpec.js +61 -42
  10. data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +28 -15
  11. data/lib/jasmine-core/spec/core/EnvSpec.js +8 -8
  12. data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +6 -6
  13. data/lib/jasmine-core/spec/core/ExceptionsSpec.js +1 -1
  14. data/lib/jasmine-core/spec/core/ExpectationResultSpec.js +8 -8
  15. data/lib/jasmine-core/spec/core/ExpectationSpec.js +17 -17
  16. data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +14 -14
  17. data/lib/jasmine-core/spec/core/MockDateSpec.js +14 -14
  18. data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +65 -56
  19. data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +32 -18
  20. data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +27 -3
  21. data/lib/jasmine-core/spec/core/SpecSpec.js +37 -37
  22. data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +46 -7
  23. data/lib/jasmine-core/spec/core/SpySpec.js +11 -11
  24. data/lib/jasmine-core/spec/core/SpyStrategySpec.js +25 -13
  25. data/lib/jasmine-core/spec/core/SuiteSpec.js +25 -25
  26. data/lib/jasmine-core/spec/core/TimerSpec.js +2 -2
  27. data/lib/jasmine-core/spec/core/TreeProcessorSpec.js +26 -26
  28. data/lib/jasmine-core/spec/core/UtilSpec.js +12 -12
  29. data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +8 -8
  30. data/lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js +7 -7
  31. data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js +6 -6
  32. data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +11 -11
  33. data/lib/jasmine-core/spec/core/asymmetric_equality/StringMatchingSpec.js +4 -4
  34. data/lib/jasmine-core/spec/core/formatErrorMsgSpec.js +13 -0
  35. data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +2 -2
  36. data/lib/jasmine-core/spec/core/integration/EnvSpec.js +195 -76
  37. data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +20 -21
  38. data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +164 -114
  39. data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +4 -4
  40. data/lib/jasmine-core/spec/core/matchers/toBeDefinedSpec.js +2 -2
  41. data/lib/jasmine-core/spec/core/matchers/toBeFalsySpec.js +2 -2
  42. data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanOrEqualSpec.js +29 -0
  43. data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +2 -2
  44. data/lib/jasmine-core/spec/core/matchers/toBeLessThanOrEqualSpec.js +29 -0
  45. data/lib/jasmine-core/spec/core/matchers/toBeLessThanSpec.js +2 -2
  46. data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +3 -3
  47. data/lib/jasmine-core/spec/core/matchers/toBeNullSpec.js +2 -2
  48. data/lib/jasmine-core/spec/core/matchers/toBeSpec.js +2 -2
  49. data/lib/jasmine-core/spec/core/matchers/toBeTruthySpec.js +2 -2
  50. data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +2 -2
  51. data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +4 -4
  52. data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +2 -2
  53. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +11 -11
  54. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledTimesSpec.js +22 -17
  55. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +11 -10
  56. data/lib/jasmine-core/spec/core/matchers/toMatchSpec.js +7 -6
  57. data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +24 -24
  58. data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +9 -8
  59. data/lib/jasmine-core/spec/helpers/defineJasmineUnderTest.js +3 -3
  60. data/lib/jasmine-core/spec/helpers/nodeDefineJasmineUnderTest.js +5 -5
  61. data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +95 -59
  62. data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +3 -3
  63. data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +1 -1
  64. data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +4 -4
  65. data/lib/jasmine-core/spec/html/QueryStringSpec.js +5 -5
  66. data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +4 -4
  67. data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +2 -2
  68. data/lib/jasmine-core/spec/performance/large_object_test.js +1 -1
  69. data/lib/jasmine-core/version.rb +1 -1
  70. metadata +5 -3
  71. data/lib/jasmine-core/spec/node_suite.js +0 -195
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (c) 2008-2015 Pivotal Labs
2
+ Copyright (c) 2008-2016 Pivotal Labs
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining
5
5
  a copy of this software and associated documentation files (the
@@ -19,7 +19,7 @@ describe("ConsoleReporter", function() {
19
19
  });
20
20
 
21
21
  it("reports that the suite has started to the console", function() {
22
- var reporter = new j$.ConsoleReporter({
22
+ var reporter = new jasmineUnderTest.ConsoleReporter({
23
23
  print: out.print
24
24
  });
25
25
 
@@ -30,7 +30,7 @@ describe("ConsoleReporter", function() {
30
30
 
31
31
  it("starts the provided timer when jasmine starts", function() {
32
32
  var timerSpy = jasmine.createSpyObj('timer', ['start']),
33
- reporter = new j$.ConsoleReporter({
33
+ reporter = new jasmineUnderTest.ConsoleReporter({
34
34
  print: out.print,
35
35
  timer: timerSpy
36
36
  });
@@ -41,7 +41,7 @@ describe("ConsoleReporter", function() {
41
41
  });
42
42
 
43
43
  it("reports a passing spec as a dot", function() {
44
- var reporter = new j$.ConsoleReporter({
44
+ var reporter = new jasmineUnderTest.ConsoleReporter({
45
45
  print: out.print
46
46
  });
47
47
 
@@ -51,7 +51,7 @@ describe("ConsoleReporter", function() {
51
51
  });
52
52
 
53
53
  it("does not report a disabled spec", function() {
54
- var reporter = new j$.ConsoleReporter({
54
+ var reporter = new jasmineUnderTest.ConsoleReporter({
55
55
  print: out.print
56
56
  });
57
57
 
@@ -61,7 +61,7 @@ describe("ConsoleReporter", function() {
61
61
  });
62
62
 
63
63
  it("reports a failing spec as an 'F'", function() {
64
- var reporter = new j$.ConsoleReporter({
64
+ var reporter = new jasmineUnderTest.ConsoleReporter({
65
65
  print: out.print
66
66
  });
67
67
 
@@ -71,7 +71,7 @@ describe("ConsoleReporter", function() {
71
71
  });
72
72
 
73
73
  it("reports a pending spec as a '*'", function() {
74
- var reporter = new j$.ConsoleReporter({
74
+ var reporter = new jasmineUnderTest.ConsoleReporter({
75
75
  print: out.print
76
76
  });
77
77
 
@@ -81,7 +81,7 @@ describe("ConsoleReporter", function() {
81
81
  });
82
82
 
83
83
  it("alerts user if there are no specs", function(){
84
- var reporter = new j$.ConsoleReporter({
84
+ var reporter = new jasmineUnderTest.ConsoleReporter({
85
85
  print: out.print
86
86
  });
87
87
 
@@ -94,7 +94,7 @@ describe("ConsoleReporter", function() {
94
94
 
95
95
  it("reports a summary when done (singular spec and time)", function() {
96
96
  var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
97
- reporter = new j$.ConsoleReporter({
97
+ reporter = new jasmineUnderTest.ConsoleReporter({
98
98
  print: out.print,
99
99
  timer: timerSpy
100
100
  });
@@ -114,7 +114,7 @@ describe("ConsoleReporter", function() {
114
114
 
115
115
  it("reports a summary when done (pluralized specs and seconds)", function() {
116
116
  var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
117
- reporter = new j$.ConsoleReporter({
117
+ reporter = new jasmineUnderTest.ConsoleReporter({
118
118
  print: out.print,
119
119
  timer: timerSpy
120
120
  });
@@ -148,7 +148,7 @@ describe("ConsoleReporter", function() {
148
148
  });
149
149
 
150
150
  it("reports a summary when done that includes stack traces for a failing suite", function() {
151
- var reporter = new j$.ConsoleReporter({
151
+ var reporter = new jasmineUnderTest.ConsoleReporter({
152
152
  print: out.print
153
153
  });
154
154
 
@@ -182,7 +182,7 @@ describe("ConsoleReporter", function() {
182
182
 
183
183
  beforeEach(function() {
184
184
  onComplete = jasmine.createSpy('onComplete');
185
- reporter = new j$.ConsoleReporter({
185
+ reporter = new jasmineUnderTest.ConsoleReporter({
186
186
  print: out.print,
187
187
  onComplete: onComplete
188
188
  });
@@ -210,7 +210,7 @@ describe("ConsoleReporter", function() {
210
210
 
211
211
  describe("with color", function() {
212
212
  it("reports that the suite has started to the console", function() {
213
- var reporter = new j$.ConsoleReporter({
213
+ var reporter = new jasmineUnderTest.ConsoleReporter({
214
214
  print: out.print,
215
215
  showColors: true
216
216
  });
@@ -221,7 +221,7 @@ describe("ConsoleReporter", function() {
221
221
  });
222
222
 
223
223
  it("reports a passing spec as a dot", function() {
224
- var reporter = new j$.ConsoleReporter({
224
+ var reporter = new jasmineUnderTest.ConsoleReporter({
225
225
  print: out.print,
226
226
  showColors: true
227
227
  });
@@ -232,7 +232,7 @@ describe("ConsoleReporter", function() {
232
232
  });
233
233
 
234
234
  it("does not report a disabled spec", function() {
235
- var reporter = new j$.ConsoleReporter({
235
+ var reporter = new jasmineUnderTest.ConsoleReporter({
236
236
  print: out.print,
237
237
  showColors: true
238
238
  });
@@ -243,7 +243,7 @@ describe("ConsoleReporter", function() {
243
243
  });
244
244
 
245
245
  it("reports a failing spec as an 'F'", function() {
246
- var reporter = new j$.ConsoleReporter({
246
+ var reporter = new jasmineUnderTest.ConsoleReporter({
247
247
  print: out.print,
248
248
  showColors: true
249
249
  });
@@ -254,7 +254,7 @@ describe("ConsoleReporter", function() {
254
254
  });
255
255
 
256
256
  it("displays all afterAll exceptions", function() {
257
- var reporter = new j$.ConsoleReporter({
257
+ var reporter = new jasmineUnderTest.ConsoleReporter({
258
258
  print: out.print,
259
259
  showColors: true
260
260
  });
@@ -1,6 +1,6 @@
1
1
  describe("CallTracker", function() {
2
2
  it("tracks that it was called when executed", function() {
3
- var callTracker = new j$.CallTracker();
3
+ var callTracker = new jasmineUnderTest.CallTracker();
4
4
 
5
5
  expect(callTracker.any()).toBe(false);
6
6
 
@@ -10,7 +10,7 @@ describe("CallTracker", function() {
10
10
  });
11
11
 
12
12
  it("tracks that number of times that it is executed", function() {
13
- var callTracker = new j$.CallTracker();
13
+ var callTracker = new jasmineUnderTest.CallTracker();
14
14
 
15
15
  expect(callTracker.count()).toEqual(0);
16
16
 
@@ -20,7 +20,7 @@ describe("CallTracker", function() {
20
20
  });
21
21
 
22
22
  it("tracks the params from each execution", function() {
23
- var callTracker = new j$.CallTracker();
23
+ var callTracker = new jasmineUnderTest.CallTracker();
24
24
 
25
25
  callTracker.track({object: void 0, args: []});
26
26
  callTracker.track({object: {}, args: [0, "foo"]});
@@ -31,13 +31,13 @@ describe("CallTracker", function() {
31
31
  });
32
32
 
33
33
  it("returns any empty array when there was no call", function() {
34
- var callTracker = new j$.CallTracker();
34
+ var callTracker = new jasmineUnderTest.CallTracker();
35
35
 
36
36
  expect(callTracker.argsFor(0)).toEqual([]);
37
37
  });
38
38
 
39
39
  it("allows access for the arguments for all calls", function() {
40
- var callTracker = new j$.CallTracker();
40
+ var callTracker = new jasmineUnderTest.CallTracker();
41
41
 
42
42
  callTracker.track({object: {}, args: []});
43
43
  callTracker.track({object: {}, args: [0, "foo"]});
@@ -46,7 +46,7 @@ describe("CallTracker", function() {
46
46
  });
47
47
 
48
48
  it("tracks the context and arguments for each call", function() {
49
- var callTracker = new j$.CallTracker();
49
+ var callTracker = new jasmineUnderTest.CallTracker();
50
50
 
51
51
  callTracker.track({object: {}, args: []});
52
52
  callTracker.track({object: {}, args: [0, "foo"]});
@@ -57,7 +57,7 @@ describe("CallTracker", function() {
57
57
  });
58
58
 
59
59
  it("simplifies access to the arguments for the last (most recent) call", function() {
60
- var callTracker = new j$.CallTracker();
60
+ var callTracker = new jasmineUnderTest.CallTracker();
61
61
 
62
62
  callTracker.track();
63
63
  callTracker.track({object: {}, args: [0, "foo"]});
@@ -69,13 +69,13 @@ describe("CallTracker", function() {
69
69
  });
70
70
 
71
71
  it("returns a useful falsy value when there isn't a last (most recent) call", function() {
72
- var callTracker = new j$.CallTracker();
72
+ var callTracker = new jasmineUnderTest.CallTracker();
73
73
 
74
74
  expect(callTracker.mostRecent()).toBeFalsy();
75
75
  });
76
76
 
77
77
  it("simplifies access to the arguments for the first (oldest) call", function() {
78
- var callTracker = new j$.CallTracker();
78
+ var callTracker = new jasmineUnderTest.CallTracker();
79
79
 
80
80
  callTracker.track({object: {}, args: [0, "foo"]});
81
81
 
@@ -83,14 +83,14 @@ describe("CallTracker", function() {
83
83
  });
84
84
 
85
85
  it("returns a useful falsy value when there isn't a first (oldest) call", function() {
86
- var callTracker = new j$.CallTracker();
86
+ var callTracker = new jasmineUnderTest.CallTracker();
87
87
 
88
88
  expect(callTracker.first()).toBeFalsy();
89
89
  });
90
90
 
91
91
 
92
92
  it("allows the tracking to be reset", function() {
93
- var callTracker = new j$.CallTracker();
93
+ var callTracker = new jasmineUnderTest.CallTracker();
94
94
 
95
95
  callTracker.track();
96
96
  callTracker.track({object: {}, args: [0, "foo"]});
@@ -102,4 +102,19 @@ describe("CallTracker", function() {
102
102
  expect(callTracker.all()).toEqual([]);
103
103
  expect(callTracker.mostRecent()).toBeFalsy();
104
104
  });
105
+
106
+ it("allows object arguments to be shallow cloned", function() {
107
+ var callTracker = new jasmineUnderTest.CallTracker();
108
+ callTracker.saveArgumentsByValue();
109
+
110
+ var objectArg = {"foo": "bar"},
111
+ arrayArg = ["foo", "bar"];
112
+
113
+ callTracker.track({object: {}, args: [objectArg, arrayArg, false, undefined, null, NaN, "", 0, 1.0]});
114
+
115
+ expect(callTracker.mostRecent().args[0]).not.toBe(objectArg);
116
+ expect(callTracker.mostRecent().args[0]).toEqual(objectArg);
117
+ expect(callTracker.mostRecent().args[1]).not.toBe(arrayArg);
118
+ expect(callTracker.mostRecent().args[1]).toEqual(arrayArg);
119
+ });
105
120
  });
@@ -6,7 +6,7 @@ describe("Clock", function() {
6
6
  delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction"]),
7
7
  delayedFn = jasmine.createSpy("delayedFn"),
8
8
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
9
- clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
9
+ clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
10
10
 
11
11
  fakeGlobal.setTimeout(delayedFn, 0);
12
12
 
@@ -28,7 +28,7 @@ describe("Clock", function() {
28
28
  delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["removeFunctionWithId"]),
29
29
  delayedFn = jasmine.createSpy("delayedFn"),
30
30
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
31
- clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
31
+ clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
32
32
 
33
33
  fakeGlobal.clearTimeout("foo");
34
34
 
@@ -50,7 +50,7 @@ describe("Clock", function() {
50
50
  delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction"]),
51
51
  delayedFn = jasmine.createSpy("delayedFn"),
52
52
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
53
- clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
53
+ clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
54
54
 
55
55
  fakeGlobal.setInterval(delayedFn, 0);
56
56
 
@@ -72,7 +72,7 @@ describe("Clock", function() {
72
72
  delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["removeFunctionWithId"]),
73
73
  delayedFn = jasmine.createSpy("delayedFn"),
74
74
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
75
- clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
75
+ clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
76
76
 
77
77
  fakeGlobal.clearInterval("foo");
78
78
 
@@ -94,7 +94,7 @@ describe("Clock", function() {
94
94
  fakeGlobal = { setTimeout: originalFakeSetTimeout },
95
95
  delayedFunctionSchedulerFactory = jasmine.createSpy('delayedFunctionSchedulerFactory'),
96
96
  mockDate = {},
97
- clock = new j$.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
97
+ clock = new jasmineUnderTest.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
98
98
 
99
99
  fakeGlobal.setTimeout = replacedSetTimeout;
100
100
 
@@ -112,7 +112,7 @@ describe("Clock", function() {
112
112
  fakeGlobal = { clearTimeout: originalFakeClearTimeout },
113
113
  delayedFunctionSchedulerFactory = jasmine.createSpy('delayedFunctionSchedulerFactory'),
114
114
  mockDate = {},
115
- clock = new j$.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
115
+ clock = new jasmineUnderTest.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
116
116
 
117
117
  fakeGlobal.clearTimeout = replacedClearTimeout;
118
118
 
@@ -130,7 +130,7 @@ describe("Clock", function() {
130
130
  fakeGlobal = { setInterval: originalFakeSetInterval },
131
131
  delayedFunctionSchedulerFactory = jasmine.createSpy('delayedFunctionSchedulerFactory'),
132
132
  mockDate = {},
133
- clock = new j$.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
133
+ clock = new jasmineUnderTest.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
134
134
 
135
135
  fakeGlobal.setInterval = replacedSetInterval;
136
136
 
@@ -148,7 +148,7 @@ describe("Clock", function() {
148
148
  fakeGlobal = { clearInterval: originalFakeClearInterval },
149
149
  delayedFunctionSchedulerFactory = jasmine.createSpy('delayedFunctionSchedulerFactory'),
150
150
  mockDate = {},
151
- clock = new j$.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
151
+ clock = new jasmineUnderTest.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
152
152
 
153
153
  fakeGlobal.clearInterval = replacedClearInterval;
154
154
 
@@ -174,7 +174,7 @@ describe("Clock", function() {
174
174
  delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction", "reset"]),
175
175
  delayedFn = jasmine.createSpy("delayedFn"),
176
176
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
177
- clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
177
+ clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
178
178
 
179
179
  clock.install();
180
180
  clock.uninstall();
@@ -204,7 +204,7 @@ describe("Clock", function() {
204
204
  delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction", "reset", "removeFunctionWithId"]),
205
205
  delayedFn = jasmine.createSpy("delayedFn"),
206
206
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
207
- clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
207
+ clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
208
208
  passedFunctionCalled = false;
209
209
 
210
210
  clock.withMock(function() {
@@ -251,7 +251,7 @@ describe("Clock", function() {
251
251
  delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction", "reset", "removeFunctionWithId"]),
252
252
  delayedFn = jasmine.createSpy("delayedFn"),
253
253
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
254
- clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
254
+ clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
255
255
  passedFunctionCalled = false;
256
256
 
257
257
  expect(function() {
@@ -294,7 +294,7 @@ describe("Clock", function() {
294
294
  fakeGlobal = { setTimeout: fakeSetTimeout },
295
295
  delayedFn = jasmine.createSpy('delayedFn'),
296
296
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
297
- clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
297
+ clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
298
298
 
299
299
  clock.install();
300
300
  clock.setTimeout(delayedFn, 0, 'a', 'b');
@@ -311,7 +311,7 @@ describe("Clock", function() {
311
311
  fakeGlobal = { setTimeout: fakeSetTimeout },
312
312
  delayedFn = jasmine.createSpy('delayedFn'),
313
313
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
314
- clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
314
+ clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
315
315
  timeoutId;
316
316
 
317
317
  clock.install();
@@ -326,7 +326,7 @@ describe("Clock", function() {
326
326
  fakeGlobal = { setTimeout: fakeClearTimeout },
327
327
  delayedFn = jasmine.createSpy('delayedFn'),
328
328
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
329
- clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
329
+ clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
330
330
 
331
331
  clock.install();
332
332
  clock.clearTimeout(123);
@@ -342,7 +342,7 @@ describe("Clock", function() {
342
342
  fakeGlobal = { setInterval: fakeSetInterval },
343
343
  delayedFn = jasmine.createSpy('delayedFn'),
344
344
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
345
- clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
345
+ clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
346
346
 
347
347
  clock.install();
348
348
  clock.setInterval(delayedFn, 0, 'a', 'b');
@@ -359,7 +359,7 @@ describe("Clock", function() {
359
359
  fakeGlobal = { setInterval: fakeSetInterval },
360
360
  delayedFn = jasmine.createSpy('delayedFn'),
361
361
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
362
- clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
362
+ clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
363
363
  intervalId;
364
364
 
365
365
  clock.install();
@@ -374,7 +374,7 @@ describe("Clock", function() {
374
374
  fakeGlobal = { setInterval: clearInterval },
375
375
  delayedFn = jasmine.createSpy('delayedFn'),
376
376
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
377
- clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
377
+ clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
378
378
 
379
379
  clock.install();
380
380
  clock.clearInterval(123);
@@ -384,7 +384,7 @@ describe("Clock", function() {
384
384
  });
385
385
 
386
386
  it("gives you a friendly reminder if the Clock is not installed and you tick", function() {
387
- var clock = new j$.Clock({}, jasmine.createSpyObj('delayedFunctionScheduler', ['tick']));
387
+ var clock = new jasmineUnderTest.Clock({}, jasmine.createSpyObj('delayedFunctionScheduler', ['tick']));
388
388
  expect(function() {
389
389
  clock.tick(50);
390
390
  }).toThrow();
@@ -401,7 +401,7 @@ describe("Clock", function() {
401
401
  setInterval: fakeSetInterval
402
402
  },
403
403
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
404
- clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
404
+ clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
405
405
 
406
406
  fakeSetTimeout.apply = null;
407
407
  fakeSetInterval.apply = null;
@@ -428,9 +428,9 @@ describe("Clock (acceptance)", function() {
428
428
  delayedFn2 = jasmine.createSpy('delayedFn2'),
429
429
  delayedFn3 = jasmine.createSpy('delayedFn3'),
430
430
  recurring1 = jasmine.createSpy('recurring1'),
431
- delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
431
+ delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
432
432
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
433
- clock = new j$.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate);
433
+ clock = new jasmineUnderTest.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate);
434
434
 
435
435
  clock.install();
436
436
 
@@ -475,9 +475,9 @@ describe("Clock (acceptance)", function() {
475
475
 
476
476
  it("can clear a previously set timeout", function() {
477
477
  var clearedFn = jasmine.createSpy('clearedFn'),
478
- delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
478
+ delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
479
479
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
480
- clock = new j$.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate),
480
+ clock = new jasmineUnderTest.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate),
481
481
  timeoutId;
482
482
 
483
483
  clock.install();
@@ -493,9 +493,9 @@ describe("Clock (acceptance)", function() {
493
493
 
494
494
  it("can clear a previously set interval using that interval's handler", function() {
495
495
  var spy = jasmine.createSpy('spy'),
496
- delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
496
+ delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
497
497
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
498
- clock = new j$.Clock({setInterval: function() {}}, function () { return delayedFunctionScheduler; }, mockDate),
498
+ clock = new jasmineUnderTest.Clock({setInterval: function() {}}, function () { return delayedFunctionScheduler; }, mockDate),
499
499
  intervalId;
500
500
 
501
501
  clock.install();
@@ -511,9 +511,9 @@ describe("Clock (acceptance)", function() {
511
511
 
512
512
  it("correctly schedules functions after the Clock has advanced", function() {
513
513
  var delayedFn1 = jasmine.createSpy('delayedFn1'),
514
- delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
514
+ delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
515
515
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
516
- clock = new j$.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
516
+ clock = new jasmineUnderTest.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
517
517
 
518
518
  clock.install();
519
519
 
@@ -528,9 +528,9 @@ describe("Clock (acceptance)", function() {
528
528
  it("correctly schedules functions while the Clock is advancing", function() {
529
529
  var delayedFn1 = jasmine.createSpy('delayedFn1'),
530
530
  delayedFn2 = jasmine.createSpy('delayedFn2'),
531
- delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
531
+ delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
532
532
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
533
- clock = new j$.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
533
+ clock = new jasmineUnderTest.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
534
534
 
535
535
  delayedFn1.and.callFake(function() { clock.setTimeout(delayedFn2, 0); });
536
536
  clock.install();
@@ -547,9 +547,9 @@ describe("Clock (acceptance)", function() {
547
547
  it("correctly calls functions scheduled while the Clock is advancing", function() {
548
548
  var delayedFn1 = jasmine.createSpy('delayedFn1'),
549
549
  delayedFn2 = jasmine.createSpy('delayedFn2'),
550
- delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
550
+ delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
551
551
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
552
- clock = new j$.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
552
+ clock = new jasmineUnderTest.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
553
553
 
554
554
  delayedFn1.and.callFake(function() { clock.setTimeout(delayedFn2, 1); });
555
555
  clock.install();
@@ -563,9 +563,9 @@ describe("Clock (acceptance)", function() {
563
563
  it("correctly schedules functions scheduled while the Clock is advancing but after the Clock is uninstalled", function() {
564
564
  var delayedFn1 = jasmine.createSpy('delayedFn1'),
565
565
  delayedFn2 = jasmine.createSpy('delayedFn2'),
566
- delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
566
+ delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
567
567
  mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
568
- clock = new j$.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
568
+ clock = new jasmineUnderTest.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
569
569
 
570
570
  delayedFn1.and.callFake(function() {
571
571
  clock.uninstall();
@@ -585,10 +585,10 @@ describe("Clock (acceptance)", function() {
585
585
  });
586
586
 
587
587
  it("does not mock the Date object by default", function() {
588
- var delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
588
+ var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
589
589
  global = {Date: Date},
590
- mockDate = new j$.MockDate(global),
591
- clock = new j$.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate);
590
+ mockDate = new jasmineUnderTest.MockDate(global),
591
+ clock = new jasmineUnderTest.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate);
592
592
 
593
593
  clock.install();
594
594
 
@@ -602,10 +602,10 @@ describe("Clock (acceptance)", function() {
602
602
  });
603
603
 
604
604
  it("mocks the Date object and sets it to current time", function() {
605
- var delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
605
+ var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
606
606
  global = {Date: Date},
607
- mockDate = new j$.MockDate(global),
608
- clock = new j$.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate);
607
+ mockDate = new jasmineUnderTest.MockDate(global),
608
+ clock = new jasmineUnderTest.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate);
609
609
 
610
610
  clock.install().mockDate();
611
611
 
@@ -626,10 +626,10 @@ describe("Clock (acceptance)", function() {
626
626
  });
627
627
 
628
628
  it("mocks the Date object and sets it to a given time", function() {
629
- var delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
629
+ var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
630
630
  global = {Date: Date},
631
- mockDate = new j$.MockDate(global),
632
- clock = new j$.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate),
631
+ mockDate = new jasmineUnderTest.MockDate(global),
632
+ clock = new jasmineUnderTest.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate),
633
633
  baseTime = new Date(2013, 9, 23);
634
634
 
635
635
 
@@ -652,4 +652,23 @@ describe("Clock (acceptance)", function() {
652
652
 
653
653
  expect(timeoutDate).toEqual(baseTime.getTime() + 150);
654
654
  });
655
+
656
+ it("mocks the Date object and updates the date per delayed function", function () {
657
+ var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
658
+ global = {Date: Date},
659
+ mockDate = new jasmineUnderTest.MockDate(global),
660
+ clock = new jasmineUnderTest.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate),
661
+ baseTime = new Date();
662
+
663
+ clock.install().mockDate(baseTime);
664
+
665
+ var actualTimes = [];
666
+ var pushCurrentTime = function() { actualTimes.push(global.Date().getTime()); };
667
+ delayedFunctionScheduler.scheduleFunction(pushCurrentTime);
668
+ delayedFunctionScheduler.scheduleFunction(pushCurrentTime, 1);
669
+
670
+ clock.tick(1);
671
+
672
+ expect(actualTimes).toEqual([baseTime.getTime(), baseTime.getTime() + 1]);
673
+ })
655
674
  });